pi signs in with a Client ID Metadata Document on pi.dev, and switches to a per-server document when the authorization server sends no iss
Kind: idiosyncrasy · Status: current · Last verified: 2026-11-27 · Clients: pi, openai-codex · Revisions: 2025-11-25
pi picks how to identify itself to an authorization server in this order:
- A
clientIdin the server'soauthblock, with an optionalclientSecret. - A client it registered earlier, kept in
mcp-auth.jsonwhile its redirect URI still matches and until the user signs out. - Its Client ID Metadata Document, when the authorization server's metadata has
client_id_metadata_document_supportedand listsnoneintoken_endpoint_auth_methods_supported. - Dynamic client registration, with
client_namepi.
Step 3 is skipped in the default auto mode when the entry sets oauth.clientName, or when the callback is not /callback on localhost or 127.0.0.1, because pi's documents list only those redirect URIs. oauth.clientRegistration forces the choice: dcr always registers, and cimd fails the sign-in when the server does not support documents for public clients. A document used as the client is not written to the store.
Two documents
When the authorization server advertises authorization_response_iss_parameter_supported, the client id is https://pi.dev/oauth/client.json and the redirect URI is the loopback one, http://127.0.0.1:<port>/callback. At the code exchange pi compares the iss parameter of the response with the metadata issuer and refuses a mismatch.
When the server does not advertise it, pi uses https://pi.dev/oauth/<id>/client.json with the redirect URI http://127.0.0.1:<port>/callback/<id>. The id is the first nine bytes of the SHA-256 of the MCP server URL without its fragment, in base64url, which is twelve characters. The loopback server listens on both paths and rejects a response that arrives on a path other than the one the pending sign-in expects. The source comment cites RFC 9700 section 4.4.2.2 and says the id is computed the way Codex computes its own.
https://pi.dev/oauth/client.json answered 200 on 2026-11-16 with token_endpoint_auth_method none and the redirect URIs http://127.0.0.1/callback and http://localhost/callback. A per-server document was not fetched.
History and limits
The document was opt-in from v1.0.1 (1499466d, 2026-10-02) and became the preferred method in v1.5.0 (908aa7b7, 2026-10-30). A build whose app name is not pi registers dynamically in auto mode, so a rebranded build does not present pi's documents.
pi's conformance baseline lists auth/basic-cimd as failing the cimd-client-id-used check. The suite expects its own document URL, and pi sends the pi.dev one.
The registry records Codex as preferring a document under chatgpt.com, keyed by a callback id or shared when the server advertises authorization_response_iss_parameter_supported, and Kilo Code as offering one document URL for every server.
Sources
- packages/mcp/src/oauth/client-settings.ts, offersClientMetadataDocument, clientMetadataDocument and callbackId, commit
cdf74062,packages/mcp/src/oauth/client-settings.ts, 2026-11-27 - packages/mcp/src/oauth/flow.ts, runFlow, where a stored client wins and the iss parameter is checked, commit
cdf74062,packages/mcp/src/oauth/flow.ts:runFlow, 2026-11-27 - packages/coding-agent/src/extensions/mcp/oauth.ts, pi's documents and the rebranded-build rule, commit
cdf74062,packages/coding-agent/src/extensions/mcp/oauth.ts, 2026-11-27 - packages/coding-agent/src/core/mcp-servers.ts, isClientMetadataDocumentCallback, commit
cdf74062,packages/coding-agent/src/core/mcp-servers.ts:isClientMetadataDocumentCallback, 2026-11-27 - packages/mcp/src/oauth/loopback.ts, the extra callback path the loopback server listens on, commit
cdf74062,packages/mcp/src/oauth/loopback.ts:listenForLoopbackSignIn, 2026-11-27 - packages/coding-agent/docs/mcp.md, Authenticate with OAuth, commit
cdf74062,packages/coding-agent/docs/mcp.md:Authenticate with OAuth, 2026-11-27 - feat(coding-agent) prefer the client ID metadata document for MCP OAuth, first released in v1.5.0, commit
908aa7b7, 2026-11-16 - pi's Client ID Metadata Document as served on 2026-11-16, 2026-11-16