OAuth for MCP clients

A client connects to the hosted MCP server and the person signs in in a browser. No API key is pasted anywhere. This page is for people writing a client; Claude Code and Cursor already do all of it.

The access token it ends up with is an ordinary API key, valid for one hour and renewed with a refresh token. It is listed in the dashboard beside keys people made, marked as OAuth, and revoking it there ends the connection.

The flow

  1. Connect. POST https://mcp.passivedev.com/mcp with no token answers 401 with WWW-Authenticate: Bearer resource_metadata="https://mcp.passivedev.com/.well-known/oauth-protected-resource/mcp".
  2. Find the authorization server. GET that URL. authorization_servers names it (https://api.passivedev.com).
  3. Read its metadata: GET https://api.passivedev.com/.well-known/oauth-authorization-server.
  4. Register (once per install): POST /oauth/register with {"client_name", "redirect_uris"}. You get a client_id. Clients are public: there is no secret.
  5. Send the person to the authorization_endpoint with response_type=code, your client_id, a registered redirect_uri, a PKCE code_challenge (method S256), a state, the scope you want and resource set to the MCP URL you connect to.
  6. They approve and the browser returns to your redirect_uri with code, state and iss.
  7. Exchange the code: POST /oauth/token (form encoded) with grant_type=authorization_code, client_id, code, redirect_uri and code_verifier. You receive access_token, refresh_token, expires_in (3600) and scope.
  8. Call the MCP server with Authorization: Bearer <access_token>.
  9. Refresh with grant_type=refresh_token, client_id and refresh_token. You get a new pair.

Rules a client must follow

  • PKCE S256 is required. plain is refused.
  • Redirect URIs must be https, loopback http (http://localhost:<port>/..., where the port may vary), or the custom scheme of a known MCP client: cursor, vscode, vscode-insiders, windsurf, zed, claude. Any other custom scheme is refused, because the browser would hand the code to whatever program the operating system has registered for it. They are matched exactly when you register.
  • A refresh token works once. Save the new one before using the new access token. Presenting one of the last five spent refresh tokens revokes the whole connection, because it can only mean it was copied. An older one is simply invalid.
  • An authorization code works once and is bound to your client, redirect URI and challenge.
  • Scopes. A token carries only scopes the MCP tools use: apps:read, apps:write, db:read, db:write, jobs:read and workers:read. Anything else you ask for is dropped, with or without resource, because the token is an API key the whole REST API accepts. apps:secrets and db:credentials are never among them. A token for /mcp/read-only is limited to read scopes. A refresh may narrow the scopes, never widen them.
  • Errors use the standard OAuth error and error_description, not Passive's passive_error.

Limits

WhatLimit
Registrations10 an hour per address
Token requests120 a minute per address
Connected clients per person20 (signing in again replaces the same client's earlier connection)
Authorization requestvalid for 10 minutes
Authorization codevalid for 10 minutes, once
Access token1 hour
Refresh token30 days from its last use, rotated on every use
Connection (grant)90 days from sign-in, however often it refreshes; then sign in again
Registered client24 hours until it first signs someone in, then 90 days

Revoking

POST /oauth/revoke with token set to a refresh or access token ends the connection and always answers 200. A person can also revoke it from API keys in the dashboard.