[task] Sign members in to MCP and manage sessions

Open
#440 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
18/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
python

Research direction

Start by reading the blocking issues #437 (SDK choice), #438 (directory client) and #439 (shared start/confirm logic), since this work cannot begin until all three land. Then check whether the chosen Python MCP SDK exposes OAuth authorization-server routes behind a provider interface; if so implement the provider, otherwise record why the routes are hand-built. Existing email-code flow lives in the /v1/auth/* handlers from #331 and prior art is PR #125. Done means the listed tests around /authorize, /token, /revoke and the admin revoke command pass.

Written by the indexing model from the issue text.

Description

area/integration area/service type/feature
Blocked by

#437

What

Give allowlisted coding agents browser OAuth sign-in using the gateway’s email-code login and a durable, revocable session.

Why

Members need to sign in as themselves and keep the agent connected across access-token expiry.

Area

integration, service

Done looks like
  • Extract shared email-login start and confirm functions for the browser and the existing gateway routes. Preserve authenticated caller identity, challenge binding, delivery timing, limits and the existing public login contract.
  • Add migration 003 with a working downgrade and matching in-memory and Postgres adapters. Bind each session to the member, client and environment. Store only hashes of authorization codes and tokens.
  • Exchange each short-lived code once. Rotate refresh tokens, handle concurrent refresh within the agreed grace policy, and revoke on reuse outside it. Support single-session and all-session revocation.
  • Discovery documents (/.well-known/oauth-protected-resource/mcp and /.well-known/oauth-authorization-server) and /authorize are served only when both the MCP switch and email_login_enabled are on. /authorize accepts only S256 PKCE, this gateway's /mcp as resource, a client ID on the allowlist, and a loopback redirect address listed in that client's metadata document.
  • The login page signs the member in through #331's shared start and confirm logic under the app name mcp, with their real IP and the same "check your email" message for members and non-members. It sends no-store, a content security policy and framing protection, rejects cross-site form posts, and escapes everything it shows back.
  • /token exchanges the code and PKCE verifier for tokens and rotates refresh tokens, checking membership on each refresh. /revoke ends the session. Tokens are bound to /mcp and the environment.
  • A gateway-keys-style CLI command revokes all of a person's sessions.
  • Sign-in, refresh, logout, revocation and failed sign-in attempts are written to the audit log, with no tokens, codes or email addresses.
  • Tests cover the whole sign-in from /authorize, against fake directory and verification clients: success, non-member, wrong or expired code, wrong PKCE verifier, unknown client, bad redirect address, refresh, refresh after membership ends, revoke, and the admin command.
Design notes

Part of #436. Storage and the email-login refactor can begin alongside #437. Mounted OAuth routes depend on its SDK and feature switch. #442 owns authorization on tool requests. Detailed storage and email-login contracts: #438 and #439. Approved design: #335 / PR #399.

Dominant language
Python
Stars
0
Forks
2
Avg merge
3d 3h
Merged PRs (30d)
31

Getting set up

  • No Dockerfile or Docker Compose file
  • Has a pull request template
  • No contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from UTMIST/Misty

All issues in UTMIST/Misty

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.