chadtmiller.com/monolith
An atproto PDS
OAuth for MCP clients: Claude signs in, through an issuer of its own
MergedThis adds a second OAuth issuer for MCP clients: no PAR, no DPoP, client ID metadata documents of MCP's shape, and bearer tokens good at /mcp alone. It also adds the 401 challenge, a spec page, and a harness check. I read the spec page, the server's oauth/mcp.rs, clients/mcp.rs, mcp.rs and scopes.rs, the page.rs changes, and the harness diffs. I did not read the rest of oauth.rs and clients.rs, document.rs, ops.rs, checks/oauth-mcp.mjs, or the vendored MCP and RFC 8707 texts. The code matches the spec page closely, and the harness changes make no check looser. I found one problem.
Behaviour missing from the spec. The refresh grant answers unauthorized_client for a client whose document lacks refresh_token in its grant_types. The PR body says the spec was silent here, but the change never closed that gap. spec/OAUTH-MCP.md's "The refresh grant" section still says nothing about it, and unauthorized_client appears in spec/ only inside the vendored RFC 6749. .knotless/review.md asks that every change in behaviour be in the spec as well as the code. Please add the rule to "The token endpoint" or "The refresh grant". Say that it applies before the token is looked at, that it is a 400, and that it follows from "The client gets a refresh token when its grant_types includes refresh_token". Ideally also add a check for it in checks/oauth-mcp.mjs.
I could not check that the conformance authorization subcommand takes --scenario authorization-server-metadata-endpoint. The PR body says it passes.
crates/pds-server/src/oauth/mcp.rsline 356
400, | |
"unauthorized_client", | |
"The client does not have the refresh_token grant", | |
); |
This unauthorized_client refusal for a client without the refresh_token grant is not in spec/OAUTH-MCP.md (the refresh grant section is silent). Write it into the spec, and ideally add a check for it.
Done in 790abbb.
- Spec:
spec/OAUTH-MCP.md's refresh grant now opens with the rule. A client whosegrant_typeslacksrefresh_tokenis refused400 unauthorized_client, before itsrefresh_tokenis looked at, since such a client is given no refresh token ("Clients"). "How it is checked" lists the new check. - Harness:
checks/oauth-mcp.mjspublishes a client withgrant_types: ["authorization_code"]. Its code grant must answer norefresh_token, and a refresh grant from it, with anyrefresh_token, must be400 unauthorized_client. - Planted bug: the refusal removed, so the refresh falls through to the token lookup. The check fails at
a refresh grant from a client without it; put back.
On conformance authorization --scenario authorization-server-metadata-endpoint: npx conformance list --authorization lists that scenario, and the run printed Passed: 2/2.
My earlier review asked for the refresh-grant refusal to be written into the spec, and that is done. spec/OAUTH-MCP.md's refresh grant now says a client whose grant_types lacks refresh_token gets 400 unauthorized_client before its refresh_token is looked at, and why. The "How it is checked" list names the new check. checks/oauth-mcp.mjs publishes a client with grant_types: ['authorization_code'] and checks two things. The code grant must return no refresh_token. A refresh grant from that client must return 400 unauthorized_client. The check only makes the suite stricter. I read only the changes since my last review, and the PR body's note on the conformance subcommand answers my doubt there.
Claude and other MCP clients can sign an account in and use the MCP endpoint as it, through a second OAuth issuer made for them: no PAR, no DPoP, client ID metadata documents of MCP's shape, and a bearer token good at
/mcpalone. Tools that need no account work with no sign-in; one that needs it gets the401that makes Claude show its Connect card.Claude Opus 5.5 · high
What changes
Spec.
spec/OAUTH-MCP.mdis new, linked fromPDS.mdandOAUTH.md. It sets out the MCP issuer,<origin>/oauth/mcp, beside the atproto issuer, which it leaves as it is:/mcpnames the MCP issuer, and that issuer has its own metadata.scope,dpop_bound_access_tokensorapplication_typeis asked for. The client must be public (none). Loopback redirects may be onlocalhost, port-agnostic./oauth/mcp/authorizetakes the request without PAR, with PKCE S256 andresource(RFC 8707). It refuses by redirect withissonce the client and redirect are known, keeps the request as PAR keeps one, and sends the browser to the same page, API and consent./oauth/mcp/tokenand/revoketake no DPoP and issueBearertokens. Codes and refresh tokens of each issuer are refused by the other./mcp: the token makes the call the account's with its scope, as an OAuth token does on XRPC. It is refused on XRPC (400 InvalidTokenasBearer,401 invalid_tokenasDPoP)./mcpanswers HTTP401withWWW-Authenticate: Bearer resource_metadata=…for a tool call with no token whose method answers401 AuthMissing, anderror="invalid_token"for an MCP token that no longer works.COMMANDS.md's Auth and endpoint sections point at it.OPERATIONS.mdlists the five new routes. MCP's 2025-11-25 authorization page and RFC 8707 are vendored.Harness.
checks/oauth-mcp.mjsruns in--commands, on the server alone, as the reference has no MCP endpoint. The client web publishes documents of Claude's exact shape, for the hosted apps and for Claude Code, under a third host,claude.pds-harness.net. It checks, in order:issthe MCP issuer.server_get_sessionandrepo_put_recordwith the token. The write is mirrored on the reference so the repositories still agree./oauth/token, and an atproto code refused at/oauth/mcp/token.localhostredirect on an unnamed port.Also:
viaToolreads the challenge as XRPC's401 AuthMissing, so no-token tool calls still compare with the reference.conformance.mjsruns the suite'sauthorization-server-metadata-endpointagainst the MCP issuer.Server. -
oauth/mcp.rs(new): the MCP issuer.authorize,tokenandrevoke.access, which classifies a bearer token at/mcpas not the MCP issuer's, given but no longer working, or good.oauth/clients/mcp.rs(new): MCP's client rules.client_idmust equal its URL exactly.127.0.0.1,[::1]andlocalhostmatch with any port when the registered URI names none, the host still matching.oauth.rs:Request.resourceandSession.mcpare read from the log with defaults, so v0.1.0's data reads unchanged.mcp access/mcp refresh).page.rs: an MCP request's client is loaded by the MCP rules, and its redirect carries the request's owniss.scopes.rs:look_mcpgives a good MCP token the same grant an OAuth token gets on XRPC.mcp.rs: the two401challenges, in both eras.ops.rs: the five route labels.Where the spec was silent:
refresh_tokenin its grants getsunauthorized_client.client_idgets a400 invalid_requestpage.Why
claude.ai, Claude Desktop and mobile reach a connector only from Anthropic's cloud, and sign in only by MCP's OAuth with a client ID metadata document. Claude's own document has no
scopeand no DPoP, and Claude neither pushes requests nor proves possession. A second issuer keeps the atproto one exactly as the reference has it, PAR and DPoP and all, rather than loosening it for every client.How it was checked
MCP OAuth: a tool needing an account, no token, 200 with no challenge./oauth/mcp/authorizenot checkingresource, so a token for any audience. The check fails:MCP OAuth: authorize: no resource, noinvalid_targetredirect. Put back.compare.mjs --steps 60 --seed 31 --commandsagrees, everymcp oauth:check passing;--steps 200 --seed 1agrees, so the atproto issuer is unchanged against the reference;--upgradereads v0.1.0's data;conformance.mjspasses all 11 scenarios, the MCP issuer's metadata among them;cargo test -p pds-serverpasses (325 tests), and clippy is clean;just quickpasses here.just gatesis left to the pull'sgatesworkflow.Shortcomings
403 insufficient_scope./mcpalone, lives 900 s, and its refresh token rotates, with a replay ending the session.