Skip to main content

Browser Login for MCP Clients

MCPProxy can act as a small OAuth 2.1 authorization server so that an MCP client that supports OAuth can sign in instead of carrying an API key in its config file. It is off by default and experimental. An administrator approves each sign-in on a consent page or through the REST API (see Approving a sign-in) and manages the logins in the Clients page, the CLI or the credentials MCP tool (see Managing logins).

What it gives you:

  • public clients only (no client secret), PKCE S256, dynamic client registration (RFC 7591), protected-resource and authorization-server metadata (RFC 9728, RFC 8414) and the resource parameter (RFC 8707);
  • one sign-in address per client: http://127.0.0.1:8080/mcp/oauth/<client-id> (for example /mcp/oauth/cursor), or the generic /mcp/oauth where the administrator chooses the client at approval;
  • API keys keep working unchanged on /mcp and everywhere else.

It is served to loopback peers and loopback Host values only, and only by the personal edition (mcpproxy). In the server edition the feature is unavailable: with the switch on, the OAuth paths answer 404; with it off and never used, nothing changes, as in the personal edition.

Enabling​

{ "mcp_oauth_enabled": true }

or MCPPROXY_MCP_OAUTH_ENABLED=true for one process (never persisted). The setting is read live, so a config change needs no restart; the environment variable is read at start.

With the setting off and never used, nothing changes: the OAuth paths behave as they did before, and no storage bucket is created. A client registration is stored as soon as a client registers, but that does not change what "off" means. The boundary is the first stored login (an authorization code exchanged for tokens): from then on, off means the OAuth paths answer 404 and the records are kept (see Turning it off). scripts/test-client-oauth-e2e.sh checks off-and-never-used before it switches the feature on, and that "on, register only, off" still behaves as before.

Addresses​

PathPurpose
/mcp/oauth, /mcp/oauth/<client-id>The MCP endpoint, same tools as /mcp, bearer access token only
/.well-known/oauth-protected-resource/mcp/oauth[/<client-id>]Protected-resource metadata (RFC 9728)
/.well-known/oauth-authorization-serverAuthorization-server metadata (RFC 8414)
POST /oauth/registerDynamic client registration (RFC 7591)
GET /oauth/authorizeStarts a sign-in; redirects to /ui/authorize?request=<id>
POST /oauth/tokenCode exchange and refresh

An unknown client id in an address is 404. Without a valid token the OAuth MCP address answers 401 with a WWW-Authenticate: Bearer resource_metadata="..." challenge that points at the metadata of that exact address, so a client discovers the per-client path on its own. Registration, authorize and token are rate limited (429 with Retry-After).

Tokens​

  • Access token mcp_oat_..., valid for 1 hour, accepted only on the address it was issued for.
  • Refresh token mcp_ort_..., valid for 30 days from the last rotation, rotated on every use. Presenting an old (already rotated) refresh token revokes the whole login.
  • An access token is refused on /mcp, on another client's address and on a different origin (for example localhost instead of 127.0.0.1). An API key, ?apikey=, an agent token or the admin key is refused on the OAuth addresses.

A login belongs to a client and uses that client's profile binding, like its API key. A binding that would let the client bypass its profile through /mcp without authentication is refused the same way as for API keys (binding_bypassable_without_auth); set require_mcp_auth or use an all-servers binding.

Approving a sign-in​

A sign-in is held until an administrator decides it. With the admin API key:

# pending sign-ins
curl -s -H "X-API-Key: $KEY" http://127.0.0.1:8080/api/v1/oauth/authorizations
# one request, with the client, its binding and its revision
curl -s -H "X-API-Key: $KEY" http://127.0.0.1:8080/api/v1/oauth/authorizations/<id>
# approve (existing client: pass binding_revision when it has a binding)
curl -s -X POST -H "X-API-Key: $KEY" -H 'Content-Type: application/json' \
http://127.0.0.1:8080/api/v1/oauth/authorizations/<id>/approve \
-d '{"client":{"id":"cursor"},"mode":"switchable","profile":""}'

The answer is {"data":{"redirect_url":"..."}}; the client receives the code when its browser is sent there. Approval writes an audit activity row but stores no login and no binding: the login is stored when the client exchanges the code, after the binding and guard are checked again. (The client's registration was already stored when it registered.) .../deny ends the request with access_denied; .../preview shows the guard verdict without writing. Full contract: REST API.

The request opens in the Web UI at /ui/authorize?request=<id> (the page is never framed: frame-ancestors 'none' and X-Frame-Options: DENY). It shows the name the app reports, labelled as unverified, where the browser returns to, and one sentence on whose access is being handed over. Everything the app reports is shown as plain text.

  • Per-client address: the client is fixed. A client that has a profile binding shows it, without asking; a client with none and configured profiles needs a profile chosen before Approve is enabled. "Replace the previous browser login" appears only when this same registration signed in before.
  • Generic address: the page opens with a client selected and you can change it. When the reported name equals exactly one existing client's id, display name or known client name (Claude Code (my-server) is also tried as Claude Code), that client is pre-selected with the note Suggested because the app calls itself "<name>". MCPProxy cannot verify that. Otherwise "New client" is selected, with an editable id and name filled from the reported name. The suggestion decides nothing: approval carries the client the page sent, and a request with no client is refused (client_required).
  • The binding guard's verdict is fetched through the preview call whenever the choice is complete or changes; a refusal is shown with its fixes and Approve stays disabled.
  • Without the admin API key in this browser the page asks you to open the request from the MCPProxy tray or paste the key, and makes no request until then.

Managing logins​

Everything here is for administrators. An agent token or a client credential cannot see or revoke a login on any surface.

Settings. One switch, "Browser login for MCP clients", marked Experimental, in Security & Access (the tray Settings window has the same switch). It takes effect without a restart. While it is off and was never used, no other page mentions browser login.

Clients page. Expand a client to see its credentials: the API key and every login, each with its state (active, lapsed when the refresh token expired, revoked), when it was approved and last used, the name the app reported and the host it returns to. Those names come from the app, so they are shown as plain text. A login whose client introduces itself at initialize under a different name than the one it registered shows a "name mismatch" note; it is advice, never a block. "Revoke login" revokes that one login, "Revoke API key" revokes the key alone (the logins and the profile binding stay); both ask first. While the switch is off after use, the page says browser login is disabled and still lists the logins so they can be revoked.

CLI.

mcpproxy client show cursor # lists the API key and each login
mcpproxy client revoke-login cursor <grant-id>

MCP. The administrator credentials tool lists logins (list with kind=browser_login, and they appear under kind=all), get client=<id> includes them under logins, and revoke client=<id> grant=<grant_id> revokes one. revoke client=<id> without grant revokes everything under the client. No operation creates a login: only the person on the consent page can approve one. See credential lifecycle over MCP.

REST. GET /api/v1/clients and GET /api/v1/clients/<id> list each login under credentials (kind: browser_login, state active, lapsed or revoked, never the token). Revoke one with DELETE /api/v1/clients/<id>/logins/<grant_id>; the next request on that login, including on an open session, is refused. Forgetting a client removes all its logins.

Turning it off​

Set mcp_oauth_enabled back to false (or the variable to false). After the feature has been used, the OAuth paths answer 404, pending sign-ins are cancelled and existing logins stop working; they are kept, so turning it on again restores them while their tokens are still valid. browser_login_disabled on the client payload is true while it is off after use. API-key access is never affected. A login can still be revoked while off.

Downgrade​

Browser-login records live in their own storage buckets, created lazily on the first write (a client registration, then the first stored login). A binary that does not know the feature does not serve the OAuth paths, so the logins simply stop being usable.

Plain HTTP​

The issuer is http://127.0.0.1:<port>, not HTTPS. The specifications ask for HTTPS for non-loopback issuers; loopback HTTP is the common local-tool case. Client behaviour is checked in specs/132-client-oauth-login/verification/real-clients.md; the MCP TypeScript SDK client flow and the Claude Code CLI login flow are verified so far (Cursor, VS Code and MCP Inspector are not).