Skip to content

[BUG] OAuth token refresh never attempted for custom connectors via mcp-proxy.anthropic.com #228

Description

What happened?

What's Wrong?

Custom MCP connectors connected via the claude.ai web UI (mcp-proxy.anthropic.com) never refresh OAuth tokens when they expire. The proxy reconnects the SSE transport and reports success, but never calls /token or /authorize on the upstream server. The expired token is then forwarded on the next tool call, which fails — requiring a full manual reconnect daily.

Note: This was originally filed as anthropics/claude-code#52905 (labeled duplicate there) and anthropics/claude-code#46328. Re-filing here as the root cause is in the claude.ai proxy layer — anthropics/claude-ai-mcp is the correct home for this bug.


Environment

  • Client: claude.ai web (Team/Enterprise plan)
  • Connector: Custom MCP server on Azure App Service
  • Auth: Azure Entra ID OBO flow (external IdP)
  • Transport: Streamable HTTP

What did you expect to happen?

The proxy should check token expiry before forwarding tool calls and attempt a silent refresh using the stored refresh token before falling back to a re-auth prompt — standard OAuth 2.0 refresh token grant behavior already implemented in the direct HTTP path.

Steps to reproduce

  1. Set up a custom MCP server with Azure Entra ID (external IdP) OAuth — server exposes /.well-known/oauth-authorization-server with correct authorization_endpoint, token_endpoint, and grant_types_supported: ["authorization_code", "refresh_token"]
  2. Add the server as a custom connector in Claude.ai Settings → Connectors
  3. Complete the OAuth flow — connector shows as Connected, tools are available
  4. Wait for the access token to expire (~1 hour)
  5. Attempt any tool call on the connector
  6. Result: Tool call fails — server receives the expired Bearer token with no prior /token refresh attempt. Connector appears disconnected. User must manually reconnect daily.

Area

OAuth / Authentication

MCP Server (if applicable)

Custom server — Azure App Service (Node.js/Express, Streamable HTTP, Azure Entra ID OBO auth)

Error messages or logs

Error in Claude Web UI (Connector page)
Connection issue
Connection has expired. You can reconnect to re-authenticate.


Server logs show zero /token or /authorize requests after initial auth.
On expired token, server returns:
HTTP 401
WWW-Authenticate: Bearer realm="Azure AD", error="invalid_token", error_description="Token validation failed"

Client behavior: SSE transport reconnects successfully but no OAuth refresh is attempted.
Expired token is forwarded on next tool call → tool call fails.

Additional context

Key Observations

  1. Fix exists for direct HTTP path — token refresh was fixed for Claude Code direct HTTP connections in ~v2.1.59. The fix has not been ported to the mcp-proxy.anthropic.com proxy path.

  2. Server is fully spec-compliant/.well-known/oauth-authorization-server correctly advertises token_endpoint and grant_types_supported: ["authorization_code", "refresh_token"]. On expired token, server returns 401 with WWW-Authenticate: Bearer error="invalid_token" — a compliant client should use this to trigger a refresh. Zero /token or /authorize requests reach the server after initial auth.

  3. External IdP compounds the issue — per Claude.ai ignores authorization_endpoint and token_endpoint from OAuth metadata when MCP server uses external authorization server #82, claude.ai ignores authorization_endpoint/token_endpoint from OAuth metadata for external IdPs. This means both initial auth discovery AND token refresh are broken on the proxy path for Entra ID / Okta / Auth0 setups.

  4. First-party connectors unaffected — Slack, Otter etc. remain connected. Bug is specific to custom connectors via mcp-proxy.anthropic.com.


Related Issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions