You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Research: authorizing worker agents, and whether Clerk can be the authorization server #733
What does the latest MCP authorization spec require of Patchy as both the protected resource and the authorization server, what do the clients we check actually run, and could Clerk be the authorization server instead of our own?
Cover, with each client's behaviour (Claude.ai, Claude desktop, ChatGPT, Claude Code, Codex, Cursor, Gemini CLI, VS Code):
Registration: Client ID Metadata Documents versus dynamic client registration; which clients use which, and whether a server can drop dynamic registration yet.
The flow: PKCE, resource indicators (RFC 8707) and audience binding, the iss parameter, scopes, and insufficient-scope / step-up responses.
Lifetimes: refresh tokens and rotation, the access token lifetimes clients expect, and what each client does when a token expires with or without a refresh token.
Redirects: the redirect URIs each client uses (loopback ports, hosted callbacks such as claude.ai or chatgpt.com) and what that means for consent and the page's CSP.
Open endpoints: discovery, registration and the token endpoint answer anyone. What the spec and current practice say about abuse: fetching a client's metadata document safely (Patchy fetching a URL a stranger names), registration spam and retention, and token endpoint guessing.
Plain http in development: clients' loopback rules. Testing found Claude Code sends credentials over http only to localhost or 127.0.0.1.
Then Clerk: does its OAuth and MCP support let it act as the authorization server for Patchy MCP, with our consent wording, company-scoped grants, per-client tokens listed and revoked on Your machines, the company's agent access switch checked on every call, and token checks at our door without a network round trip per call? What it costs, and what we would gain or lose against the prototype's own server (packages/auth/src/OAuth.ts on #727) and ADR-0008's machine tokens.
Resolves when
The findings are a comment on this ticket, every claim cited to the spec, the client's docs or Clerk's docs (or marked as observed, with how). The signing-in ticket consumes it.
#733: authorizing worker agents, and whether Clerk can be the authorization server (Opus 5.5 lane)
Researched 2026-10-17 from primary sources:
the MCP specification (2026-07-28 and 2025-11-25) and the RFCs and IETF drafts it cites;
each client's docs and changelog, and for open-source clients the code at a pinned commit;
shipped artifacts: Claude Code's npm binary 2.1.302, read for strings and never run, and VS Code 1.142.0's product.json;
Clerk's docs, OpenAPI specs, SDK source, changelog and pricing page.
Observed marks something fetched or read in shipped code rather than documented, and says how. Forum posts and GitHub issues are labelled staff or community. Read-only throughout: nothing was registered with a third party, no Clerk setting was touched, and nothing in the repo changed.
Short answer
Registration: add Client ID Metadata Documents (CIMD) and keep dynamic client registration (DCR).
The current revision, 2026-07-28, makes CIMD a SHOULD and deprecates DCR. DCR may be removed in "the first revision released on or after 2027-07-28" ([R26], [DEP]).
Five clients switch to CIMD once Patchy advertises client_id_metadata_document_supported: true: Claude.ai (and Claude Desktop and mobile through it), ChatGPT, Claude Code, Codex and VS Code. Claude.ai and Codex also require "none" in token_endpoint_auth_methods_supported, which Patchy already advertises.
Patchy can't drop DCR yet, because these still depend on it:
Cursor and Gemini CLI support only DCR or a hand-configured client ID.
When Claude Desktop starts a Claude Code sign-in with a non-loopback redirect, Claude Code withholds CIMD and registers instead.
Claude Desktop deployed on third-party platforms supports only DCR.
Refresh and lifetimes: issue rotating refresh tokens and shorten the access token.
Every client we checked refreshes before expiry (between 30 s and 5 min ahead) and once more after a 401. Every client accepts a rotated refresh token.
No client documents the access-token lifetime it expects.
Without a refresh token, every client needs the person to step in when the token lapses:
Claude Code fails the call with "run /mcp". A headless claude -p worker can't sign in at all.
Codex says "Run codex mcp login".
Claude.ai shows Reconnect.
OpenAI staff say ChatGPT "relies on the OAuth provider being configured to issue refresh tokens".
The spec says authorization servers SHOULD issue short-lived access tokens, and MUST rotate refresh tokens for public clients ([S26]).
Access tokens about an hour long, still opaque and checked against the database, so revocation stays immediate.
The rotating refresh token is the connection, under ADR-0008's limits: 30 idle days, 90 days absolute.
Open endpoints: the specs give clear rules, and the prototype misses four of them.
Fetching a metadata document. CIMD means Patchy fetches a URL that a stranger names. Draft -02 of the CIMD spec says the server:
MUST NOT fetch special-use IP addresses, which includes link-local cloud metadata addresses;
MUST NOT follow redirects;
SHOULD read at most about 5 KB;
should cache according to the response headers, and never cache an error.
It sets no timeout.
Registration spam. RFC 7591 says the server MAY rate-limit registration and MAY expire unused registrations. MCP says nothing. Most clients that use DCR register a new client every time someone signs in.
Guessing at the token endpoint. Codes and tokens need at least 128 bits of entropy (Patchy uses 256). Codes should live 10 minutes or less and be single use. A replayed code SHOULD revoke the tokens issued from it.
The prototype's four gaps:
no rate limit on /oauth/*;
registrations are kept forever;
it redirects before the person is signed in, which makes it an open redirect;
it doesn't revoke on code replay.
Clerk or our own: our own.
Clerk now covers the protocol:
CIMD (generally available since September 2026) and DCR;
PKCE, and RFC 8707 resource binding to an aud claim;
the RFC 9207 iss parameter and custom scopes;
refresh tokens, and JWT access tokens that Patchy could verify locally with the key it already holds.
It falls short on the ticket's own requirements:
Listing and revoking connections. No API lists a person's grants, or revokes one by grant, user or client. JWT access tokens can't be revoked during their one-day life, and Clerk's refresh tokens "never expire".
Agent access. There is no hook before issuance where the company's agent-access switch could stop a token.
Consent wording. Our wording needs a custom consent flow running in the browser, which Clerk's docs discourage.
Dev loop. Dev personas mode, which runs without Clerk, would lose MCP sign-in.
Clerk would replace roughly the 255 lines of OAuth.ts. Patchy would still keep its consent page, its connection table and its per-call check at the door.
Clerk's pricing page doesn't list OAuth, CIMD or DCR.
Per-client tables
Each row is how the client treats an authorization server shaped like Patchy's: PKCE S256 advertised, iss advertised, none only, public clients only.
Registration and the flow
Client
Registration Patchy will see
Without registration_endpoint
resource sent
Checks iss
Scopes it requests
403 insufficient_scope
Claude.ai (web; also Desktop, mobile and Cowork when signed in)
CIMD https://claude.ai/oauth/mcp-oauth-client-metadata when the server advertises CIMD andnone; otherwise DCR, a new client on every fresh connection; or an admin-entered client [CLA-AUTH]
Works through CIMD; otherwise "Claude can't obtain a client identity" [CLA-TROUBLE]
On authorize and token: the canonical MCP URL [CLA-TROUBLE]
Not documented
WWW-Authenticate scope, else PRM scopes_supported, plus offline_access if the server lists it [CLA-AUTH]
Asks the person to re-authorize, then retries with the union of scopes [CLA-LAZY]. Community reports say Cowork's step-up is broken (#931)
Claude Desktop
Remote connectors are the hosted Claude.ai client, brokered through Anthropic [CLA-HELP]. The Code tab is Claude Code, but sign-ins Desktop starts with a non-loopback redirect fall back to DCR (observed in bundle 2.1.302; changelog 2.1.243 [CC-LOG]). Desktop on third-party platforms: DCR or an admin client only [D3P]
Hosted: as Claude.ai. Desktop-started Claude Code sign-ins fail. Third-party platforms fail unless an admin configures a client
Hosted: as Claude.ai; third-party: not documented
Third-party checks the metadata issuer; the response iss isn't documented [D3P]
Hosted: as Claude.ai
Hosted: as Claude.ai
ChatGPT
Static credentials if the creator entered any; then CIMD https://chatgpt.com/oauth/client.json (the stable id, used because Patchy advertises iss); then DCR, run once per connection [OAI-AUTH], [OAI-CUSTOM]. Its CIMD document's singular field says private_key_jwt and the plural field lists none (observed)
The docs say CIMD has no registration step [OAI-AUTH]. In April 2026 OpenAI staff said CIMD detection was broken (forum). Untested since: test it live
On authorize and token, the exact PRM resource; on refresh, not documented [OAI-AUTH]
Yes, an exact match, required when the server advertises support [OAI-AUTH]
Order not documented. Uses the 401 scope, PRM scopes_supported and per-tool securitySchemes [OAI-AUTH]
Tool-level linking through _meta["mcp/www_authenticate"]; an HTTP 403 isn't documented [OAI-AUTH]
Claude Code
A stored client or --client-id; then CIMD https://claude.ai/oauth/claude-code-client-metadata whenever the flag is advertised (since 2.1.81); then DCR, client_name "Claude Code (<server>)", re-registered when the port changes [CC-MCP], [CC-LOG], bundle
Works through CIMD, except for the Desktop-started sign-ins above
On authorize, token and refresh, when a PRM was found. The PRM resource must be same-origin and a path prefix of the MCP URL (bundle)
Yes, on the v2 runtime (the default since 2.1.232/2.1.274). A missing iss fails when the server advertises support [CC-MCP], [CC-ERR]
WWW-Authenticate scope, else PRM scopes_supported. Never the server's scopes_supported (since 2.1.196). Adds offline_access if listed, and then also prompt=consent [CC-MCP], bundle
The call fails with "needs additional permissions (scope: …) — run /mcp"; interactive sessions get a re-authenticate prompt since 2.1.288 [CC-ERR], [CC-LOG]
Codex (CLI, IDE, app)
A configured client_id; then CIMD https://chatgpt.com/oauth/codex/client.json (needs the flag, none, and the native /callback; since v0.148.0, 2026-08-18); then DCR, a new client on every login [CODEX-REG], PR #38089
Works through CIMD, unless a custom callback URL or --oauth-client-registration dcr is used
On authorize, token and refresh [RMCP]
Yes. A missing iss is rejected when advertised, a mismatch always RMCP L2141
--scopes, then config, then discovered. Discovered means the server's scopes_supported in v0.163.0, and on main the 401 scope then PRM. Adds offline_access if listed [CODEX-AUTH]
No step-up: the call fails, and the person runs codex mcp login --scopes again
Cursor
DCR, or a static CLIENT_ID in mcp.json. No CIMD (staff, 2026-09-22, forum). One DCR request carries three redirect URIs, one of them cursor://… (staff, forum; observed staff: true in Discourse JSON)
Only with a static client ID
On authorize (community report; staff acknowledged the bug it causes, forum); token request not stated
No source
Config, else the server's scopes_supported [CUR-DOCS]
No source
Gemini CLI v0.64.0
DCR, client_name "Gemini CLI MCP Client", on every sign-in, or a configured oauth.clientId. No CIMD [GEM-PROV]
Only with oauth.clientId
On authorize, token and refresh: the MCP URL [GEM-FLOW]
Yes, required when the server advertises support GEM-FLOW L265
A configured clientId; then a stored registration; then CIMD https://vscode.dev/oauth/client-metadata.json (since 1.106, 2025-11-12); then DCR; then a prompt [VSC-AUTH], [VSC-106]
Works through CIMD
On authorize, token, refresh and device requests: the PRM resourceVSC-AUTH L562
No
WWW-Authenticate scope, then PRM, then the server's list; adds offline_access if listed
Yes. A 401 or 403 with a new scope fetches a new token; a 401 or 403 while it holds a token throws away the registration and re-registers VSC-MCP L866
Exactly https://claude.ai/api/mcp/auth_callback [CLA-AUTH]; it is also the only entry in its CIMD (observed: curl)
Anthropic's cloud, 160.79.104.0/21, IPv4 only [CLA-IP]
HTTPS only. Hostnames that resolve to private or loopback addresses are refused [CLA-TROUBLE], so it can't reach a dev instance without a public tunnel
Claude Desktop
Hosted: as Claude.ai. Third-party: refreshes before expiry [D3P]
Hosted: Reconnect. Third-party: back to Connect [D3P]
Hosted: as Claude.ai. Third-party: http://127.0.0.1:53280/callback [D3P]
Hosted connectors come from Anthropic's cloud even though the app is local [CLA-HELP]; third-party from the device
Hosted: as Claude.ai. Third-party: the authorization endpoint must be https [D3P]
ChatGPT
Its CIMD declares refresh_token. Staff: ChatGPT "relies on the OAuth provider being configured to issue refresh tokens" (forum, 2026-09-29). Rotation not documented
The person re-authenticates. A community report says all tools are hidden when no refresh token is issued (unverified, forum)
https://chatgpt.com/connector_platform_oauth_redirect when the server advertises iss, which Patchy does; otherwise https://chatgpt.com/connector/oauth/{callback_id} [OAI-AUTH]
Public HTTPS. Secure MCP Tunnel carries MCP traffic but not the authorization server [OAI-TUNNEL]
Claude Code
Refreshes 300 s before expiry and once on a 401. Handles rotation, and keeps the old refresh token if none comes back; invalid_grant starts the sign-in over (bundle; [CC-MCP])
After expires_in: "MCP server "<name>" needs you to sign in again (run /mcp…)". claude -p and the Agent SDK can't run OAuth themselves [CC-ERR], [CC-MCP]
http://localhost:<port>/callback, with a random port in 49152–65535 per sign-in, fixable with --callback-port. The listener binds 127.0.0.1 [CC-MCP], bundle. Its CIMD lists port-less http://localhost/callback and http://127.0.0.1/callback (observed)
The person's machine
The token endpoint must be https or exactly localhost, 127.0.0.1 or ::1, so <name>.localhost is refused [CC-MCP], and the bundle compares the hostname exactly. Other endpoints aren't checked (bundle)
Codex
Refreshes 30 s before expiry and once on a 401. Handles rotation; invalid_grant is permanent [CODEX-OAUTH], RMCP L2349
At startup "requires OAuth reauthentication. Run codex mcp login"; mid-session "Reconnect to continue…" [CODEX-STARTUP]
http://127.0.0.1:<ephemeral>/callback when iss is advertised, otherwise /callback/<id>. Port configurable. Its CIMD is port-less (observed) [CODEX-LOGIN]
The person's machine
No https requirement. Metadata on *.localhost is accepted when the MCP URL is loopback RMCP L1244; a dev instance worked (observed on #727)
Cursor
Stored. Staff said silent refresh was unreliable from November 2025 to March 2026 (forum), and reported it working in October 2026 (forum). Rotation: no source
OAuth endpoints must be https unless the MCP URL is exactly localhost, 127.0.0.1 or ::1. *.localhost and private addresses are refused [GEM-UTILS], so it can't sign in to today's dev instances
VS Code
Refreshes 5 min before expiry; rotation accepted VSC-AUTH L580
Discards the token and shows "The MCP Server Definition '…' wants to authenticate to Patchy"
http://127.0.0.1:33418/, or a random port when 33418 is busy, or https://vscode.dev/redirect when remote or web [VSC-LOOP], VSC-AUTH L715
The machine
No http restriction
1. Which spec, and what it asks of Patchy
The current revision is 2026-07-28.
The versioning page says "The current protocol version is 2026-07-28" [VER]. The 2025-11-25 revision is the one before.
The draft has no authorization changes beyond one example: it now uses loopback IP literals in the CIMD example (PR #3384, merged 2026-09-22).
The authorization text was split into four pages ([A26], [D26], [R26], [S26]).
What 2026-07-28 changed for authorization, compared with 2025-11-25:
DCR is deprecated ([R26], [DEP]).
iss (RFC 9207): the server SHOULD send it, including on errors; a server that sends it MUST advertise authorization_response_iss_parameter_supported; clients MUST validate it. A later revision is "expected to upgrade" this to MUST ([A26]#authorization-response-validation).
Clients MUST key stored credentials by the server's issuer. CIMD ids are portable across servers ([R26]#authorization-server-binding).
DCR clients MUST send application_type, and native clients SHOULD send "native" ([R26]).
There is a new refresh-token section ([A26]#refresh-tokens):
clients "MUST NOT assume refresh tokens will be issued";
MCP servers SHOULD NOT put offline_access in the WWW-Authenticate scope or in PRM scopes_supported.
A scope challenge is "authoritative for the current operation". Servers SHOULD put every scope the operation needs into one challenge ([A26]#scope-challenge-handling).
What the spec asks of Patchy as the protected resource ([A26], [D26], [S26]):
MUST serve RFC 9728 protected resource metadata (PRM) listing at least one authorization server, discoverable through the 401's resource_metadata or a well-known URI. Patchy offers both.
SHOULD include scope in the 401 WWW-Authenticate. Patchy doesn't.
MUST validate that the token's audience is Patchy, and MUST NOT accept or pass on other tokens. A use token only opens /mcp, which meets this.
Answers an invalid or expired token with 401, and insufficient scope with 403 error="insufficient_scope" carrying scope and resource_metadata.
RFC 6750 §3.1 also wants error="invalid_token" when a token was presented, and no error code when none was (RFC 6750).
MUST answer an invalid Origin with 403 ([HTTP26]). The prototype does.
What the spec asks of Patchy as the authorization server:
RFC 8414 or OIDC discovery, with issuer identical to the URL it was fetched from ([D26]).
PKCE: code_challenge_methods_supported must be present, or clients "MUST refuse to proceed" ([S26]#authorization-code-protection). OAuth 2.1 draft -16 removes plain ([O21] §4.1.1).
resource (RFC 8707): clients MUST send it on authorization and token requests ([A26]#resource-parameter-implementation). The resource server MUST check audience, and RFC 8707 says the server SHOULD audience-restrict the tokens it issues (RFC 8707 §2).
Redirect URIs must be localhost or HTTPS and validated exactly ([S26]#communication-security, #open-redirection). OAuth 2.1 and RFC 8252 add that the server "MUST allow any port to be specified at the time of the request for loopback IP redirect URIs" (RFC 8252 §7.3, [O21] §8.4.2).
MCP's own text says "exact" with no port exception. That is a surface conflict between MCP and the RFCs it builds on.
"All authorization server endpoints MUST be served over HTTPS" ([S26]#communication-security). OAuth 2.1 makes an exception only for loopback redirect URIs ([O21] §1.5).
Access tokens: the server "SHOULD issue short-lived access tokens" ([S26]#token-theft, [O21] §7.1.3.5). Neither defines "short".
Refresh tokens for public clients:
MCP: the server "MUST rotate refresh tokens" ([S26]#token-theft).
OAuth 2.1 and RFC 9700 allow either rotation or sender-constraining ([O21] §4.3.1, RFC 9700 §4.14.2).
RFC 9700 adds that refresh tokens "MUST be bound to the scope and resource servers as consented" and "SHOULD expire if the client has been inactive for some time".
The protocol side (which revision Patchy's door serves) belongs to another ticket. For this one, note:
Codex defaults to 2025-06-18; 2026-07-28 is behind an "under development" flag (CODEX protocol_mode.rs).
Claude Code's v2 runtime negotiates 2026-07-28 and falls back to older revisions [CC-MCP].
2. Registration: CIMD and DCR
What the spec asks clients to do ([R26]):
Use this order: pre-registered client, then CIMD if the server advertises it, then DCR if the server has a registration_endpoint, then prompt the user.
Clients and servers SHOULD support CIMD; DCR is MAY and deprecated.
What a CIMD server must do ([R26]#implementation-requirements):
MUST check that the document's client_id equals the URL exactly.
MUST validate the request's redirect URIs against the document.
MUST validate the document's structure.
SHOULD cache it according to its HTTP headers.
What each client does. The CIMD documents below were fetched with curl on 2026-10-17.
Claude.ai and the hosted Claude clients use CIMD only when the server advertises both client_id_metadata_document_supported: true and "none"; "If either is missing, Claude falls back to DCR" [CLA-AUTH].
Anthropic says DCR "register[s] a new client on every fresh connection" [CLA-AUTH].
Its document lists the grant type urn:ietf:params:oauth:grant-type:jwt-bearer (observed), so Patchy must accept grant types it doesn't know.
Claude Code prefers CIMD whenever the flag is present. It doesn't check none. CIMD support shipped in 2.1.81 on 2026-03-20 ([CC-LOG]; bundle 2.1.302).
Exception: a sign-in Desktop starts with its own non-loopback redirect URI withholds the CIMD client_id and uses DCR. Seen in the bundle as the log line "withholding CIMD client_id — registering via DCR"; it relates to the 2.1.243 changelog fix. The exact redirect Desktop sends isn't documented.
ChatGPT "prioritizes CIMD when it is available, but the plugin builder can choose DCR when both … are available" [OAI-AUTH].
The singular field of its document says private_key_jwt, and the plural token_endpoint_auth_methods_supported says ["none","private_key_jwt"]. ChatGPT picks from the intersection with what the server allows, under SEP-3149, which is still an open PR ([OAI-AUTH], SEP-3149).
So Patchy must read the plural field. A server that reads only the singular one would refuse ChatGPT.
Codex uses CIMD only with the flag, none and a native /callback redirect. It shipped in v0.148.0 (CODEX-REG L53).
VS Code uses CIMD when the flag is present, since 1.106 ([VSC-106]; client id from the 1.142.0 product.json, observed).
Cursor and Gemini CLI have no CIMD. The sources are Cursor staff (forum, 2026-09-22), Gemini's source at v0.64.0, and #25724, where a maintainer said "we don't have immediate plans".
Can Patchy drop DCR? Not yet.
Cursor and Gemini CLI would need someone to configure a client ID by hand.
Desktop-started Claude Code sign-ins, and Claude Desktop on third-party platforms, would fail.
The spec allows dropping it: DCR is MAY. But the honest date is when Cursor and Gemini ship CIMD. Neither has a timeline.
What a connection is. CIMD changes this, and it matters to #736.
With CIMD, every install of a client shares one client_id: all Claude Code installs are https://claude.ai/oauth/claude-code-client-metadata.
The prototype's MachineTokens.mint revokes "the user's earlier live one for the same client". Under CIMD, connecting a second laptop would therefore disconnect the first, which breaks the decision that every device has its own token.
DCR clients happen to be unique per sign-in today (Codex, Gemini, Claude.ai) or per port (Claude Code). That isn't a guarantee.
So a connection has to be the grant, not the client.
3. The flow
PKCE: every client sends S256.
Codex tolerates a missing code_challenge_methods_supported.
Claude Code and ChatGPT stop if it is present without S256.
Patchy already advertises ["S256"].
resource and audience:
Every client except Cursor documents or ships sending resource on both authorize and token. Codex, Claude Code, Gemini CLI and VS Code also send it on refresh.
The values differ:
Claude.ai sends the canonical URL without a trailing slash [CLA-TROUBLE].
Claude Code sends new URL(prm.resource).href, so an origin-only resource gains a / (bundle).
Patchy's PRM resource is <base>/mcp, and check() trims one trailing slash before comparing, which covers all of them.
Risk: VS Code and Gemini's connect-time path validate a root PRM against the bare origin (VSC oauth.ts L1279, GEM mcp-client.ts L2096). Patchy's root PRM says <base>/mcp, so that fallback would fail.
In practice it never triggers, because Patchy's 401 always carries the path-specific resource_metadata.
Gemini CLI starts with HEAD /mcp, and the prototype routes only GET and POST. Answering HEAD with the same 401 keeps Gemini on the header path (inference from GEM-PROV L320).
iss: Claude Code v2, ChatGPT, Codex and Gemini CLI validate it. Because Patchy advertises support:
a missing iss fails in all four;
ChatGPT and Codex switch to their stable redirect URIs and client ids.
The prototype's back() adds iss to every redirect, errors included, and it matches issuer because both come from publicBaseUrl. Keep that.
Scopes. Patchy has one scope, patches, listed only in its server metadata.
Claude.ai and Claude Code never read the server metadata's scopes_supported (Claude Code only when configured). They send no scope unless the 401 or the PRM names one. Patchy accepts that, but it is accidental.
Put scope="patches" in the 401 and scopes_supported: ["patches"] in the PRM (MCP SHOULD; RFC 9728 RECOMMENDED).
If Patchy issues refresh tokens, don't list offline_access in the PRM or the 401 ([A26]#refresh-tokens). Listing it in the server metadata makes Claude Code and Cursor add prompt=consent ([CC-MCP]; Cursor staff). That is harmless, since Patchy always asks for consent, but it isn't needed: issue a refresh token on every code exchange and ignore offline_access.
Step-up and 403. Step-up support varies: Claude.ai and VS Code re-authorize, Claude Code now prompts, Codex and Gemini CLI fail the call, and ChatGPT's HTTP behaviour is undocumented.
With one scope, Patchy never needs step-up.
More important is that Patchy must never use HTTP 403 for a policy refusal, such as agent access being off:
VS Code treats a 401 or 403 sent while it holds a token as a reason to throw away its registration and re-register (VSC-MCP L877).
Claude.ai treats any 403 other than insufficient_scope as terminal [CLA-LAZY].
The prototype already answers "agent access is off" as a tool result over HTTP 200 (apps/server/src/Mcp.ts, observed). Keep that.
4. Lifetimes
What the spec says: short-lived access tokens (SHOULD), rotation for public clients' refresh tokens (MUST in MCP), and clients "MUST NOT assume" a refresh token ([S26], [A26]#refresh-tokens). No numbers.
What clients expect: none documents an access-token lifetime.
Proactive refresh windows: Claude.ai 5 min [CLA-AUTH], Claude Code 300 s (bundle), Codex 30 s CODEX-OAUTH L102, Gemini CLI and VS Code 5 min.
Any lifetime well above 5 minutes avoids refresh storms. Claude.ai allows 30 s for a refresh request [CLA-AUTH].
Claude Code, Codex and Gemini CLI treat a token with no expires_in as valid until a 401. Claude Code 2.1.118 fixed hourly re-authentication in that case [CC-LOG].
Rotation: every client stores a rotated refresh token and keeps the old one when the response has none.
Claude Code and Cursor have shipped fixes for refresh races between several processes or windows ([CC-LOG] 2.1.59, 2.1.118, 2.1.136, 2.1.221; Cursor staff).
No refresh token (the prototype today): each client needs the person when the 90-day or 30-idle-day token lapses, as the table shows.
ChatGPT is the outlier. OpenAI support says it relies on refresh tokens, and one community report says its tools disappear without one. That is unverified; test it before shipping without refresh.
Recommendation (inference):
Issue a rotating refresh token on every code exchange.
Access tokens of about 1 hour, opaque and checked against the database as today, so revoking on Your machines, deactivation and turning agent access off still act on the next call.
Let the refresh-token family be "the connection", with ADR-0008's limits: 30 idle days, 90 days from consent.
http://localhost:<any>/callback and http://127.0.0.1:<any>/callback (Claude Code, Codex)
http://127.0.0.1:33418/, any port, and https://vscode.dev/redirect (VS Code; Insiders' document lists https://insiders.vscode.dev/redirect, observed)
http://localhost:8787/callback and https://www.cursor.com/agents/mcp/oauth/callback (Cursor), and cursor://anysphere.cursor-mcp/oauth/callback in Cursor's registration
http://127.0.0.1:53280/callback (Claude Desktop on third-party platforms)
What this means for the prototype:
Ports must match loosely. Claude Code and Codex publish port-less loopback URIs and bind a new port each sign-in, and VS Code falls back to a random port. So the CIMD path needs the RFC 8252 any-port match, with host and path exact.
Anthropic asks for the same match on localhost, not only the IP literals [CLA-AUTH].
Today client.redirectUris.includes(redirectUri) in OAuthPages.ts is exact.
Cursor's registration fails today.
OAuth.register refuses the whole request when any URI is neither https nor loopback http, and Cursor sends cursor://… alongside the other two. "Cursor doesn't currently retry DCR with a reduced set of URIs" (staff, forum).
RFC 7591 lets the server "reject or replace any of the client's requested metadata values … and substitute them with suitable values" (§3.2.1).
The fix: keep the allowed URIs and drop the rest. Cursor staff call that "the right one" for a cursor.com callback (forum).
The alternative is to allow private-use schemes as RFC 8252 §7.1 permits for native apps. Cursor's Cloud flow still sends cursor:// at /authorize (staff).
The consent form's CSP. The prototype adds the exact redirect origin to form-action on each request. For an IPv6 literal it adds only the scheme, since host sources can't spell one (OAuthPages.consent).
CSP's form-action check runs for "form-submission" navigations (CSP3 §6.4.1.1). That section doesn't say whether a 303 after the POST is checked again. Listing the target, as the prototype does, is the safe reading.
A custom scheme needs a scheme source such as cursor: (CSP3 source-list grammar).
vscode.dev's own page then hands off to vscode://; that second hop isn't Patchy's page.
VS Code's state is a long vscode://dynamicauthprovider/… URI that must come back verbatim (VSC-AUTH L715). The prototype carries state through untouched.
What the consent page must show:
MCP "MUST clearly display the redirect URI hostname", SHOULD warn when the only redirect URIs are loopback, and MAY apply domain trust policies ([S26]#localhost-redirect-uri-risks, #trust-policies).
CIMD -02 says to display the client_id hostname ([CIMD] §8.5).
Anthropic asks servers to name the host of a CIMD client_id rather than trusting client_name [CLA-AUTH].
OAuth 2.1 -16 §7.9 asks for extra care with DCR and CIMD clients ([O21] §7.9).
The prototype shows "Your answer goes back to ". For CIMD clients it should add the client_id host, plus a loopback warning.
One point of tension: any local process can claim Claude Code's id ([BP]#localhost-redirect-uri-impersonation). The client name a person sees is a label, not proof, which is already the map's rule.
6. Open endpoints: discovery, registration, token
Fetching a client's metadata document safely. These rules come from CIMD -02 (2026-07-06); MCP cites -00.
MUST NOT fetch a document, or any URL inside one, "that resolve[s] to special-use IP addresses as defined in [RFC6890]". A development server MAY fetch loopback "when the authorization server itself is also running on a loopback address", and "MUST NOT apply this exception in production" ([CIMD] §8.6).
On AWS that set includes the link-local instance and task metadata addresses.
MUST NOT follow redirects; only a 200 counts ([CIMD] §5).
Recommends reading at most about 5 KB ([CIMD] §8.7).
MUST NOT cache errors or invalid documents; otherwise caching follows the HTTP headers within the server's own bounds ([CIMD] §5.2). Claude's and OpenAI's documents send max-age=300, and VS Code's no-store (observed).
No timeout is specified. Claude gives Patchy's endpoints 10 s, so a slow fetch at authorize time surfaces as a failed connection [CLA-AUTH].
MCP's best practices add: pin DNS between the check and the fetch, use an egress proxy, and don't hand-roll IP validation ([BP]#server-side-request-forgery-ssrf).
Risk to verify from Patchy's real egress: two open community reports say claude.ai's Cloudflare edge answers server-side fetches of both Anthropic documents with a 403 challenge from some datacenter IPs (claude-code#84263, claude-ai-mcp#650). I got 200s from a residential address (observed). I didn't test from AWS.
A trust policy keeps the fetch small (inference). The clients we check use five documents on three hosts: claude.ai, chatgpt.com and vscode.dev.
Always fetch, cache and validate, but treat other hosts as unknown and warn on the consent page.
CIMD §8.9 and [BP]#cimd-trust-policies describe allowlists and warnings for the first users of a new client.
Registration spam and retention:
RFC 7591 says registration "MAY be rate-limited", that all client metadata is self-asserted, that the server SHOULD warn about recently registered clients, and that it "MAY decide to expire registrations" (RFC 7591 §3, §5).
MCP is silent on spam and retention.
CIMD lists DCR's "cleanup of inactive clients" as a reason it exists ([CIMD] §1).
Volume: Codex, Gemini CLI and Claude.ai register a new client on every sign-in or fresh connection (CODEX-REG L35, GEM-PROV L430, [CLA-AUTH]). Unused rows are the normal case, not an attack.
The prototype has none of this: no limit on /oauth/register, and oauth_clients rows are never deleted.
Limits cover /api/* (ApiGuard.ts) and device login (DeviceLogins.ts) only, observed by reading the code at a0257fd.
Inference: limit per address, and delete clients that hold no code or token after a short window.
Guessing at the token endpoint:
Tokens and codes must be unguessable at "less than or equal to 2^(-128)", ideally 2^(-160) ([O21] §7.7).
Codes: at most 10 minutes RECOMMENDED; single use. A second valid use "SHOULD revoke (when possible) all access tokens and refresh tokens previously issued based on that authorization code" ([O21] §4.1.2, §4.1.3).
No spec asks for token-endpoint rate limits; entropy is the control.
The prototype uses 256-bit codes and tokens stored as SHA-256, a 10-minute code life, and single use under a row lock. It doesn't revoke on replay and has no limit on /oauth/token.
Open redirect before sign-in. This is a real bug in the prototype.
OAuthPages.check() answers bad requests (unsupported_response_type, a missing or bad PKCE challenge, invalid_target) with a 303 to the client's registered redirect URI. It runs before RequireSession.withViewer.
With open DCR, anyone can register https://attacker.example/… and craft a broken authorize link, and Patchy bounces a signed-out visitor straight there.
OAuth 2.1 and RFC 9700: "The authorization server MUST always authenticate the user first … before redirecting the user" ([O21] §7.13.2, RFC 9700 §4.11.2). MCP adopts that section ([S26]#open-redirection).
The fix: require the session before any redirect, or render the error on the page.
Discovery endpoints answer anyone, and the specs expect that.
CORS MAY be offered on the token, metadata and registration endpoints, and "MUST NOT be supported at the authorization endpoint" (RFC 9700 §2.6).
The prototype sends * on the client endpoints and none on /oauth/authorize, which matches.
7. Plain http in development
The specs:
Normative MCP and OAuth 2.1 have no development exception for authorization server endpoints ([S26], [O21] §1.5).
MCP's best-practices page allows http "only for loopback addresses (such as localhost, 127.0.0.1, or ::1) during local development" ([BP]#oauth-authorization-url-validation).
Gemini CLI refuses *.localhost (and *.local, *.internal and private addresses) for every OAuth endpoint, and allows http only when the MCP URL host is exactly localhost, 127.0.0.1 or ::1 (GEM-UTILS L97, GEM fetch.ts L259). It can't sign in to today's dev instances.
Claude.ai and ChatGPT run in the cloud. They can't reach a dev instance without a public https tunnel, and Claude.ai refuses hostnames that resolve to private addresses [CLA-TROUBLE].
A cleaner equivalent (inference, if Gemini CLI matters in dev):
Advertise the instance's whole client-facing surface on http://127.0.0.1:<port>: the MCP URL, PRM, issuer, metadata, registration and token endpoints. Each worktree already has its own port (scripts/dev/src/plan.ts).
Have /oauth/authorize there bounce the browser to <label>.localhost:<port>, where the session cookie lives. Worktrees use named hosts because cookies ignore ports.
For the clients we check, the current token-endpoint rewrite is enough.
8. Clerk as the authorization server
Patchy's production Clerk instance was not changed or relied on for these findings; Clerk's capabilities below come from its docs, specs and SDK.
The ticket's requirements
Requirement
Clerk today
What it would take
What we'd lose compared with the prototype
Our consent wording, including the agent-access-off state
The Account Portal consent page can be styled but not re-worded. A custom consent page is possible: <OAuthConsent /> with an experimentallocalization prop, or a custom flow that posts consented to the Frontend API /v1/me/oauth/consent/{client_id} (custom consent page, localization). Clerk "strongly recommends" the Account Portal page. DCR and CIMD clients always see consent
A Patchy-hosted consent page running Clerk's JS, which must forward every original parameter including resource. The access-off state would be our page with only Deny
Server-rendered consent built from Patchy's own state. It would also break in dev personas mode, which has no Clerk
Company-scoped grants
OAuth access tokens can't carry custom claims; the only tenant claim is org_id, which needs Clerk Organizations (how Clerk implements OAuth). ADR-0007 rejected Organizations
Look up the company from sub (users.clerk_user_id) on every call: the same single join the door already does
Little, since a person has exactly one company. A Clerk grant does follow the Clerk user if they later belong to another Patchy company, unless Patchy refuses it
Per-client tokens listed and revoked on Your machines
No Backend or Frontend API lists a user's grants or tokens. Backend POST /oauth_applications/{id}/revoke_token needs the token's value, and "JWT access tokens cannot be revoked" (Backend API spec 2026-08-20, read in clerk/openapi-specs)
Patchy keeps its own connections table (recorded at consent, or on first sight at the door) and refuses disconnected ones at the door. Revoking at Clerk would mean storing a bearer value
A real disconnect. Clerk's refresh token "never expire[s]" (guide; the Frontend API spec says 10 years, so the docs conflict) and keeps minting JWTs that Patchy can only refuse. ADR-0008's single-transaction revocation on deactivation becomes revocation in two systems
The agent-access switch checked on every call
No pre-issuance hook; webhooks are asynchronous. There are no Organizations to disable
Unchanged: Patchy's door check
Nothing at the door, but Clerk keeps issuing while access is off
No network round trip per call at our door
JWT access tokens (the default for apps created since 2026-01-08, changelog) verify locally with jwtKey. Claims: sub, client_id, scope, jti, exp, and aud only when aud_claim_enabled is on. Opaque tokens need Backend POST /oauth_applications/access_tokens/verify on every call, under a 1,000 requests / 10 s production limit shared with every other Backend call (rate limits)
JWTs plus audience = <instance>/mcp, plus Patchy's own per-call checks
Immediate revocation of the access token: a JWT lives 1 day, which isn't documented as configurable. One RS256 key signs both session tokens and OAuth JWTs, so any direct verifyToken call must check typ
Fit with the spec
What Clerk has:
CIMD, generally available 2026-09-21. Off until Publish CIMD support is set. Three admission modes. Redirects "must exactly match" (CIMD guide, changelog).
DCR, off by default; native clients may use custom schemes or loopback http.
PKCE S256, resource with invalid_target, iss, custom scopes (2026-08-21) and default scopes (2026-07-22).
Refresh tokens and the device grant.
Sources: the Frontend API spec in clerk/openapi-specs and the changelog entries cited above.
Unknown or undocumented:
Loopback on any port. The CIMD guide says exact match, while Claude Code's and Codex's documents are port-less, so the RFC 8252 behaviour is unclear. Clerk documents Claude Code and Codex against mcp.clerk.com (Clerk MCP server), which suggests it works. Not tested.
Refresh rotation: not documented.
Configurable lifetimes: not documented.
Whether consent is remembered.
Whether deleting an app revokes its tokens.
A 2025 report of a DCR rule that client_uri must share an origin with a redirect (inspector#710, third party).
Clients Clerk documents for your own MCP server: Cursor, VS Code, Claude Code, Claude Desktop and Windsurf (connect an MCP client). ChatGPT and Gemini CLI aren't listed.
Pro is $25/month ($20 billed annually), with 50,000 monthly retained users included and $0.02 for each one beyond.
OAuth applications, Clerk acting as the OAuth server, DCR, CIMD and OAuth token verification are not listed. No OAuth doc I read calls them paid, so they are probably included, but that isn't stated.
What is priced:
Machine-to-machine (M2M) tokens and API keys: free creations and verifications each month, then $0.001 per creation and $0.00001 per opaque verification (M2M, API keys).
Organizations through the B2B add-on: $100/month ($85 billed annually). They would be needed only for org_id.
Whether an OAuth refresh counts as a retained user's visit isn't documented.
Neither Clerk product replaces ADR-0008:
API keys are opaque, need a network call to verify, and are billed past 100k verifications a month.
M2M tokens belong to machines with no human owner, which contradicts "every bearer is somebody".
What we would gain and lose
Gain:
Clerk would maintain the protocol surface: CIMD, the device grant, future spec changes, and clients already proven against mcp.clerk.com.
Fewer lines of auth code: OAuth.ts, roughly 255.
Lose:
Disconnecting a connection. Under ADR-0008 a revoke or deactivation is final in one transaction; under Clerk it isn't.
Telling devices apart. Clerk's tokens identify the client, not the grant, so under CIMD two Claude Code installs look the same.
Server-rendered consent. Patchy's wording would move into a client-side flow Clerk discourages.
Configuration in code. It would become dashboard state instead.
The Clerk-free dev and test loop. Personas mode and offline pnpm test would need a stand-in authorization server or fake JWTs, and a Clerk development instance has one consent path shared by every worktree (environments).
Unchanged either way: Patchy keeps the PRM, the consent page, the connection table and the door check.
Recommendation: keep Patchy's own authorization server
Reasons:
The ticket's requirements live on Patchy's side either way: consent copy, the company, the access switch, listing and revoking, and dev. What Clerk takes over is the part that is cheap to own.
The two features Clerk has that Patchy lacks, CIMD and refresh rotation, are each a bounded addition to OAuth.ts.
The prototype is already the sensible hybrid. Clerk authenticates the person, through the browser session on the consent page, and Patchy authorizes the agent.
Because Patchy uses the session rather than a static Clerk OAuth client, it isn't the "proxy with a static client ID" that MCP's confused-deputy rules target ([S26]#confused-deputy-problem).
When Clerk would win: if Patchy adopts Clerk Organizations for company SSO (ADR-0007 expects that one day), and Clerk ships a grant list and revoke API plus configurable refresh lifetimes.
How to settle the unknowns: test Clerk's loopback matching and its refresh rotation on a development instance. That needs Allison's OK, because it means changing a Clerk setting.
9. What Patchy's authorization server should change
From the spec and client findings above. The signing-in ticket decides; this is the evidence.
Match loopback redirects on any port, with host and path exact. Apply it to 127.0.0.1, [::1] and, as Anthropic asks, localhost (RFC 8252 §7.3 MUST; [CLA-AUTH]).
Sign the person in before any redirect from /oauth/authorize ([O21] §7.13.2 MUST). Fixes the open redirect.
rotation, with refresh_token in grant_types_supported and invalid_grant for a dead token;
bound to <base>/mcp, with idle and absolute expiry;
no offline_access in the PRM or the 401.
Scopes and errors:
scope="patches" in the 401 and scopes_supported in the PRM;
error="invalid_token" when a bad token was presented;
policy refusals stay tool results, never HTTP 403.
Revoke what a code minted when the code is replayed ([O21] §4.1.3 SHOULD).
Small items:
Make redirect_uri optional at /oauth/token ([O21] §10.2 says clients following only OAuth 2.1 won't send it).
Answer HEAD /mcp with the same 401 (Gemini CLI).
Consider whether the root PRM's resource should be <base>/mcp, since VS Code and Gemini validate a root PRM against the origin.
10. Conflicts and silences
MCP vs the RFCs:
MCP says redirect URIs match "exactly"; RFC 8252 and OAuth 2.1 require any port on loopback.
MCP says refresh tokens "MUST rotate"; OAuth 2.1 and RFC 9700 allow rotation or sender-constraining.
iss is SHOULD in MCP and REQUIRED in OAuth 2.1 -16. MCP still links -13.
MCP cites CIMD -00; -02 tightens SSRF from SHOULD to MUST NOT and forbids redirects.
The spec is silent on:
registration rate limits and expiry;
what "short-lived" means;
an http exception in development (the best-practices page is looser than the normative spec);
the root PRM's resource when the MCP endpoint has a path.
Claude:
The hosted docs require the CIMD flag andnone; Claude Code's code checks only the flag.
Claude Code's changelog says CIMD is used "for servers without DCR"; its code prefers CIMD whenever advertised.
The hosted client's iss validation and its expected token lifetime aren't documented.
The hosted CIMD URL isn't named in Anthropic's docs; it comes from a community issue plus my curl.
ChatGPT:
Not documented: the DCR request body, whether resource is sent on refresh, rotation, HTTP 403 handling, and its initialize version.
The docs say a 401 restarts OAuth; a community report says a mid-session 401 surfaced as -32603 until the person clicked Reconnect (staff didn't confirm).
Codex: the docs say server-advertised scopes beat configured ones; the code does the reverse.
Cursor: staff contradict each other on the desktop /authorize redirect: "always" localhost:8787 on 2026-09-22; a cursor.com URL "on recent versions", called a bug, on 2026-10-15.
Gemini CLI: the docs promise automatic OAuth on a 401; the code needs oauth.enabled: true or /mcp auth. #25724 is closed "completed" with no CIMD code.
VS Code: the user docs describe only DCR; the source and 1.106 release notes add CIMD and step-up.
Clerk:
Refresh tokens "never expire" (guide) vs a "10 year lifetime" (Frontend API spec).
Access-token lifetime: 1 day, though one example shows expires_in: 7200.
Undocumented: loopback any-port, rotation, and pricing for OAuth tokens.
curl of the five CIMD documents (claude.ai/oauth/mcp-oauth-client-metadata, claude.ai/oauth/claude-code-client-metadata, chatgpt.com/oauth/client.json, chatgpt.com/oauth/codex/client.json, vscode.dev/oauth/client-metadata.json), all HTTP 200;
curl of openai.com/chatgpt-connectors.json;
GET of clerk.clerk.com metadata;
VS Code 1.142.0 product.json from the stable tarball;
the prototype's code at a0257fd: packages/auth/src/{OAuth,OAuthPages,AgentAuth,MachineTokens}.ts, apps/server/src/{Mcp,ApiGuard}.ts, scripts/dev/src/plan.ts.
Registration: implement Client ID Metadata Documents (CIMD) first, with DCR as a compatibility fallback. The latest published MCP revision is 2026-07-28; it deprecates DCR, but current first-party evidence does not establish CIMD support in Cursor or Gemini CLI. Dropping DCR would therefore give up automatic onboarding for part of this ticket’s client set. Latest MCP, registration, Cursor, Gemini.
Refresh and lifetimes: issue refresh tokens and rotate them. No reviewed client contract specifies one required access-token lifetime. One-hour access tokens, with a separately revocable connection and bounded refresh lifetime, is a proposed starting policy, not a protocol requirement. Keep ADR-0008’s 90-day absolute / 30-day idle limits at the connection level if preserving that policy is desired. The prototype’s 90-day bearer without refresh is interoperable with the tested logins, but a poor production default. MCP security, ADR-0008, prototype tests reported in #727.
Open endpoints: public discovery and public-client token exchange are intentional; public registration need not grant access. Use bounded requests, rate limits, unguessable credentials, expiry, PKCE and atomic exchanges. CIMD removes registration writes but adds a public-URL fetcher requiring SSRF protection. RFC 7591 §§3,5, RFC 6749 §§4.1,10.10, CIMD draft §§6.5–6.6.
Clerk or our own:recommend Patchy’s own authorization server, using Clerk for browser identity, for this build. Clerk can serve MCP OAuth, including CIMD, custom consent, organization selection and local JWT verification; its published API schema also describes resource binding. The obstacle is preserving Patchy’s immediate, independently revocable, per-connection Your machines model without a Clerk request per call: that still needs significant Patchy grant state, and the documented APIs do not establish a complete grant-list/revoke-by-ID path. Do not merge the prototype unchanged. Clerk MCP, resource-binding schema, custom consent, token formats, revocation API.
Per-client findings. “Not documented” means the cited first-party material does not settle the behavior; it does not mean unsupported. Source inspection and live public-document fetches are labeled observed below. I did not run fresh client OAuth sessions.
Client
Registration and flow
Expiry and refresh
Redirects and development
Claude.ai
CIMD when AS metadata advertises both client_id_metadata_document_supported: true and token auth none; otherwise DCR, with static-client alternatives. S256 PKCE; scope selection and offline_access are documented. Hosted documentation lists authorization specs through 2025-11-25, not a blanket 2026-07-28 guarantee. Auth, versions.
Proactive refresh up to five minutes before expiry and reactive refresh on 401. Invalid refresh uses invalid_grant; rotating responses must include the replacement. No minimum/maximum access TTL or precise no-refresh-token UX is promised. Token requirements.
https://claude.ai/api/mcp/auth_callback. Hosted service needs network-reachable MCP and discovery endpoints; a callback to the person’s loopback is not its normal hosted flow. Callbacks/discovery.
Claude Desktop
Remote connectors use the shared hosted Claude authentication infrastructure, including CIMD/DCR. Distinguish this from running a local stdio extension, which is not remote OAuth. Shared infrastructure, remote/local distinction.
Same documented remote refresh contract as Claude.ai. Desktop’s changelog also records saved-sign-in and reauthentication fixes; it does not define a separate numerical token TTL. Refresh, Desktop changelog.
Remote connector: the same https://claude.ai/api/mcp/auth_callback, not a desktop loopback callback. A Code session running inside Desktop can instead follow Claude Code’s local flow. Surface distinctions.
ChatGPT
CIMD, DCR or supplied client credentials; CIMD supports none and private_key_jwt. S256, resource on authorization/token requests, and issuer checking are documented. OAuth contract, custom-server setup.
Public metadata requests both code and refresh grants (observed GET). Docs allow token expiry/rotation and prescribe challenges for reauthorization, but do not specify a universal refresh schedule, TTL bound, or exact missing-refresh UX. Metadata, auth.
With issuer-bound responses: https://chatgpt.com/connector_platform_oauth_redirect; otherwise https://chatgpt.com/connector/oauth/{callback_id}; some older connections retain the stable callback. Use the URI displayed for that connection. Aug 21 change, callback rules.
Claude Code
CIMD, DCR or preconfigured credentials. Current docs distinguish SDK v1 and v2; v2 can negotiate 2026-07-28, with rollout/version/feature-flag qualifications. Pinned scopes and 403 step-up behavior are documented. Client docs.
Automatic refresh; 401 triggers refresh, reconnect and one retry. Rejected refresh produces a reauthentication notice. No-refresh-token exact UX and TTL bounds are not specified. Recovery.
Usually http://localhost:<ephemeral>/callback; metadata also declares 127.0.0.1. Fixed-port option exists. v2 documents HTTP token endpoints only on localhost, 127.0.0.1, or ::1. Code docs, metadata.
Codex
Current docs support CIMD, DCR and supplied credentials; automatic CIMD requires advertised support, none, and a supported loopback callback. Supplied ID wins. iss is validated; callbacks without advertised issuer support get a server-specific suffix. MCP docs.
Observed source: expiry is tracked from expires_in, refresh begins with a 30-second skew, and rejected refresh is tested to retire credentials and require reauthentication. No product-wide TTL bound is documented. Expiry code, recovery test, inspected not executed.
http://127.0.0.1:<ephemeral>/callback, or /callback/{callback_id} without issuer binding; configurable callback/port. Portless registration and variable-port matching are explicitly documented. Remote plain-HTTP AS exceptions are not promised in these docs. Callback contract.
Cursor
DCR and supplied OAuth credentials documented; I found no affirmative CIMD contract in the reviewed docs/release notes. Requested scopes can be configured. PKCE/resource/iss/step-up details are not specified sufficiently to certify each behavior. MCP docs, IDE releases.
Cursor staff confirmed background refresh, alongside a transport bug in May; newer release notes describe reconnect prompts for revoked/expired logins. Do not turn the historical bug into a claim that current Cursor never refreshes. No TTL bound or precise no-refresh behavior is documented. Staff statement, newer releases.
Current docs: desktop http://localhost:8787/callback; web/Agents https://www.cursor.com/agents/mcp/oauth/callback. Historical DCR also included cursor://anysphere.cursor-mcp/oauth/callback; current releases add hosted fallback. Local MCP HTTP examples do not establish arbitrary HTTP token-endpoint acceptance. Docs, staff/history, releases.
Gemini CLI
Docs describe discovery, DCR and configured client IDs. Observed current source: missing client ID follows DCR; no CIMD branch in that flow. Source sends S256 and resource indicators. Docs describe conditional iss validation, but Oct 13 preview notes contain a related fix: do not assume stable 0.64 has every preview correction. Docs, source, preview.
Refreshes expired tokens if a refresh token exists; otherwise /mcp auth is the documented recovery. Observed source: failed refresh removes credentials and returns no valid token. No TTL bound or automatic scope-step-up promise found. Docs, source.
1.106 release notes explicitly prefer CIMD over DCR and add WWW-Authenticate scope step-up. The developer guide still says DCR-first: that text is inconsistent with newer release notes and observed current source. Source uses S256/resource; iss validation was not established by the inspected generic flow. Release notes, older guide, selection source.
Observed source: sessions refresh within five minutes of expiry; without a refresh token they are discarded from matching sessions, so another authorization is needed. This is implementation evidence, not a guaranteed UX or minimum TTL. Token handling.
Guide: http://127.0.0.1:33418 and https://vscode.dev/redirect; observed live CIMD has http://127.0.0.1:33418/ with a slash. Prefer actual metadata/exact selected callback over prose. A complete HTTP AS exception policy is not documented. Guide, live metadata.
Evidence and scope. I read #733, #730, the first resolution comment on #731 and the specified local files at commit a0257fd9914444b04025ed7293cd332c4dda024a. The fixed model remains one person/company grant, separate build and work purposes, company agent access checked on every call, and consent-approved client names as labels rather than authority. Ticket, map, fixed decisions.
“Observed” here means reading source files/OpenAPI schemas or fetching public JSON with HTTP GET, not testing an installed client. The prototype’s successful Claude Code/Codex OAuth and HTTP restriction are previous observations reported by #727, not experiments repeated in this lane. No repo files, GitHub records or Clerk configuration were changed. Reported experiments.
1. What the two MCP revisions require.
On this date /specification/latest/basic/authorization resolved to 2026-07-28. The 2025-11-25 revision already recommends CIMD, makes DCR optional, separates protected resource from AS, requires resource indicators and includes scope escalation. The newer revision explicitly deprecates DCR and adds more detailed registration binding, issuer-response validation and refresh guidance. OAuth 2.1 and CIMD remain referenced Internet-Drafts; “OAuth 2.1” is not the name of a finalized RFC. 2025-11-25, 2026 changes, OAuth draft.
Patchy’s protected-resource duties are public RFC 9728 metadata naming its canonical resource and AS, a discoverable 401 challenge, and validating authorization on every request. Implement both well-known locations and the challenge pointer for compatibility; that exceeds the minimum of providing one discovery mechanism. Bind resource metadata to the actual /mcp URL. Metadata is public, not company data. MCP discovery, RFC 9728 §§2–5.
Patchy’s AS duties include OAuth authorization-code handling, metadata via RFC 8414 or OIDC Discovery, validated redirect registration, S256 PKCE, code/client/redirect binding, and appropriate public/confidential-client security. Clients must refuse authorization if PKCE support is not advertised. Keep codes single-use and short-lived; the familiar ten-minute upper recommendation comes from OAuth, not a client’s required access-token TTL. MCP security, RFC 7636 §4, OAuth draft §4.1, RFC 8414.
CIMD is a URL-based client identity, not DCR under another name. Validate HTTPS/path/no fragment/no userinfo, required JSON fields, exact document client_id, and allowed redirects. Cache successful metadata with HTTP caching rules. Public metadata alone does not prove that the process presenting its URL is the named client, particularly with loopback callbacks; user-approved naming must remain a label. The draft also allows asymmetric client authentication, unlike a shared secret published in a document. CIMD draft §§3–6, MCP registration.
Can DCR go? For newly implemented protocol support, CIMD is the preferred path. For this client matrix, retain DCR until supported Cursor/Gemini versions have documented or observed CIMD onboarding, or accept a manual pre-registration step for them. No protocol obligation forces DCR forever. Do not make an initial registration access token, CAPTCHA or administrator-created client a requirement for the automatic public-DCR path. Those are valid closed-registration policies but would change the onboarding product. MCP registration, RFC 7591 appendix A.1, client evidence above.
2. Resource, issuer, scope and step-up.
resource and scope solve different problems: which API a token can reach versus what it can do there. Clients send the canonical MCP resource on authorization and token requests even if an AS ignores it. Patchy must actually enforce intended-recipient binding: for opaque tokens, store/verify the resource with the grant; for JWTs, verify the intended audience. A Clerk login JWT, ID token or builder token must not become an MCP credential just because its signature is valid. An ID token’s client audience is not evidence of an MCP access-token audience. RFC 8707 §§2–3, MCP audience rules, OIDC ID-token contract.
Emit iss on successful and error authorization responses, advertise authorization_response_iss_parameter_supported: true, and keep the issuer string identical across metadata and callbacks. Clients record the validated expected issuer before redirecting. Advertised support plus missing iss, or a mismatched present iss, fails before code exchange. Exact comparison means trailing slash/port/case “cleanup” is unsafe. The latest MCP recommendation to emit iss is currently SHOULD, not yet an unconditional MUST. RFC 9207 §§2–2.4, latest response validation.
Use one coarse MCP permission consistent with the fixed all-company-agent-areas grant; do not invent per-patch or read-only OAuth consent here. Advertise the required permission in WWW-Authenticate and resource metadata; validate requested/granted scope rather than returning a constant unrelated to the request. offline_access, if used for refresh issuance, belongs to the AS’s refresh policy, not a required MCP-resource permission. Fixed grant, RFC 6749 §3.3, MCP refresh guidance.
Missing/expired/invalid credentials produce 401; a valid token lacking a required scope produces 403 with error="insufficient_scope", required scope, and preferably resource_metadata. Clients should reauthorize with the union of previously requested and newly challenged scopes and limit retries. Put every scope needed for the operation in one challenge. A company’s agent-access-off decision is an ordinary authorization refusal, not a scope upgrade: repeatedly asking consent cannot repair it. RFC 6750 §3.1, latest step-up, company-switch contract.
Client-specific scope behavior matters: Claude documents transport 403 scope escalation; Claude Code’s pinned oauth.scopes can require editing before reauthentication; VS Code’s 1.106 notes explicitly add step-up. ChatGPT additionally documents tool-level securitySchemes and _meta["mcp/www_authenticate"] for its lazy linking UI. That extension is not a substitute for standards-compliant HTTP authorization at Patchy’s protected endpoint. Cursor/Gemini’s exact step-up behavior remains unproven by the reviewed docs. Claude, Claude Code, VS Code, ChatGPT.
3. Lifetime policy and expiry behavior.
Refresh tokens are discretionary: clients cannot assume issuance. The new MCP guidance tells clients to advertise the refresh grant and optionally request AS-advertised offline_access. For public clients, MCP’s security text explicitly requires rotation; RFC 9700 describes rotation or sender-constraining as replay protection, plus expiry after inactivity. Implement rotation for these public clients rather than relying on client names as authentication. Replayed refresh tokens must not silently revive revoked grants. MCP refresh, MCP rotation, RFC 9700 §4.14.
Recommended Patchy model: a durable agent connection owns person, company, client, granted scope/resource, revocation, creation and last use; short-lived access tokens and rotating refresh credentials refer to it. Every MCP request still checks the live connection, person and company switch locally. A refresh cannot extend the connection beyond its absolute/idle expiry or undo revocation. This preserves the fixed product model while making credential renewal transparent. One-hour access TTL and 90-day absolute / 30-day idle connection TTL are proposed values; only the latter pair already exists in ADR-0008. Fixed model, ADR, security rationale.
With refresh, persist and return the replacement atomically, preserve resource/scope/client binding, and return invalid_grant for an invalid/revoked refresh grant. Without refresh, an expired token is unusable and a new authorization is necessary; whether a particular client opens a browser immediately, offers a reconnect button, or fails the current tool call is a separate UX question. The table marks where that UX is documented or source-observed. No evidence justifies inventing one common behavior or a required “five-minute” access-token lifetime. RFC 6749 §§5–6, Claude’s distinct five-minute early-refresh window.
4. Redirect matching, consent and CSP.
Registration-time redirect validation and exchange-time binding are separate checks. RFC 8252 requires varying-port acceptance for IP-literal loopback redirects; match the remaining registered URI exactly. Claude additionally requires equivalent port-agnostic handling of localhost, although RFC 8252 discourages the hostname form. Once a request selects its actual redirect, bind the code to that complete URI for redemption. This is not permission for arbitrary redirect hosts or path wildcards. RFC 8252 §§7.3,8.3–8.4, Claude compatibility requirement.
Show the signed-in person, company, client label and actual redirect host clearly. Warn that a loopback destination does not authenticate an installed application. A native process can cite somebody else’s public client metadata and listen locally; CIMD plus PKCE prevents several attacks but is not installed-client attestation. The fixed decision correctly forbids granting different rights because a client calls itself “Claude” or “Codex.” MCP localhost warnings, CIMD security, fixed naming rule.
Observed prototype: consent POSTs to Patchy then returns a 303 to the client. It adds that approved callback’s origin to form-action, with a broad scheme fallback for IPv6. Keep callback allowances per validated consent request; do not add https:/http: globally. form-action restricts form submission, and browser handling across redirect chains has varied, so exercise hosted and loopback callbacks in real browsers. With Clerk’s custom page, its form instead POSTs to the action URL Clerk supplies, so CSP must allow that Clerk FAPI destination too. Prototype consent, CSP shell, CSP specification, browser documentation, Clerk custom flow.
Cursor is a compatibility caveat: first-party staff historically confirmed registration containing a private URI scheme as well as web/loopback URLs, whereas MCP’s communication-security text says localhost or HTTPS redirects. Current Cursor docs/releases describe loopback and hosted fallback. Do not weaken redirect policy based solely on an old report; capture the current registration during acceptance. If it still requires private schemes, record the explicit compatibility exception and its RFC 8252 rationale. Cursor staff, current releases, MCP rule, native-app RFC.
5. Plain HTTP in development.
The specification requires HTTPS AS endpoints; the loopback redirect exception is about returning a code to a native client, not a general exemption for an AS on the LAN or a named development host. Product implementations provide narrower local-development exceptions. Claude Code currently documents all three exact loopback forms, including IPv6, while #727 only reports testing localhost/127.0.0.1; there is no evidence the earlier test established IPv6 failure. <name>.localhost must not be assumed equivalent to literal localhost. MCP HTTPS rule, Claude Code runtime rules, reported observation.
Observed prototype: an HTTP base ending .localhost advertises the token endpoint at 127.0.0.1 on the same port, retaining the original issuer/authorization URL. This solved the reported local Claude Code flow; it is not proof that every client permits this arrangement. Prefer HTTPS for shared/hosted testing and explicit loopback for local-only clients. Hosted Claude cannot reach the developer’s loopback from its cloud; ChatGPT has separately documented secure tunnels, whose OAuth AS still needs to be reachable. Prototype endpoint calculation, Claude testing guidance, OpenAI tunnel/OAuth boundary.
6. Abuse of public endpoints.
CIMD fetcher. The draft specifically calls for avoiding private/loopback destinations and limiting metadata responses, recommending 5 KB. Recommended implementation: validate URL syntax before networking; resolve and block private/link-local/loopback/reserved IPv4 and IPv6 destinations; keep DNS validation coupled to the actual connection; revalidate every redirect or disable redirects; bound time, bytes, redirects and concurrent fetches; send no ambient cookies/credentials; cache successes with a bounded cache and request coalescing. The latter mechanics are engineering recommendations implementing the cited SSRF/DoS guidance, not extra MCP MUSTs. Apply equivalent checks to any fetched JWKS/logo URLs; avoiding remote logos entirely keeps the initial consent flow simpler. A loopback redirect URI being allowed never authorizes a loopback metadata fetch. CIMD §§6.5–6.7, MCP SSRF guidance.
DCR spam and retention. RFC 7591 discusses both open registration and abuse controls; registration is not a user grant. Bound input/URI counts and rate-limit registration independently of authenticated MCP use. Do not trust a self-selected client name. Recommendation: expire never-authorized registrations after a short documented retention period, e.g. seven days; retain registrations backing live grants/refresh credentials until those end. Preserve audit references separately. Do not delete an active ChatGPT client just because the registration is old: OpenAI explicitly says its reused registered client/secret must remain valid while the connection is in use. CIMD avoids this growing DCR inventory, though its cache also needs an eviction bound. RFC 7591 §§3,5, ChatGPT registration lifetime, Clerk’s DCR warning.
Token guessing and DoS. Client IDs are public identifiers, not passwords. Require a high-entropy, short-lived, single-use code plus correct PKCE verifier, client, selected redirect and resource; refresh requires its own secret and live grant. OAuth requires protection against credential guessing; use rate limits and anomaly detection, bounded form parsing and cheap indexed lookups before expensive work. Return standards-shaped failures without exposing whether a user/account exists. Rate-limit by a combination of network and credential/client context rather than only a spoofable public client ID; do not permanently lock the person because a stranger submits guesses. These are implementation choices grounded in OAuth’s guessing/DoS guidance. RFC 6749 §§2.2,4.1,10.10, RFC 9700.
Discovery and CORS. Serve static/cacheable public metadata cheaply. Browser clients need accessible metadata and challenges; CORS is not authentication or protection against non-browser spam. Avoid session cookies on discovery/register/token endpoints; protect the actual consent decision using the signed-in session and CSRF defenses. Claude’s documented endpoint budgets are ten seconds for discovery/register/initial exchange and thirty for refresh, so abuse mitigation must not turn these endpoints into long queues. RFC 8414 §3, Clerk browser metadata guidance, Claude latency, OAuth CSRF guidance.
7. What the prototype actually supplies.
These are source observations, not a claim that #727 is production-complete:
Area
Observed implementation and implication
Registration
Public none DCR, up to ten redirects, client names capped at 64 characters; no CIMD resolver. Registration accepts HTTPS and literal loopback HTTP only, so a mixed historical Cursor registration containing a private scheme is rejected. No client-retention cleanup is present in these modules. OAuth.ts.
Code exchange
Ten-minute hashed codes, transactional single use, client/redirect/S256 binding, and company/person checks. Preserve these properties. OAuth.ts.
Resource/scope
Authorization rejects a supplied foreign resource, but permits omission; a resource is stored with the code, then not selected/checked at redemption. Token decoding has no resource; scope is always patches. Intended-recipient protection currently comes mainly from the isolated use purpose. Make that explicit and carry resource/scope binding through the exchange. OAuth.ts, OAuthPages.ts.
Lifetime and connection
No refresh grant. Opaque pp_ bearer expires after 90 days or 30 idle days. Reconnecting the same user/client ID revokes its prior token, so CIMD’s shared software identity needs explicit thought about independent devices/connections. MachineTokens.ts.
Door and revocation
DB lookup checks token purpose, expiry, idle expiry and active user; AgentAuth separately reads the company switch every call. No Clerk round trip is needed. The prototype says use; the fixed product purpose is work. MachineTokens.ts, AgentAuth.ts, rename decision.
HTTP/consent
Public JSON/CORS endpoints and 8 KiB body bounds; consent uses the browser session and same-origin POST protection; callbacks include iss. Registered redirect matching includes the port exactly, missing CIMD/native variable-port compatibility. No OAuth-specific rate limits are present in the inspected modules. OAuthPages.ts.
ADR-0008’s “one credential” wording also needs amendment for the fixed builder/worker split and for separating a durable connection from renewable access credentials. Its valuable invariants remain: user ownership, hashed secrets, immediate local revocation/deactivation, and browser sign-out separate from machine sign-out. ADR-0008, fixed purposes.
Clerk is an OAuth/OIDC provider, not only a consumer of Google/GitHub OAuth. Its current MCP guide supports CIMD and DCR, and OAuth JWT access tokens became available in January 2026. Older claims that Clerk requires opaque-token verification on every request, cannot do CIMD, or cannot host custom consent are outdated. Provider documentation, MCP guide, JWT changelog, CIMD GA.
Ticket requirement
What Clerk provides; what Patchy still needs; what changes/losses follow
Automatic client onboarding
Enable current-provider CIMD, public-client none, unknown-client admission and DCR for remaining clients. Legacy Clerk OAuth instances do not support CIMD; the actual instance’s implementation must be checked later. Clerk runs metadata retrieval/registration infrastructure, but its docs do not specify every SSRF control, retention limit or rate bucket. Patchy gives up direct control of those internals. CIMD settings.
Our consent wording
Supported: a same-domain custom consent route, prebuilt component with surrounding Patchy copy, or a low-level custom form. The latter must preserve OAuth parameters and use buildConsentActionUrl, show identity/scopes/redirect and both decisions. This requires a Clerk consent integration, not merely changing an application’s display name. Patchy keeps product copy; Clerk owns consent submission/session mechanics. Custom-consent contract.
Company-scoped grant
Clerk’s user:org:read can select an Organization and put org_id into access tokens. Observed repo: Patchy users instead carry local companyId plus clerkUserId. Either map/adopt Clerk Organizations, or maintain a Patchy consent/connection record binding the authenticated Clerk subject to the approved company. Merely looking up whichever company the person currently belongs to does not prove what company they approved. Local user/activity/role checks remain necessary. Organizations, current user model.
Per-client connections listed on Your machines
OAuth applications are client registrations, not a user’s independent grants/devices. The documented application list is not a grant list. Observed current SDK: OAuth access-token data has token ID, client ID, subject, scope and audience, but does not establish a stable connection/family ID across refresh. Patchy still needs its own connection inventory, attribution and last-used tracking, plus a proven mapping from every refreshed token to that connection. Cannot claim turnkey support. Application API, inspected token type.
Disconnect one connection immediately
Clerk’s documented revokeToken takes the opaque access token or refresh token plus OAuth application ID and revokes the associated grant. JWT access tokens remain valid to signature verification until expiry. Patchy ordinarily receives only the access token, never the client’s refresh token. A local per-connection refusal can stop its own door immediately, but revoking the future refresh lineage and preventing old credentials reappearing after reconnection needs a stable grant mapping/revocation mechanism not established by these docs. Do not silently weaken “disconnect” to “within a day.” Revocation, format trade-off.
Company switch checked every call
Entirely compatible: after authentication, resolve the local person/company and check agentsEnabled on every call, just as the prototype does. Turning it off should not revoke Clerk grants. Putting the switch only in a one-day JWT or Clerk metadata would make it stale and fail the fixed contract. Current door, fixed switch.
No Clerk network round trip per call
Supported with OAuth JWTs and a configured PEM/public-key cache. Explicitly accept OAuth access tokens; check type, signature, issuer, resource audience, expiry and granted scope, then local grant/company policy. Opaque tokens instead need Clerk verification; caching that answer sacrifices immediate Clerk-side revocation unless a separate local gate provides it. Key discovery/rotation can still require occasional networking. Verify issuer explicitly rather than assuming a generic JWT signature check enforces it. Verification docs, inspected networkless verifier.
MCP audience, issuer and coarse permission
Positive evidence: observed published FAPI schema accepts RFC 8707 resource on authorize/token/consent, binds code/refresh requests to the grant’s resource, and describes iss in authorization responses. BAPI verification exposes aud. Custom OAuth scopes are now documented. Configure a narrow Patchy permission; avoid granting private_metadata/profile data solely to make MCP authentication work. Actual audience/issuer output still needs a development acceptance test. FAPI schema, BAPI schema, custom scopes.
Refresh, expiry and builder separation
Code/refresh grants exist; current guide says access tokens last one day, refresh tokens never expire. Conflict: published FAPI schema says refresh tokens last ten years. I found no clear provider guarantee of public-client refresh rotation/reuse detection or configurable 90-day/30-idle policy. These require confirmation/testing, not an assumption from Clerk browser-session rotation. Keep existing builder machine tokens separate; Clerk M2M is a different service identity model. OAuth lifetimes, conflicting schema, machine-auth distinctions.
An additional interoperability check is necessary for ChatGPT’s current CIMD document: observed public JSON has legacy singular token_endpoint_auth_method: private_key_jwt while its new methods array allows both none and private_key_jwt. OpenAI explicitly documents this transition. Clerk documents public CIMD clients, but not its handling of that plural-method negotiation. Do not infer either incompatibility or success. DCR or a supplied public client is a fallback while this is proved. Live ChatGPT document, OpenAI transition, Clerk CIMD requirements.
Clerk cost. Current published platform pricing is Hobby $0, Pro $25/month or $20/month billed annually, Business $300/month or $250/month annually, with 50,000 monthly retained users per app included; Pro user overages start at $0.02/MRU/month. Clerk Organizations has separate free limits/add-on pricing, relevant only if Patchy adopts that model. These are general platform prices, not a quoted MCP bill. Current pricing.
The pricing table explicitly meters API keys and M2M tokens, but does not give an explicit OAuth-token price/allowance. Clerk’s July 2025 MCP announcement says OAuth machine-token use was free during beta and would later be priced. Those sources do not establish the October 2026 OAuth commercial contract. Therefore: incremental OAuth cost is unresolved, not “free forever,” and the API-key/M2M verification prices must not be assigned to OAuth by analogy. Local JWT verification avoids a Clerk verification request, but does not prove token issuance/refresh is unbilled. Pricing table, dated beta statement.
Recommendation and reasons. Use Clerk for browser identity and keep Patchy responsible for the worker-agent authorization server and grant store. This preserves immediate revocation, one-company consent, local checks, independent builder credentials and one coherent Your machines inventory. Extend the prototype’s useful primitives with CIMD, native redirect matching, rotating refresh, resource/scope binding and endpoint abuse controls. Owning this server also means owning protocol/security maintenance: use established OAuth components where practical and focused interoperability/security tests. OpenAI recommends an established identity provider; that is a real maintenance advantage for Clerk. This recommendation weighs it against the unresolved grant-management fit, rather than claiming Clerk cannot authorize MCP. Fixed requirements, prototype, Clerk revocation limitation, OpenAI provider guidance, MCP registration/security.
Clerk would remove much OAuth protocol hosting/registration/key-management work. It would not remove Patchy consent policy, company authorization or the connection inventory, and it adds provider lifecycle/pricing dependencies. I would change the recommendation if Clerk establishes a supported stable grant identifier, list/revoke-by-grant integration, refresh rotation and lifetime controls, current ChatGPT/loopback compatibility, and an explicit OAuth price. A Clerk-fronted exchange issuing Patchy tokens would reintroduce an AS boundary and two credential lifecycles; it is not the smallest solution to this ticket. Clerk capabilities, documented revocation input, token lifetimes.
9. What remains to prove in the signing-in ticket.
These are targeted acceptance checks, not findings from tests performed in this lane: record client/version and negotiated MCP revision; confirm CIMD/DCR and exact redirect; verify resource and issuer handling; exercise access expiry with/without refresh, rotation, rejected refresh and 403 scope escalation; disconnect then attempt refresh/reconnect; turn the company switch off/on; deactivate the person; check consent CSP for hosted and ephemeral loopback callbacks. Check current Cursor’s full DCR redirect set and Gemini’s stable/preview issuer difference explicitly. Do not set an arbitrary sunset for 2025-11-25 while hosted Claude still documents it. Claude supported versions, Cursor release notes, Gemini preview correction, map’s compatibility rule.
Merged from two lanes; both lane reports are the comments above, with every source cited.
Claude Opus 5.5 read the specs and the RFCs and IETF drafts they cite, plus each client's docs and source at pinned commits. It also fetched the five clients' live CIMD documents, read Claude Code's shipped bundle for strings, and read Clerk's docs, OpenAPI specs and SDK source.
GPT 6.1 Sol read the same primary sources and client source.
Neither lane ran a fresh OAuth sign-in or changed any Clerk setting. The two lanes agree on every recommendation; where they differ on a detail, both positions are given.
Recommendation: keep Patchy's own authorization server, with Clerk for browser identity. This is how the prototype already works: Clerk signs the person in on the consent page, and Patchy authorizes the agent. Clerk has caught up on the protocol: Client ID Metadata Documents (CIMD) went generally available in September 2026, and it supports DCR, PKCE, resource binding, iss, custom scopes, refresh tokens and locally verifiable JWT access tokens. It falls short on what this map fixed:
What the map needs
Clerk today
Disconnect one connection, immediately
No API lists a person's grants, or revokes one by grant, user or client: revoking needs the token's value. JWT access tokens can't be revoked during their one-day life. Clerk's refresh tokens "never expire" in the guide and last 10 years in the API spec. ADR-0008's one-transaction revocation on deactivation would become revocation across two systems.
Tell devices apart
Clerk's tokens identify the client, not the grant, and under CIMD every install of a client shares one id.
Company switch on every call
There's no hook before issuance, so Clerk keeps issuing tokens while access is off. Patchy's door check works either way.
Our consent wording
Only through a custom consent flow running in the browser, which Clerk discourages. Today's consent is server-rendered from Patchy's own state.
Dev and test loop
Dev personas mode and offline pnpm test would need a stand-in authorization server.
Price
OAuth isn't on the pricing page. A 2025 announcement said OAuth token use was free during beta and would be priced later. Unresolved.
What Clerk would take over is the part that's cheap to own: roughly the 255 lines of OAuth.ts. Patchy would still keep the consent page, the connection table and the door check. Clerk would win if Patchy adopts Clerk Organizations for company SSO (ADR-0007 expects that one day) and Clerk ships grant listing and revocation plus configurable refresh lifetimes. Settling Clerk's remaining unknowns (loopback on any port, refresh rotation) would need a test on a Clerk development instance, which means changing a Clerk setting with Allison's OK.
Registration: add CIMD, keep DCR.
CIMD: 2026-07-28 makes it the SHOULD and deprecates DCR, which may be removed in the first revision released on or after 2027-07-28. Advertising client_id_metadata_document_supported: true plus the none auth method moves five clients onto it: Claude.ai (with Claude desktop and mobile through it), ChatGPT, Claude Code, Codex and VS Code. Their documents live on claude.ai, chatgpt.com and vscode.dev.
DCR can't go yet:
Cursor and Gemini CLI have no CIMD and no timeline.
Claude Code withholds CIMD when Claude Desktop starts its sign-in with a non-loopback redirect.
Claude Desktop on third-party platforms supports DCR only.
Codex, Gemini CLI and Claude.ai register a new client on every sign-in, so unused registrations are the normal case, not an attack.
ChatGPT's CIMD document says private_key_jwt in its singular field and lists none in its plural field. Patchy must read the plural field, or ChatGPT is refused.
A connection is the grant, not the client. With CIMD every Claude Code install is the same client_id, so the prototype's rule (reconnecting a client revokes that person's earlier token for it) would let a second laptop disconnect the first. The grant made at consent has to be the connection, with credentials hanging off it.
Lifetimes: rotating refresh tokens and a short access token.
What clients do: every checked client refreshes ahead of expiry (between 30 s and 5 min) and again after a 401, and every one accepts a rotated refresh token. None documents the access-token lifetime it expects.
Without a refresh token, every client needs the person when the token lapses: Claude Code says "run /mcp", Codex says "run codex mcp login", and Claude.ai shows Reconnect. A headless claude -p worker can't sign in at all. OpenAI staff say ChatGPT relies on refresh tokens, and one community report (unverified) says its tools disappear without them.
What the spec says: servers SHOULD issue short-lived access tokens and MUST rotate public clients' refresh tokens.
Proposed starting policy, from both lanes:
access tokens of about an hour, still opaque and checked against the database, so disconnecting, deactivation and agent access off act on the next call;
a rotating refresh token whose family is the connection, held to ADR-0008's limits (30 idle days, 90 days absolute).
Whether a person re-consents every 90 days is the sign-in ticket's call.
Replay detection: detecting a replayed refresh token and revoking the whole family will occasionally disconnect a legitimate person whose client raced itself. Claude Code and Cursor have both shipped fixes for refresh races, so pick that trade-off deliberately.
Open endpoints. Discovery and the token exchange are public by design.
Fetching CIMD documents (Patchy fetching a URL a stranger names), per the current CIMD draft:
never fetch special-use addresses, which include the cloud's link-local metadata addresses;
follow no redirects and accept only a 200;
read about 5 KB at most;
cache by the response headers, within bounds, and never cache errors;
pin DNS between the check and the fetch.
The draft sets no timeout, but Claude gives Patchy's endpoints 10 s. Because the clients we check use only three hosts, a trust policy keeps it small: fetch everything, and warn on consent for unknown hosts. Risk (Opus): two open reports say claude.ai's Cloudflare edge challenges server-side fetches of Anthropic's documents from some datacenter addresses. Verify from Patchy's real egress.
Registration: RFC 7591 allows rate-limiting registration and expiring unused registrations. Expire clients that never complete a grant after a short window (Sol suggests seven days), but keep any client that backs a live grant.
The token endpoint: codes and tokens already carry 256 bits; codes last 10 minutes and are single use. Add rate limits, and revoke what a code minted if the code is replayed.
Prototype gaps both lanes found (for the build, not decisions):
An open redirect before sign-in./oauth/authorize redirects some bad requests to the client's registered URI before the person is signed in, and anyone can register a URI through open DCR. OAuth 2.1 and RFC 9700 say the person MUST be authenticated first.
Loopback redirects must match on any port (RFC 8252 MUST), with host and path exact, including localhost as Anthropic asks. Claude Code, Codex and VS Code publish port-less loopback URIs and bind a new port each sign-in; today's match is exact.
resource isn't bound through the exchange. It's checked at authorize, then dropped. Today the use/work purpose is what keeps the token to this door.
The 401 and the protected resource metadata don't name a scope. Add scope="patches" and scopes_supported, and error="invalid_token" when a bad token was sent.
No rate limits on /oauth/*, and registrations kept forever.
Cursor's registration is refused. It sends cursor:// beside its https and loopback URIs. The lanes differ:
Opus: keep the allowed URIs and drop the rest, which RFC 7591 permits and Cursor staff endorse.
Sol: don't loosen the policy on an old report; capture Cursor's current registration at acceptance first.
Small fixes: answer HEAD /mcp with the same 401 (Gemini CLI starts with it), make redirect_uri optional at the token endpoint, and keep iss on every redirect.
Never use HTTP 403 for a policy refusal. VS Code treats a 401 or 403 while it holds a token as a reason to throw away its registration and re-register. Claude.ai treats any 403 other than insufficient_scope as final. "Agent access is off" stays a tool result over HTTP 200, as in the prototype. With one scope, Patchy never needs step-up.
Consent. MCP says the page MUST show the redirect host clearly, and SHOULD warn when every redirect is loopback. The CIMD draft and Anthropic ask to show the client_id host rather than trusting the client's name. Any local process can claim Claude Code's id, which matches the map's rule that a client's name is a label, not proof. The consent page's CSP keeps adding the redirect origin per request; a custom scheme such as cursor: would need a scheme source.
Dev instances.
Claude Code checks only the token endpoint, and only by exact hostname, so today's rewrite to 127.0.0.1 is enough.
Codex and VS Code have no http rule.
Gemini CLI refuses *.localhost for every OAuth endpoint, so it can't sign in to a dev instance. The cleaner equivalent, if Gemini matters in dev: advertise the whole client-facing surface on http://127.0.0.1:<port>, and have /oauth/authorize there bounce the browser to the named host where the session cookie lives.
Claude.ai and ChatGPT can only reach a public https instance. A dev instance must never be exposed publicly (dev personas let anyone sign in as anyone), so the hosted clients get tested in production.
For the tickets
Signing in and out:
Patchy's own authorization server
CIMD plus DCR
the connection as the grant
rotating refresh with an hour-long opaque access token, and the replay-detection trade-off
re-consent every 90 days or not
registration retention
the CIMD fetch rules and trust policy
Cursor's custom scheme
the consent page's hosts and loopback warning
the dev instance's loopback surface
ADR-0008 amended for a durable connection with renewable credentials as well as the work purpose
Surface: policy refusals stay tool results on HTTP 200; HEAD /mcp.
Bounds: rate limits for registration and the token endpoint.
Build: fix the prototype gaps above; the open redirect first.
Activity
allisonmahmood commentedon Oct 17, 2026
Lane report: Claude Opus 5.5
#733: authorizing worker agents, and whether Clerk can be the authorization server (Opus 5.5 lane)
Researched 2026-10-17 from primary sources:
product.json;Observed marks something fetched or read in shipped code rather than documented, and says how. Forum posts and GitHub issues are labelled staff or community. Read-only throughout: nothing was registered with a third party, no Clerk setting was touched, and nothing in the repo changed.
Short answer
Registration: add Client ID Metadata Documents (CIMD) and keep dynamic client registration (DCR).
client_id_metadata_document_supported: true: Claude.ai (and Claude Desktop and mobile through it), ChatGPT, Claude Code, Codex and VS Code. Claude.ai and Codex also require"none"intoken_endpoint_auth_methods_supported, which Patchy already advertises.Refresh and lifetimes: issue rotating refresh tokens and shorten the access token.
claude -pworker can't sign in at all.codex mcp login".Open endpoints: the specs give clear rules, and the prototype misses four of them.
/oauth/*;Clerk or our own: our own.
resourcebinding to anaudclaim;issparameter and custom scopes;OAuth.ts. Patchy would still keep its consent page, its connection table and its per-call check at the door.Per-client tables
Each row is how the client treats an authorization server shaped like Patchy's: PKCE S256 advertised,
issadvertised,noneonly, public clients only.Registration and the flow
registration_endpointresourcesentissinsufficient_scopehttps://claude.ai/oauth/mcp-oauth-client-metadatawhen the server advertises CIMD andnone; otherwise DCR, a new client on every fresh connection; or an admin-entered client [CLA-AUTH]WWW-Authenticatescope, else PRMscopes_supported, plusoffline_accessif the server lists it [CLA-AUTH]issuer; the responseissisn't documented [D3P]https://chatgpt.com/oauth/client.json(the stable id, used because Patchy advertisesiss); then DCR, run once per connection [OAI-AUTH], [OAI-CUSTOM]. Its CIMD document's singular field saysprivate_key_jwtand the plural field listsnone(observed)resource; on refresh, not documented [OAI-AUTH]scope, PRMscopes_supportedand per-toolsecuritySchemes[OAI-AUTH]_meta["mcp/www_authenticate"]; an HTTP 403 isn't documented [OAI-AUTH]--client-id; then CIMDhttps://claude.ai/oauth/claude-code-client-metadatawhenever the flag is advertised (since 2.1.81); then DCR,client_name"Claude Code (<server>)", re-registered when the port changes [CC-MCP], [CC-LOG], bundleresourcemust be same-origin and a path prefix of the MCP URL (bundle)issfails when the server advertises support [CC-MCP], [CC-ERR]WWW-Authenticatescope, else PRMscopes_supported. Never the server'sscopes_supported(since 2.1.196). Addsoffline_accessif listed, and then alsoprompt=consent[CC-MCP], bundleclient_id; then CIMDhttps://chatgpt.com/oauth/codex/client.json(needs the flag,none, and the native/callback; since v0.148.0, 2026-08-18); then DCR, a new client on every login [CODEX-REG], PR #38089--oauth-client-registration dcris usedissis rejected when advertised, a mismatch always RMCP L2141--scopes, then config, then discovered. Discovered means the server'sscopes_supportedin v0.163.0, and onmainthe 401scopethen PRM. Addsoffline_accessif listed [CODEX-AUTH]codex mcp login --scopesagainCLIENT_IDinmcp.json. No CIMD (staff, 2026-09-22, forum). One DCR request carries three redirect URIs, one of themcursor://…(staff, forum; observedstaff: truein Discourse JSON)scopes_supported[CUR-DOCS]client_name"Gemini CLI MCP Client", on every sign-in, or a configuredoauth.clientId. No CIMD [GEM-PROV]oauth.clientIdscopes_supportedclientId; then a stored registration; then CIMDhttps://vscode.dev/oauth/client-metadata.json(since 1.106, 2025-11-12); then DCR; then a prompt [VSC-AUTH], [VSC-106]resourceVSC-AUTH L562WWW-Authenticatescope, then PRM, then the server's list; addsoffline_accessif listedscopefetches a new token; a 401 or 403 while it holds a token throws away the registration and re-registers VSC-MCP L866Every client sends PKCE S256 ([CLA-AUTH], [OAI-AUTH], [CC-MCP], RMCP L1875, Cursor staff, [GEM-FLOW], [VSC-AUTH]).
Lifetimes, redirects and reach
invalid_grant[CLA-AUTH]https://claude.ai/api/mcp/auth_callback[CLA-AUTH]; it is also the only entry in its CIMD (observed: curl)160.79.104.0/21, IPv4 only [CLA-IP]http://127.0.0.1:53280/callback[D3P]refresh_token. Staff: ChatGPT "relies on the OAuth provider being configured to issue refresh tokens" (forum, 2026-09-29). Rotation not documentedhttps://chatgpt.com/connector_platform_oauth_redirectwhen the server advertisesiss, which Patchy does; otherwisehttps://chatgpt.com/connector/oauth/{callback_id}[OAI-AUTH]openai.com/chatgpt-connectors.json(283 prefixes, observed), plus an mTLS client certificate [OAI-IP], [OAI-AUTH]invalid_grantstarts the sign-in over (bundle; [CC-MCP])expires_in: "MCP server "<name>" needs you to sign in again (run /mcp…)".claude -pand the Agent SDK can't run OAuth themselves [CC-ERR], [CC-MCP]http://localhost:<port>/callback, with a random port in 49152–65535 per sign-in, fixable with--callback-port. The listener binds127.0.0.1[CC-MCP], bundle. Its CIMD lists port-lesshttp://localhost/callbackandhttp://127.0.0.1/callback(observed)localhost,127.0.0.1or::1, so<name>.localhostis refused [CC-MCP], and the bundle compares the hostname exactly. Other endpoints aren't checked (bundle)invalid_grantis permanent [CODEX-OAUTH], RMCP L2349codex mcp login"; mid-session "Reconnect to continue…" [CODEX-STARTUP]http://127.0.0.1:<ephemeral>/callbackwhenissis advertised, otherwise/callback/<id>. Port configurable. Its CIMD is port-less (observed) [CODEX-LOGIN]*.localhostis accepted when the MCP URL is loopback RMCP L1244; a dev instance worked (observed on #727)cursor://anysphere.cursor-mcp/oauth/callback,https://www.cursor.com/agents/mcp/oauth/callbackandhttp://localhost:8787/callback(staff). Desktop useslocalhost:8787[CUR-DOCS]http://localhost:<OS port>/oauth/callback[GEM-FLOW]localhost,127.0.0.1or::1.*.localhostand private addresses are refused [GEM-UTILS], so it can't sign in to today's dev instanceshttp://127.0.0.1:33418/, or a random port when 33418 is busy, orhttps://vscode.dev/redirectwhen remote or web [VSC-LOOP], VSC-AUTH L7151. Which spec, and what it asks of Patchy
The current revision is 2026-07-28.
What 2026-07-28 changed for authorization, compared with 2025-11-25:
iss(RFC 9207): the server SHOULD send it, including on errors; a server that sends it MUST advertiseauthorization_response_iss_parameter_supported; clients MUST validate it. A later revision is "expected to upgrade" this to MUST ([A26]#authorization-response-validation).issuer. CIMD ids are portable across servers ([R26]#authorization-server-binding).application_type, and native clients SHOULD send"native"([R26]).offline_accessin theWWW-Authenticatescope or in PRMscopes_supported.What the spec asks of Patchy as the protected resource ([A26], [D26], [S26]):
resource_metadataor a well-known URI. Patchy offers both.scopein the 401WWW-Authenticate. Patchy doesn't.usetoken only opens/mcp, which meets this.error="insufficient_scope"carryingscopeandresource_metadata.error="invalid_token"when a token was presented, and no error code when none was (RFC 6750).Originwith 403 ([HTTP26]). The prototype does.What the spec asks of Patchy as the authorization server:
issueridentical to the URL it was fetched from ([D26]).code_challenge_methods_supportedmust be present, or clients "MUST refuse to proceed" ([S26]#authorization-code-protection). OAuth 2.1 draft -16 removesplain([O21] §4.1.1).resource(RFC 8707): clients MUST send it on authorization and token requests ([A26]#resource-parameter-implementation). The resource server MUST check audience, and RFC 8707 says the server SHOULD audience-restrict the tokens it issues (RFC 8707 §2).localhostor HTTPS and validated exactly ([S26]#communication-security, #open-redirection). OAuth 2.1 and RFC 8252 add that the server "MUST allow any port to be specified at the time of the request for loopback IP redirect URIs" (RFC 8252 §7.3, [O21] §8.4.2).The protocol side (which revision Patchy's door serves) belongs to another ticket. For this one, note:
2025-06-18;2026-07-28is behind an "under development" flag (CODEX protocol_mode.rs).2025-06-18(MCP SDK 1.23.0).2025-11-25(VSC modelContextProtocol.ts L43).2026-07-28and falls back to older revisions [CC-MCP].2. Registration: CIMD and DCR
What the spec asks clients to do ([R26]):
registration_endpoint, then prompt the user.What a CIMD server must do ([R26]#implementation-requirements):
client_idequals the URL exactly.What each client does. The CIMD documents below were fetched with curl on 2026-10-17.
client_id_metadata_document_supported: trueand"none"; "If either is missing, Claude falls back to DCR" [CLA-AUTH].urn:ietf:params:oauth:grant-type:jwt-bearer(observed), so Patchy must accept grant types it doesn't know.none. CIMD support shipped in 2.1.81 on 2026-03-20 ([CC-LOG]; bundle 2.1.302).private_key_jwt, and the pluraltoken_endpoint_auth_methods_supportedsays["none","private_key_jwt"]. ChatGPT picks from the intersection with what the server allows, under SEP-3149, which is still an open PR ([OAI-AUTH], SEP-3149).noneand a native/callbackredirect. It shipped in v0.148.0 (CODEX-REG L53).product.json, observed).Can Patchy drop DCR? Not yet.
What a connection is. CIMD changes this, and it matters to #736.
client_id: all Claude Code installs arehttps://claude.ai/oauth/claude-code-client-metadata.MachineTokens.mintrevokes "the user's earlier live one for the same client". Under CIMD, connecting a second laptop would therefore disconnect the first, which breaks the decision that every device has its own token.3. The flow
PKCE: every client sends S256.
code_challenge_methods_supported.["S256"].resourceand audience:resourceon both authorize and token. Codex, Claude Code, Gemini CLI and VS Code also send it on refresh.new URL(prm.resource).href, so an origin-onlyresourcegains a/(bundle).resourceis<base>/mcp, andcheck()trims one trailing slash before comparing, which covers all of them.<base>/mcp, so that fallback would fail.resource_metadata.HEAD /mcp, and the prototype routes only GET and POST. Answering HEAD with the same 401 keeps Gemini on the header path (inference from GEM-PROV L320).iss: Claude Code v2, ChatGPT, Codex and Gemini CLI validate it. Because Patchy advertises support:issfails in all four;The prototype's
back()addsissto every redirect, errors included, and it matchesissuerbecause both come frompublicBaseUrl. Keep that.Scopes. Patchy has one scope,
patches, listed only in its server metadata.scopes_supported(Claude Code only when configured). They send noscopeunless the 401 or the PRM names one. Patchy accepts that, but it is accidental.scope="patches"in the 401 andscopes_supported: ["patches"]in the PRM (MCP SHOULD; RFC 9728 RECOMMENDED).offline_accessin the PRM or the 401 ([A26]#refresh-tokens). Listing it in the server metadata makes Claude Code and Cursor addprompt=consent([CC-MCP]; Cursor staff). That is harmless, since Patchy always asks for consent, but it isn't needed: issue a refresh token on every code exchange and ignoreoffline_access.Step-up and 403. Step-up support varies: Claude.ai and VS Code re-authorize, Claude Code now prompts, Codex and Gemini CLI fail the call, and ChatGPT's HTTP behaviour is undocumented.
insufficient_scopeas terminal [CLA-LAZY].apps/server/src/Mcp.ts, observed). Keep that.4. Lifetimes
expires_inas valid until a 401. Claude Code 2.1.118 fixed hourly re-authentication in that case [CC-LOG].5. Redirects, consent and the page's CSP
Redirect URIs to expect:
https://claude.ai/api/mcp/auth_callbackhttps://chatgpt.com/connector_platform_oauth_redirecthttp://localhost:<any>/callbackandhttp://127.0.0.1:<any>/callback(Claude Code, Codex)http://127.0.0.1:33418/, any port, andhttps://vscode.dev/redirect(VS Code; Insiders' document listshttps://insiders.vscode.dev/redirect, observed)http://localhost:8787/callbackandhttps://www.cursor.com/agents/mcp/oauth/callback(Cursor), andcursor://anysphere.cursor-mcp/oauth/callbackin Cursor's registrationhttp://localhost:<any>/oauth/callback(Gemini CLI)http://127.0.0.1:53280/callback(Claude Desktop on third-party platforms)What this means for the prototype:
localhost, not only the IP literals [CLA-AUTH].client.redirectUris.includes(redirectUri)inOAuthPages.tsis exact.OAuth.registerrefuses the whole request when any URI is neither https nor loopback http, and Cursor sendscursor://…alongside the other two. "Cursor doesn't currently retry DCR with a reduced set of URIs" (staff, forum).cursor://at/authorize(staff).form-actionon each request. For an IPv6 literal it adds only the scheme, since host sources can't spell one (OAuthPages.consent).form-actioncheck runs for "form-submission" navigations (CSP3 §6.4.1.1). That section doesn't say whether a 303 after the POST is checked again. Listing the target, as the prototype does, is the safe reading.cursor:(CSP3 source-list grammar).vscode://; that second hop isn't Patchy's page.stateis a longvscode://dynamicauthprovider/…URI that must come back verbatim (VSC-AUTH L715). The prototype carriesstatethrough untouched.What the consent page must show:
client_idhostname ([CIMD] §8.5).client_idrather than trustingclient_name[CLA-AUTH].client_idhost, plus a loopback warning.6. Open endpoints: discovery, registration, token
Fetching a client's metadata document safely. These rules come from CIMD -02 (2026-07-06); MCP cites -00.
max-age=300, and VS Code'sno-store(observed).Registration spam and retention:
/oauth/register, andoauth_clientsrows are never deleted./api/*(ApiGuard.ts) and device login (DeviceLogins.ts) only, observed by reading the code ata0257fd.Guessing at the token endpoint:
/oauth/token.Open redirect before sign-in. This is a real bug in the prototype.
OAuthPages.check()answers bad requests (unsupported_response_type, a missing or bad PKCE challenge,invalid_target) with a 303 to the client's registered redirect URI. It runs beforeRequireSession.withViewer.https://attacker.example/…and craft a broken authorize link, and Patchy bounces a signed-out visitor straight there.Discovery endpoints answer anyone, and the specs expect that.
*on the client endpoints and none on/oauth/authorize, which matches.7. Plain http in development
localhost,127.0.0.1, or::1) during local development" ([BP]#oauth-authorization-url-validation).issuerandiss(RFC 8414 §2, RFC 9207 §2).*.localhostis loopback by definition (RFC 6761 §6.3) but isn't on MCP's list.localhost,127.0.0.1or::1([CC-MCP], [CC-ERR]).127.0.0.1is enough.*.localhostmetadata when the MCP URL is loopback (rmcp, cited above). It worked against a dev instance (observed on prototype: people's own agents use patches through Patchy's MCP #727).*.localhost(and*.local,*.internaland private addresses) for every OAuth endpoint, and allows http only when the MCP URL host is exactlylocalhost,127.0.0.1or::1(GEM-UTILS L97, GEM fetch.ts L259). It can't sign in to today's dev instances.http://127.0.0.1:<port>: the MCP URL, PRM, issuer, metadata, registration and token endpoints. Each worktree already has its own port (scripts/dev/src/plan.ts)./oauth/authorizethere bounce the browser to<label>.localhost:<port>, where the session cookie lives. Worktrees use named hosts because cookies ignore ports.8. Clerk as the authorization server
Patchy's production Clerk instance was not changed or relied on for these findings; Clerk's capabilities below come from its docs, specs and SDK.
The ticket's requirements
<OAuthConsent />with an experimentallocalizationprop, or a custom flow that postsconsentedto the Frontend API/v1/me/oauth/consent/{client_id}(custom consent page, localization). Clerk "strongly recommends" the Account Portal page. DCR and CIMD clients always see consentresource. The access-off state would be our page with only Denyorg_id, which needs Clerk Organizations (how Clerk implements OAuth). ADR-0007 rejected Organizationssub(users.clerk_user_id) on every call: the same single join the door already doesPOST /oauth_applications/{id}/revoke_tokenneeds the token's value, and "JWT access tokens cannot be revoked" (Backend API spec 2026-08-20, read in clerk/openapi-specs)jwtKey. Claims:sub,client_id,scope,jti,exp, andaudonly whenaud_claim_enabledis on. Opaque tokens need BackendPOST /oauth_applications/access_tokens/verifyon every call, under a 1,000 requests / 10 s production limit shared with every other Backend call (rate limits)audience = <instance>/mcp, plus Patchy's own per-call checksverifyTokencall must checktypFit with the spec
nativeclients may use custom schemes or loopback http.resourcewithinvalid_target,iss, custom scopes (2026-08-21) and default scopes (2026-07-22).mcp.clerk.com(Clerk MCP server), which suggests it works. Not tested.client_urimust share an origin with a redirect (inspector#710, third party).Cost
Read on 2026-10-17 at clerk.com/pricing.
org_id.What we would gain and lose
mcp.clerk.com.OAuth.ts, roughly 255.pnpm testwould need a stand-in authorization server or fake JWTs, and a Clerk development instance has one consent path shared by every worktree (environments).Recommendation: keep Patchy's own authorization server
Reasons:
OAuth.ts.When Clerk would win: if Patchy adopts Clerk Organizations for company SSO (ADR-0007 expects that one day), and Clerk ships a grant list and revoke API plus configurable refresh lifetimes.
How to settle the unknowns: test Clerk's loopback matching and its refresh rotation on a development instance. That needs Allison's OK, because it means changing a Clerk setting.
9. What Patchy's authorization server should change
From the spec and client findings above. The signing-in ticket decides; this is the evidence.
127.0.0.1,[::1]and, as Anthropic asks,localhost(RFC 8252 §7.3 MUST; [CLA-AUTH])./oauth/authorize([O21] §7.13.2 MUST). Fixes the open redirect.client_id_metadata_document_supported: true.client_id,client_nameandredirect_uris.token_endpoint_auth_methods_supported.client_idhost and the redirect host on consent, and warn on loopback-only clients./oauth/registerand/oauth/token.refresh_tokeningrant_types_supportedandinvalid_grantfor a dead token;<base>/mcp, with idle and absolute expiry;offline_accessin the PRM or the 401.scope="patches"in the 401 andscopes_supportedin the PRM;error="invalid_token"when a bad token was presented;redirect_urioptional at/oauth/token([O21] §10.2 says clients following only OAuth 2.1 won't send it).HEAD /mcpwith the same 401 (Gemini CLI).resourceshould be<base>/mcp, since VS Code and Gemini validate a root PRM against the origin.10. Conflicts and silences
issis SHOULD in MCP and REQUIRED in OAuth 2.1 -16. MCP still links -13.resourcewhen the MCP endpoint has a path.none; Claude Code's code checks only the flag.issvalidation and its expected token lifetime aren't documented.resourceis sent on refresh, rotation, HTTP 403 handling, and itsinitializeversion.-32603until the person clicked Reconnect (staff didn't confirm)./authorizeredirect: "always"localhost:8787on 2026-09-22; a cursor.com URL "on recent versions", called a bug, on 2026-10-15.oauth.enabled: trueor/mcp auth. #25724 is closed "completed" with no CIMD code.expires_in: 7200.Sources
MCP specification:
IETF:
Anthropic:
@anthropic-ai/[email protected], read for strings, never run.OpenAI:
ce0323f(release v0.163.0 is identical in the OAuth files except for scope discovery), all under https://github.com/openai/codex/blob/ce0323f2f2d3b25e82806cd555237da3db4e1897/codex-rs/:rmcp-client/src/oauth_client_registration.rsrmcp-client/src/perform_oauth_login.rsrmcp-client/src/oauth.rscodex-mcp/src/mcp/auth.rscodex-mcp/src/connection_manager/startup.rsCursor:
Gemini CLI v0.64.0 at
4a0749ac, all under https://github.com/google-gemini/gemini-cli/blob/4a0749aceac5643e6f85a36d7420314d85e13b52/packages/core/src/:mcp/oauth-provider.tsutils/oauth-flow.tsmcp/oauth-utils.tsVS Code 1.142.0 at
d956e8a6, all under https://github.com/microsoft/vscode/blob/d956e8a6ac5d904486557eea07e1d6bd62a4d36f/src/vs/workbench/api/:common/extHostAuthentication.tscommon/extHostMcp.tsnode/loopbackServer.tsClerk: the docs, changelog and pricing pages linked in §8; the OpenAPI specs at https://github.com/clerk/openapi-specs (
bapi/2026-08-20.yml,fapi/2026-08-20.yml); andclerk/javascriptpackages/backendat commit 85dec02.Observed, 2026-10-17:
claude.ai/oauth/mcp-oauth-client-metadata,claude.ai/oauth/claude-code-client-metadata,chatgpt.com/oauth/client.json,chatgpt.com/oauth/codex/client.json,vscode.dev/oauth/client-metadata.json), all HTTP 200;openai.com/chatgpt-connectors.json;clerk.clerk.commetadata;product.jsonfrom the stable tarball;a0257fd:packages/auth/src/{OAuth,OAuthPages,AgentAuth,MachineTokens}.ts,apps/server/src/{Mcp,ApiGuard}.ts,scripts/dev/src/plan.ts.allisonmahmood commentedon Oct 17, 2026
Lane report: GPT 6.1 Sol
Short answer — 2026-10-17.
Per-client findings. “Not documented” means the cited first-party material does not settle the behavior; it does not mean unsupported. Source inspection and live public-document fetches are labeled observed below. I did not run fresh client OAuth sessions.
client_id_metadata_document_supported: trueand token authnone; otherwise DCR, with static-client alternatives. S256 PKCE; scope selection andoffline_accessare documented. Hosted documentation lists authorization specs through 2025-11-25, not a blanket 2026-07-28 guarantee. Auth, versions.invalid_grant; rotating responses must include the replacement. No minimum/maximum access TTL or precise no-refresh-token UX is promised. Token requirements.https://claude.ai/api/mcp/auth_callback. Hosted service needs network-reachable MCP and discovery endpoints; a callback to the person’s loopback is not its normal hosted flow. Callbacks/discovery.https://claude.ai/api/mcp/auth_callback, not a desktop loopback callback. A Code session running inside Desktop can instead follow Claude Code’s local flow. Surface distinctions.noneandprivate_key_jwt. S256,resourceon authorization/token requests, and issuer checking are documented. OAuth contract, custom-server setup.https://chatgpt.com/connector_platform_oauth_redirect; otherwisehttps://chatgpt.com/connector/oauth/{callback_id}; some older connections retain the stable callback. Use the URI displayed for that connection. Aug 21 change, callback rules.http://localhost:<ephemeral>/callback; metadata also declares127.0.0.1. Fixed-port option exists. v2 documents HTTP token endpoints only onlocalhost,127.0.0.1, or::1. Code docs, metadata.none, and a supported loopback callback. Supplied ID wins.issis validated; callbacks without advertised issuer support get a server-specific suffix. MCP docs.expires_in, refresh begins with a 30-second skew, and rejected refresh is tested to retire credentials and require reauthentication. No product-wide TTL bound is documented. Expiry code, recovery test, inspected not executed.http://127.0.0.1:<ephemeral>/callback, or/callback/{callback_id}without issuer binding; configurable callback/port. Portless registration and variable-port matching are explicitly documented. Remote plain-HTTP AS exceptions are not promised in these docs. Callback contract.iss/step-up details are not specified sufficiently to certify each behavior. MCP docs, IDE releases.http://localhost:8787/callback; web/Agentshttps://www.cursor.com/agents/mcp/oauth/callback. Historical DCR also includedcursor://anysphere.cursor-mcp/oauth/callback; current releases add hosted fallback. Local MCP HTTP examples do not establish arbitrary HTTP token-endpoint acceptance. Docs, staff/history, releases.issvalidation, but Oct 13 preview notes contain a related fix: do not assume stable 0.64 has every preview correction. Docs, source, preview./mcp authis the documented recovery. Observed source: failed refresh removes credentials and returns no valid token. No TTL bound or automatic scope-step-up promise found. Docs, source.http://localhost:<random>/oauth/callback, configurableredirectUri. Observed source: HTTP OAuth endpoints require the local-development loopback allowance; HTTPS is otherwise required. Redirect docs, URL validation.WWW-Authenticatescope step-up. The developer guide still says DCR-first: that text is inconsistent with newer release notes and observed current source. Source uses S256/resource;issvalidation was not established by the inspected generic flow. Release notes, older guide, selection source.http://127.0.0.1:33418andhttps://vscode.dev/redirect; observed live CIMD hashttp://127.0.0.1:33418/with a slash. Prefer actual metadata/exact selected callback over prose. A complete HTTP AS exception policy is not documented. Guide, live metadata.Evidence and scope. I read #733, #730, the first resolution comment on #731 and the specified local files at commit
a0257fd9914444b04025ed7293cd332c4dda024a. The fixed model remains one person/company grant, separatebuildandworkpurposes, company agent access checked on every call, and consent-approved client names as labels rather than authority. Ticket, map, fixed decisions.“Observed” here means reading source files/OpenAPI schemas or fetching public JSON with HTTP GET, not testing an installed client. The prototype’s successful Claude Code/Codex OAuth and HTTP restriction are previous observations reported by #727, not experiments repeated in this lane. No repo files, GitHub records or Clerk configuration were changed. Reported experiments.
1. What the two MCP revisions require.
On this date
/specification/latest/basic/authorizationresolved to 2026-07-28. The 2025-11-25 revision already recommends CIMD, makes DCR optional, separates protected resource from AS, requires resource indicators and includes scope escalation. The newer revision explicitly deprecates DCR and adds more detailed registration binding, issuer-response validation and refresh guidance. OAuth 2.1 and CIMD remain referenced Internet-Drafts; “OAuth 2.1” is not the name of a finalized RFC. 2025-11-25, 2026 changes, OAuth draft.Patchy’s protected-resource duties are public RFC 9728 metadata naming its canonical resource and AS, a discoverable 401 challenge, and validating authorization on every request. Implement both well-known locations and the challenge pointer for compatibility; that exceeds the minimum of providing one discovery mechanism. Bind resource metadata to the actual
/mcpURL. Metadata is public, not company data. MCP discovery, RFC 9728 §§2–5.Patchy’s AS duties include OAuth authorization-code handling, metadata via RFC 8414 or OIDC Discovery, validated redirect registration, S256 PKCE, code/client/redirect binding, and appropriate public/confidential-client security. Clients must refuse authorization if PKCE support is not advertised. Keep codes single-use and short-lived; the familiar ten-minute upper recommendation comes from OAuth, not a client’s required access-token TTL. MCP security, RFC 7636 §4, OAuth draft §4.1, RFC 8414.
CIMD is a URL-based client identity, not DCR under another name. Validate HTTPS/path/no fragment/no userinfo, required JSON fields, exact document
client_id, and allowed redirects. Cache successful metadata with HTTP caching rules. Public metadata alone does not prove that the process presenting its URL is the named client, particularly with loopback callbacks; user-approved naming must remain a label. The draft also allows asymmetric client authentication, unlike a shared secret published in a document. CIMD draft §§3–6, MCP registration.Can DCR go? For newly implemented protocol support, CIMD is the preferred path. For this client matrix, retain DCR until supported Cursor/Gemini versions have documented or observed CIMD onboarding, or accept a manual pre-registration step for them. No protocol obligation forces DCR forever. Do not make an initial registration access token, CAPTCHA or administrator-created client a requirement for the automatic public-DCR path. Those are valid closed-registration policies but would change the onboarding product. MCP registration, RFC 7591 appendix A.1, client evidence above.
2. Resource, issuer, scope and step-up.
resourceandscopesolve different problems: which API a token can reach versus what it can do there. Clients send the canonical MCP resource on authorization and token requests even if an AS ignores it. Patchy must actually enforce intended-recipient binding: for opaque tokens, store/verify the resource with the grant; for JWTs, verify the intended audience. A Clerk login JWT, ID token or builder token must not become an MCP credential just because its signature is valid. An ID token’s client audience is not evidence of an MCP access-token audience. RFC 8707 §§2–3, MCP audience rules, OIDC ID-token contract.Emit
isson successful and error authorization responses, advertiseauthorization_response_iss_parameter_supported: true, and keep the issuer string identical across metadata and callbacks. Clients record the validated expected issuer before redirecting. Advertised support plus missingiss, or a mismatched presentiss, fails before code exchange. Exact comparison means trailing slash/port/case “cleanup” is unsafe. The latest MCP recommendation to emitissis currently SHOULD, not yet an unconditional MUST. RFC 9207 §§2–2.4, latest response validation.Use one coarse MCP permission consistent with the fixed all-company-agent-areas grant; do not invent per-patch or read-only OAuth consent here. Advertise the required permission in
WWW-Authenticateand resource metadata; validate requested/granted scope rather than returning a constant unrelated to the request.offline_access, if used for refresh issuance, belongs to the AS’s refresh policy, not a required MCP-resource permission. Fixed grant, RFC 6749 §3.3, MCP refresh guidance.Missing/expired/invalid credentials produce 401; a valid token lacking a required scope produces 403 with
error="insufficient_scope", requiredscope, and preferablyresource_metadata. Clients should reauthorize with the union of previously requested and newly challenged scopes and limit retries. Put every scope needed for the operation in one challenge. A company’s agent-access-off decision is an ordinary authorization refusal, not a scope upgrade: repeatedly asking consent cannot repair it. RFC 6750 §3.1, latest step-up, company-switch contract.Client-specific scope behavior matters: Claude documents transport 403 scope escalation; Claude Code’s pinned
oauth.scopescan require editing before reauthentication; VS Code’s 1.106 notes explicitly add step-up. ChatGPT additionally documents tool-levelsecuritySchemesand_meta["mcp/www_authenticate"]for its lazy linking UI. That extension is not a substitute for standards-compliant HTTP authorization at Patchy’s protected endpoint. Cursor/Gemini’s exact step-up behavior remains unproven by the reviewed docs. Claude, Claude Code, VS Code, ChatGPT.3. Lifetime policy and expiry behavior.
Refresh tokens are discretionary: clients cannot assume issuance. The new MCP guidance tells clients to advertise the refresh grant and optionally request AS-advertised
offline_access. For public clients, MCP’s security text explicitly requires rotation; RFC 9700 describes rotation or sender-constraining as replay protection, plus expiry after inactivity. Implement rotation for these public clients rather than relying on client names as authentication. Replayed refresh tokens must not silently revive revoked grants. MCP refresh, MCP rotation, RFC 9700 §4.14.Recommended Patchy model: a durable agent connection owns person, company, client, granted scope/resource, revocation, creation and last use; short-lived access tokens and rotating refresh credentials refer to it. Every MCP request still checks the live connection, person and company switch locally. A refresh cannot extend the connection beyond its absolute/idle expiry or undo revocation. This preserves the fixed product model while making credential renewal transparent. One-hour access TTL and 90-day absolute / 30-day idle connection TTL are proposed values; only the latter pair already exists in ADR-0008. Fixed model, ADR, security rationale.
With refresh, persist and return the replacement atomically, preserve resource/scope/client binding, and return
invalid_grantfor an invalid/revoked refresh grant. Without refresh, an expired token is unusable and a new authorization is necessary; whether a particular client opens a browser immediately, offers a reconnect button, or fails the current tool call is a separate UX question. The table marks where that UX is documented or source-observed. No evidence justifies inventing one common behavior or a required “five-minute” access-token lifetime. RFC 6749 §§5–6, Claude’s distinct five-minute early-refresh window.4. Redirect matching, consent and CSP.
Registration-time redirect validation and exchange-time binding are separate checks. RFC 8252 requires varying-port acceptance for IP-literal loopback redirects; match the remaining registered URI exactly. Claude additionally requires equivalent port-agnostic handling of
localhost, although RFC 8252 discourages the hostname form. Once a request selects its actual redirect, bind the code to that complete URI for redemption. This is not permission for arbitrary redirect hosts or path wildcards. RFC 8252 §§7.3,8.3–8.4, Claude compatibility requirement.Show the signed-in person, company, client label and actual redirect host clearly. Warn that a loopback destination does not authenticate an installed application. A native process can cite somebody else’s public client metadata and listen locally; CIMD plus PKCE prevents several attacks but is not installed-client attestation. The fixed decision correctly forbids granting different rights because a client calls itself “Claude” or “Codex.” MCP localhost warnings, CIMD security, fixed naming rule.
Observed prototype: consent POSTs to Patchy then returns a 303 to the client. It adds that approved callback’s origin to
form-action, with a broad scheme fallback for IPv6. Keep callback allowances per validated consent request; do not addhttps:/http:globally.form-actionrestricts form submission, and browser handling across redirect chains has varied, so exercise hosted and loopback callbacks in real browsers. With Clerk’s custom page, its form instead POSTs to the action URL Clerk supplies, so CSP must allow that Clerk FAPI destination too. Prototype consent, CSP shell, CSP specification, browser documentation, Clerk custom flow.Cursor is a compatibility caveat: first-party staff historically confirmed registration containing a private URI scheme as well as web/loopback URLs, whereas MCP’s communication-security text says localhost or HTTPS redirects. Current Cursor docs/releases describe loopback and hosted fallback. Do not weaken redirect policy based solely on an old report; capture the current registration during acceptance. If it still requires private schemes, record the explicit compatibility exception and its RFC 8252 rationale. Cursor staff, current releases, MCP rule, native-app RFC.
5. Plain HTTP in development.
The specification requires HTTPS AS endpoints; the loopback redirect exception is about returning a code to a native client, not a general exemption for an AS on the LAN or a named development host. Product implementations provide narrower local-development exceptions. Claude Code currently documents all three exact loopback forms, including IPv6, while #727 only reports testing
localhost/127.0.0.1; there is no evidence the earlier test established IPv6 failure.<name>.localhostmust not be assumed equivalent to literallocalhost. MCP HTTPS rule, Claude Code runtime rules, reported observation.Observed prototype: an HTTP base ending
.localhostadvertises the token endpoint at127.0.0.1on the same port, retaining the original issuer/authorization URL. This solved the reported local Claude Code flow; it is not proof that every client permits this arrangement. Prefer HTTPS for shared/hosted testing and explicit loopback for local-only clients. Hosted Claude cannot reach the developer’s loopback from its cloud; ChatGPT has separately documented secure tunnels, whose OAuth AS still needs to be reachable. Prototype endpoint calculation, Claude testing guidance, OpenAI tunnel/OAuth boundary.6. Abuse of public endpoints.
CIMD fetcher. The draft specifically calls for avoiding private/loopback destinations and limiting metadata responses, recommending 5 KB. Recommended implementation: validate URL syntax before networking; resolve and block private/link-local/loopback/reserved IPv4 and IPv6 destinations; keep DNS validation coupled to the actual connection; revalidate every redirect or disable redirects; bound time, bytes, redirects and concurrent fetches; send no ambient cookies/credentials; cache successes with a bounded cache and request coalescing. The latter mechanics are engineering recommendations implementing the cited SSRF/DoS guidance, not extra MCP MUSTs. Apply equivalent checks to any fetched JWKS/logo URLs; avoiding remote logos entirely keeps the initial consent flow simpler. A loopback redirect URI being allowed never authorizes a loopback metadata fetch. CIMD §§6.5–6.7, MCP SSRF guidance.
DCR spam and retention. RFC 7591 discusses both open registration and abuse controls; registration is not a user grant. Bound input/URI counts and rate-limit registration independently of authenticated MCP use. Do not trust a self-selected client name. Recommendation: expire never-authorized registrations after a short documented retention period, e.g. seven days; retain registrations backing live grants/refresh credentials until those end. Preserve audit references separately. Do not delete an active ChatGPT client just because the registration is old: OpenAI explicitly says its reused registered client/secret must remain valid while the connection is in use. CIMD avoids this growing DCR inventory, though its cache also needs an eviction bound. RFC 7591 §§3,5, ChatGPT registration lifetime, Clerk’s DCR warning.
Token guessing and DoS. Client IDs are public identifiers, not passwords. Require a high-entropy, short-lived, single-use code plus correct PKCE verifier, client, selected redirect and resource; refresh requires its own secret and live grant. OAuth requires protection against credential guessing; use rate limits and anomaly detection, bounded form parsing and cheap indexed lookups before expensive work. Return standards-shaped failures without exposing whether a user/account exists. Rate-limit by a combination of network and credential/client context rather than only a spoofable public client ID; do not permanently lock the person because a stranger submits guesses. These are implementation choices grounded in OAuth’s guessing/DoS guidance. RFC 6749 §§2.2,4.1,10.10, RFC 9700.
Discovery and CORS. Serve static/cacheable public metadata cheaply. Browser clients need accessible metadata and challenges; CORS is not authentication or protection against non-browser spam. Avoid session cookies on discovery/register/token endpoints; protect the actual consent decision using the signed-in session and CSRF defenses. Claude’s documented endpoint budgets are ten seconds for discovery/register/initial exchange and thirty for refresh, so abuse mitigation must not turn these endpoints into long queues. RFC 8414 §3, Clerk browser metadata guidance, Claude latency, OAuth CSRF guidance.
7. What the prototype actually supplies.
These are source observations, not a claim that #727 is production-complete:
noneDCR, up to ten redirects, client names capped at 64 characters; no CIMD resolver. Registration accepts HTTPS and literal loopback HTTP only, so a mixed historical Cursor registration containing a private scheme is rejected. No client-retention cleanup is present in these modules. OAuth.ts.resource; scope is alwayspatches. Intended-recipient protection currently comes mainly from the isolatedusepurpose. Make that explicit and carry resource/scope binding through the exchange. OAuth.ts, OAuthPages.ts.pp_bearer expires after 90 days or 30 idle days. Reconnecting the same user/client ID revokes its prior token, so CIMD’s shared software identity needs explicit thought about independent devices/connections. MachineTokens.ts.use; the fixed product purpose iswork. MachineTokens.ts, AgentAuth.ts, rename decision.iss. Registered redirect matching includes the port exactly, missing CIMD/native variable-port compatibility. No OAuth-specific rate limits are present in the inspected modules. OAuthPages.ts.ADR-0008’s “one credential” wording also needs amendment for the fixed builder/worker split and for separating a durable connection from renewable access credentials. Its valuable invariants remain: user ownership, hashed secrets, immediate local revocation/deactivation, and browser sign-out separate from machine sign-out. ADR-0008, fixed purposes.
8. Clerk: concrete requirement-by-requirement comparison.
Clerk is an OAuth/OIDC provider, not only a consumer of Google/GitHub OAuth. Its current MCP guide supports CIMD and DCR, and OAuth JWT access tokens became available in January 2026. Older claims that Clerk requires opaque-token verification on every request, cannot do CIMD, or cannot host custom consent are outdated. Provider documentation, MCP guide, JWT changelog, CIMD GA.
none, unknown-client admission and DCR for remaining clients. Legacy Clerk OAuth instances do not support CIMD; the actual instance’s implementation must be checked later. Clerk runs metadata retrieval/registration infrastructure, but its docs do not specify every SSRF control, retention limit or rate bucket. Patchy gives up direct control of those internals. CIMD settings.buildConsentActionUrl, show identity/scopes/redirect and both decisions. This requires a Clerk consent integration, not merely changing an application’s display name. Patchy keeps product copy; Clerk owns consent submission/session mechanics. Custom-consent contract.user:org:readcan select an Organization and putorg_idinto access tokens. Observed repo: Patchy users instead carry localcompanyIdplusclerkUserId. Either map/adopt Clerk Organizations, or maintain a Patchy consent/connection record binding the authenticated Clerk subject to the approved company. Merely looking up whichever company the person currently belongs to does not prove what company they approved. Local user/activity/role checks remain necessary. Organizations, current user model.revokeTokentakes the opaque access token or refresh token plus OAuth application ID and revokes the associated grant. JWT access tokens remain valid to signature verification until expiry. Patchy ordinarily receives only the access token, never the client’s refresh token. A local per-connection refusal can stop its own door immediately, but revoking the future refresh lineage and preventing old credentials reappearing after reconnection needs a stable grant mapping/revocation mechanism not established by these docs. Do not silently weaken “disconnect” to “within a day.” Revocation, format trade-off.agentsEnabledon every call, just as the prototype does. Turning it off should not revoke Clerk grants. Putting the switch only in a one-day JWT or Clerk metadata would make it stale and fail the fixed contract. Current door, fixed switch.issin authorization responses. BAPI verification exposesaud. Custom OAuth scopes are now documented. Configure a narrow Patchy permission; avoid grantingprivate_metadata/profile data solely to make MCP authentication work. Actual audience/issuer output still needs a development acceptance test. FAPI schema, BAPI schema, custom scopes.An additional interoperability check is necessary for ChatGPT’s current CIMD document: observed public JSON has legacy singular
token_endpoint_auth_method: private_key_jwtwhile its new methods array allows bothnoneandprivate_key_jwt. OpenAI explicitly documents this transition. Clerk documents public CIMD clients, but not its handling of that plural-method negotiation. Do not infer either incompatibility or success. DCR or a supplied public client is a fallback while this is proved. Live ChatGPT document, OpenAI transition, Clerk CIMD requirements.Clerk cost. Current published platform pricing is Hobby $0, Pro $25/month or $20/month billed annually, Business $300/month or $250/month annually, with 50,000 monthly retained users per app included; Pro user overages start at $0.02/MRU/month. Clerk Organizations has separate free limits/add-on pricing, relevant only if Patchy adopts that model. These are general platform prices, not a quoted MCP bill. Current pricing.
The pricing table explicitly meters API keys and M2M tokens, but does not give an explicit OAuth-token price/allowance. Clerk’s July 2025 MCP announcement says OAuth machine-token use was free during beta and would later be priced. Those sources do not establish the October 2026 OAuth commercial contract. Therefore: incremental OAuth cost is unresolved, not “free forever,” and the API-key/M2M verification prices must not be assigned to OAuth by analogy. Local JWT verification avoids a Clerk verification request, but does not prove token issuance/refresh is unbilled. Pricing table, dated beta statement.
Recommendation and reasons. Use Clerk for browser identity and keep Patchy responsible for the worker-agent authorization server and grant store. This preserves immediate revocation, one-company consent, local checks, independent builder credentials and one coherent Your machines inventory. Extend the prototype’s useful primitives with CIMD, native redirect matching, rotating refresh, resource/scope binding and endpoint abuse controls. Owning this server also means owning protocol/security maintenance: use established OAuth components where practical and focused interoperability/security tests. OpenAI recommends an established identity provider; that is a real maintenance advantage for Clerk. This recommendation weighs it against the unresolved grant-management fit, rather than claiming Clerk cannot authorize MCP. Fixed requirements, prototype, Clerk revocation limitation, OpenAI provider guidance, MCP registration/security.
Clerk would remove much OAuth protocol hosting/registration/key-management work. It would not remove Patchy consent policy, company authorization or the connection inventory, and it adds provider lifecycle/pricing dependencies. I would change the recommendation if Clerk establishes a supported stable grant identifier, list/revoke-by-grant integration, refresh rotation and lifetime controls, current ChatGPT/loopback compatibility, and an explicit OAuth price. A Clerk-fronted exchange issuing Patchy tokens would reintroduce an AS boundary and two credential lifecycles; it is not the smallest solution to this ticket. Clerk capabilities, documented revocation input, token lifetimes.
9. What remains to prove in the signing-in ticket.
These are targeted acceptance checks, not findings from tests performed in this lane: record client/version and negotiated MCP revision; confirm CIMD/DCR and exact redirect; verify resource and issuer handling; exercise access expiry with/without refresh, rotation, rejected refresh and 403 scope escalation; disconnect then attempt refresh/reconnect; turn the company switch off/on; deactivate the person; check consent CSP for hosted and ephemeral loopback callbacks. Check current Cursor’s full DCR redirect set and Gemini’s stable/preview issuer difference explicitly. Do not set an arbitrary sunset for 2025-11-25 while hosted Claude still documents it. Claude supported versions, Cursor release notes, Gemini preview correction, map’s compatibility rule.
Changelogs checked alongside current docs: Claude.ai release notes, Claude Desktop, Claude Code, ChatGPT OAuth change log, Codex/ChatGPT releases, Cursor IDE, Gemini stable notes and preview notes, VS Code 1.106. Release notes supplement the contracts above; silence in a changelog does not certify unsupported behavior.
allisonmahmood commentedon Oct 17, 2026
Resolution
Merged from two lanes; both lane reports are the comments above, with every source cited.
Neither lane ran a fresh OAuth sign-in or changed any Clerk setting. The two lanes agree on every recommendation; where they differ on a detail, both positions are given.
Recommendation: keep Patchy's own authorization server, with Clerk for browser identity. This is how the prototype already works: Clerk signs the person in on the consent page, and Patchy authorizes the agent. Clerk has caught up on the protocol: Client ID Metadata Documents (CIMD) went generally available in September 2026, and it supports DCR, PKCE,
resourcebinding,iss, custom scopes, refresh tokens and locally verifiable JWT access tokens. It falls short on what this map fixed:pnpm testwould need a stand-in authorization server.What Clerk would take over is the part that's cheap to own: roughly the 255 lines of
OAuth.ts. Patchy would still keep the consent page, the connection table and the door check. Clerk would win if Patchy adopts Clerk Organizations for company SSO (ADR-0007 expects that one day) and Clerk ships grant listing and revocation plus configurable refresh lifetimes. Settling Clerk's remaining unknowns (loopback on any port, refresh rotation) would need a test on a Clerk development instance, which means changing a Clerk setting with Allison's OK.Registration: add CIMD, keep DCR.
CIMD: 2026-07-28 makes it the SHOULD and deprecates DCR, which may be removed in the first revision released on or after 2027-07-28. Advertising
client_id_metadata_document_supported: trueplus thenoneauth method moves five clients onto it: Claude.ai (with Claude desktop and mobile through it), ChatGPT, Claude Code, Codex and VS Code. Their documents live on claude.ai, chatgpt.com and vscode.dev.DCR can't go yet:
Codex, Gemini CLI and Claude.ai register a new client on every sign-in, so unused registrations are the normal case, not an attack.
ChatGPT's CIMD document says
private_key_jwtin its singular field and listsnonein its plural field. Patchy must read the plural field, or ChatGPT is refused.A connection is the grant, not the client. With CIMD every Claude Code install is the same
client_id, so the prototype's rule (reconnecting a client revokes that person's earlier token for it) would let a second laptop disconnect the first. The grant made at consent has to be the connection, with credentials hanging off it.Lifetimes: rotating refresh tokens and a short access token.
What clients do: every checked client refreshes ahead of expiry (between 30 s and 5 min) and again after a 401, and every one accepts a rotated refresh token. None documents the access-token lifetime it expects.
Without a refresh token, every client needs the person when the token lapses: Claude Code says "run /mcp", Codex says "run
codex mcp login", and Claude.ai shows Reconnect. A headlessclaude -pworker can't sign in at all. OpenAI staff say ChatGPT relies on refresh tokens, and one community report (unverified) says its tools disappear without them.What the spec says: servers SHOULD issue short-lived access tokens and MUST rotate public clients' refresh tokens.
Proposed starting policy, from both lanes:
Whether a person re-consents every 90 days is the sign-in ticket's call.
Replay detection: detecting a replayed refresh token and revoking the whole family will occasionally disconnect a legitimate person whose client raced itself. Claude Code and Cursor have both shipped fixes for refresh races, so pick that trade-off deliberately.
Open endpoints. Discovery and the token exchange are public by design.
Fetching CIMD documents (Patchy fetching a URL a stranger names), per the current CIMD draft:
The draft sets no timeout, but Claude gives Patchy's endpoints 10 s. Because the clients we check use only three hosts, a trust policy keeps it small: fetch everything, and warn on consent for unknown hosts. Risk (Opus): two open reports say claude.ai's Cloudflare edge challenges server-side fetches of Anthropic's documents from some datacenter addresses. Verify from Patchy's real egress.
Registration: RFC 7591 allows rate-limiting registration and expiring unused registrations. Expire clients that never complete a grant after a short window (Sol suggests seven days), but keep any client that backs a live grant.
The token endpoint: codes and tokens already carry 256 bits; codes last 10 minutes and are single use. Add rate limits, and revoke what a code minted if the code is replayed.
Prototype gaps both lanes found (for the build, not decisions):
/oauth/authorizeredirects some bad requests to the client's registered URI before the person is signed in, and anyone can register a URI through open DCR. OAuth 2.1 and RFC 9700 say the person MUST be authenticated first.localhostas Anthropic asks. Claude Code, Codex and VS Code publish port-less loopback URIs and bind a new port each sign-in; today's match is exact.resourceisn't bound through the exchange. It's checked at authorize, then dropped. Today theuse/workpurpose is what keeps the token to this door.scope="patches"andscopes_supported, anderror="invalid_token"when a bad token was sent./oauth/*, and registrations kept forever.cursor://beside its https and loopback URIs. The lanes differ:HEAD /mcpwith the same 401 (Gemini CLI starts with it), makeredirect_urioptional at the token endpoint, and keepisson every redirect.Never use HTTP 403 for a policy refusal. VS Code treats a 401 or 403 while it holds a token as a reason to throw away its registration and re-register. Claude.ai treats any 403 other than
insufficient_scopeas final. "Agent access is off" stays a tool result over HTTP 200, as in the prototype. With one scope, Patchy never needs step-up.Consent. MCP says the page MUST show the redirect host clearly, and SHOULD warn when every redirect is loopback. The CIMD draft and Anthropic ask to show the
client_idhost rather than trusting the client's name. Any local process can claim Claude Code's id, which matches the map's rule that a client's name is a label, not proof. The consent page's CSP keeps adding the redirect origin per request; a custom scheme such ascursor:would need a scheme source.Dev instances.
127.0.0.1is enough.*.localhostfor every OAuth endpoint, so it can't sign in to a dev instance. The cleaner equivalent, if Gemini matters in dev: advertise the whole client-facing surface onhttp://127.0.0.1:<port>, and have/oauth/authorizethere bounce the browser to the named host where the session cookie lives.For the tickets
workpurposeHEAD /mcp.