OAuth for MCP servers:sign-in in ChatGPT and Claude
Updated · 5 min read
When an MCP server's tools act on a user's account, ChatGPT and Claude sign that user in through OAuth 2.1. The specification is shared, but each app has its own requirements, and in a few places they behave in opposite ways. Here is how it works in 2026 and where it most often breaks.
How sign-in works
- The AI app calls the server without a token. The server answers 401 with a WWW-Authenticate header pointing to its resource metadata (resource_metadata).
- The resource metadata (RFC 9728, /.well-known/oauth-protected-resource) says which authorization server issues tokens and which scopes exist.
- The app fetches the authorization server's metadata (RFC 8414 or OpenID Connect discovery) and registers as a client.
- The user signs in on your site and approves access. The app exchanges the code for a token, with PKCE and the resource parameter.
- Every later call carries the token, and the MCP server checks that the token was issued for it specifically.
Client registration: CIMD instead of DCR
Your authorization server has to know ChatGPT and Claude as clients somehow. There are three ways: a manually registered client, a Client ID Metadata Document (CIMD) and Dynamic Client Registration (DCR).
With CIMD the client ID is the URL of a document describing the client, for example https://chatgpt.com/oauth/client.json. The authorization server fetches that document and doesn't have to register anyone. The July 28, 2026 version of the MCP specification marks DCR as deprecated and keeps it only for backwards compatibility. With DCR every new connection creates a new client, so with heavy directory traffic the client list grows fast.
What both require
- PKCE with the S256 method. The authorization server has to advertise it in code_challenge_methods_supported. Without that field a spec-compliant client stops the sign-in.
- The resource parameter (RFC 8707) in the authorization and token requests, set to the MCP server's canonical URL with no trailing slash.
- The MCP server checks the token's audience and rejects tokens issued for other services.
- No token passthrough: the MCP server doesn't send the token from ChatGPT or Claude on to other APIs. It uses its own credentials for calls further down.
- Missing scope: a 403 response with error="insufficient_scope". The app then signs the user in again with the wider scope.
- The iss parameter in the authorization response (RFC 9207), matching the issuer in the metadata. Without it ChatGPT rejects the sign-in.
ChatGPT
- Registration: CIMD first, DCR as a fallback. The ChatGPT client authenticates with no secret (none) or with private_key_jwt.
- Redirect URI: https://chatgpt.com/connector_platform_oauth_redirect. Copy the exact URI for your plugin from its management page.
- If your metadata advertises the openid, email and profile scopes, ChatGPT requests them by default, so they have to be enabled for the client in your identity provider.
- Each tool declares in securitySchemes whether it needs sign-in (oauth2 with scopes) or not (noauth). Both entries together mean sign-in is optional.
- Client credentials, service accounts and API keys aren't supported. Without sign-in, OpenAI recommends exposing read-only tools only.
- ChatGPT connects with an mTLS certificate (mtls.prod.connectors.openai.com) and from published IP ranges, so you can restrict traffic to it.
Claude
- Registration: DCR or CIMD by default. Claude only picks CIMD when the metadata has client_id_metadata_document_supported: true and the none method in token_endpoint_auth_methods_supported.
- Redirect URI: https://claude.ai/api/mcp/auth_callback for claude.ai, the desktop and mobile apps and Cowork. Claude Code uses http://localhost/callback and http://127.0.0.1/callback on any port.
- Claude only uses the first server in authorization_servers and adds offline_access if the authorization server advertises it.
- It refreshes tokens after a 401 and ahead of time, up to 5 minutes before expiry. Return invalid_grant for a dead refresh token.
- Discovery, registration and token endpoints get 10 seconds to answer, refresh gets 30. Traffic comes from 160.79.104.0/21, including to the authorization server.
- A client whose credentials Anthropic holds, or a fixed key in a header, are available on request (mcp-review@anthropic.com) or in beta. More on connectors for SaaS in a separate guide.
Some tools without sign-in
A product search or documentation can work without an account, orders can't. Both apps support that, but they start sign-in in opposite ways.
- ChatGPT: the tool returns a result with isError: true and a _meta["mcp/www_authenticate"] field. ChatGPT then shows a sign-in button.
- Claude: the server has to answer HTTP 401 before the request reaches the MCP SDK. A 200 response with isError doesn't start sign-in.
- If the server has to work in both, handle both cases. Check them first in the MCP Inspector and through a tunnel.
An existing identity provider
You don't have to write an authorization server from scratch. Auth0, Microsoft Entra, Keycloak and Supabase work with MCP, but each has its catches:
- Many providers only publish /.well-known/openid-configuration. That's enough as long as the document includes code_challenge_methods_supported.
- Auth0: DCR is off by default, and for production Auth0 recommends CIMD.
- Microsoft Entra: the MCP server's URL has to be added as an Application ID URI on a verified domain, or the token request fails with AADSTS9010010.
- Keycloak: DCR works, but trusted-host policies restrict anonymous registration, and the token audience needs a mapper.
- If a provider supports neither CIMD, DCR nor the resource parameter, you're left with a manually registered client or a thin layer in front of it.
The most common errors
- A redirect to another host drops the Authorization header and ends in a 401.
- The issuer in the metadata differs from the one in the token or the response.
- The token was issued for the API, not for the MCP server, so the audience doesn't match.
- The token endpoint only accepts JSON, while clients send application/x-www-form-urlencoded.
- A firewall or WAF blocks traffic from OpenAI's or Anthropic's cloud and returns 403 or 429 errors your app never sent.
- A DCR client was deleted on the identity provider's side and ChatGPT gets invalid_client.
- Can I use an API key instead of OAuth?
- Not in ChatGPT: it supports OAuth or no sign-in. In Claude a fixed key in a header, entered once by an organization Owner, is in beta and not available to everyone. For tools that act on a user's account, plan for OAuth.
- CIMD or DCR?
- If your authorization server supports CIMD, choose CIMD: the MCP specification has deprecated DCR, and ChatGPT and Claude both prefer CIMD. Keep DCR as a fallback for clients that don't support CIMD yet.
- Can the MCP server pass the user's token on to my API?
- No. The specification forbids it: the token is issued for the MCP server. The server calls your API with its own credentials, or exchanges the token for a new one issued for the API, and keeps enforcing the user's permissions.
- MCP integration: your ERP, store and CRM in ChatGPT and Claude
- Aesthetic clinic websites in Poland
- Online booking for a private clinic
- An AI assistant for your clinic: what's allowed in 2026
- ChatGPT product feed: get your products into ChatGPT shopping
- Clinic advertising in Poland: what a website may say
- Your clinic in ChatGPT and Google
- Patients from abroad: a medical tourism website
- Claude connectors: what they are and how to add one
- MCP servers in ChatGPT: how to connect one
- How to connect WooCommerce to ChatGPT in 2026
- MCP Apps: interface in ChatGPT and Claude
- MCP server security: what to check before launch
- How to test an MCP server in ChatGPT and Claude
- MCP server or API? When you need both
- Hiring a software studio in Poland
- Your Shopify or WooCommerce store in ChatGPT
- What is an MCP server? Explained for online stores
- Claude connector for SaaS: what it takes
- How to sell in ChatGPT in 2026
- MCP server, ChatGPT plugin or Claude connector?
- How to get listed in ChatGPT and Claude
Need an MCP server with sign-in?
MCP servers