MCP Shipyard
← Guides

Works in Inspector, fails in Claude

Why an MCP server that passes MCP Inspector fails as a Claude connector, and a diagnostic order that finds the cause in minutes.

debugginginspectorclaudetroubleshootingoauthwaf

You run MCP Inspector against your server and everything works: initialize, tools/list, a tool call. You add it to Claude and get "Couldn't reach the MCP server", "Authorization with the MCP server failed" or "Unexpected error while invoking tool". Your server logs show nothing useful, and sometimes nothing at all.

The gap is structural. Inspector runs on your machine, from your network, with your DNS. Claude's connector runs on Anthropic's infrastructure, over the public internet, from a published IP range, with a strict OAuth client. Most causes below are in Anthropic's troubleshooting guide, authentication docs and testing guide. A few come from our own experience shipping commercial MCP servers through Claude and ChatGPT review.

Read the symptom first

MessageUsually means
Couldn't reach the MCP serverDNS, network, WAF, a redirect, or OAuth discovery
Authorization with the MCP server failedThe OAuth flow started and broke: issuer, audience, PKCE, latency, redirect
Unexpected error while invoking toolConnected and signed in, but the tool returned an error

Anthropic says the first message is not always a network failure, despite the wording. When a connection or sign-in fails on claude.ai, the error URL contains a reference ID starting with ofid_. Copy it. If you end up filing an issue on the anthropics/claude-ai-mcp tracker, include it, your server URL and the timestamps from your logs. The ID is time-limited, so report soon after the failure.

The diagnostic order

Work top to bottom. The list follows the order Claude meets problems.

1. DNS: does the hostname resolve to a public IPv4 address

Before any request, Claude resolves your hostname and rejects it if any address is not globally routable. That means private ranges (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16), carrier-grade NAT (100.64.0.0/10), loopback and link-local addresses, and any mix of public and non-public answers. Connectors are IPv4-only, so a hostname with only AAAA records fails. The request never leaves Anthropic, so your access logs show nothing.

dig +short your-server.example.com   # run from outside your network

This explains "works in Claude Code or curl, not claude.ai": your machine and Anthropic resolve differently. Split-horizon DNS, dynamic DNS and VPN-only hostnames are the usual causes.

2. Reachability from the public internet

curl -i https://your-server.example.com/mcp

A 401 or 405 is fine. A timeout or refusal is not. Test from a network that is not yours, or from a cloud shell.

3. Redirects

curl -sI https://your-server.example.com/mcp

If this returns a 301, 302, 307 or 308 to a different host, such as apex to www, regional routing or a vanity domain in front of a CDN, register the final URL. Claude follows the redirect, drops the Authorization header as standard HTTP clients do, the target returns 401, and the failure surfaces later as an authorization error. Anthropic's docs call this out as the common cause of "works in Inspector or Claude Code, not claude.ai", because local clients fail fast on a redirect and claude.ai fails late.

4. WAF, CDN and bot rules

Look for 403 and 429 responses in your edge logs that your application did not generate, especially during a Connect attempt. Anthropic's docs say to allowlist its published egress range or exempt your MCP and OAuth paths from the blocking rule. They list the outbound range as 160.79.104.0/21.

The same rule applies to your authorization server, which can be on another host behind another WAF. Claude's discovery requests to it come from the same range. This is the most common surprise when the MCP server is fine and the identity provider is not.

5. OAuth discovery

If your server requires auth, check what an unauthenticated client sees.

curl -i https://your-server.example.com/mcp                                    # 401, with resource_metadata
curl -i https://your-server.example.com/.well-known/oauth-protected-resource   # 200 JSON
curl -i https://auth.example.com/.well-known/openid-configuration              # or oauth-authorization-server

What breaks discovery:

  • The 401 has no WWW-Authenticate header, and /.well-known/* returns 404 on your origin. Claude has nowhere to look. A telltale sign: your MCP server saw the first request and your authorization server saw nothing.
  • You return the challenge on a 200. Claude ignores it.
  • A proxy or hosting platform renames the header or returns 403 on /.well-known/. Test the deployed edge from a public network, not from inside your platform.
  • Claude falls back to your MCP origin as the authorization server and opens /authorize on a host that has no such page. This happens when it cannot read PRM.
  • authorization_servers lists several issuers. Claude uses the first and does not fall back.
  • PRM resource does not match the URL as the user typed it.
  • The authorization server offers no way to get a client ID: no registration_endpoint, no client_id_metadata_document_supported: true.

Inspector in its default flow is more forgiving about some of these, or you may have hand-fed it a client ID. Full details are in MCP OAuth for Claude and ChatGPT.

6. The authorization flow itself

Once discovery works, an "Authorization failed" error comes from one of these:

  • Issuer mismatch. The issuer in your metadata must match the issuer that signs your tokens.
  • Audience mismatch. Claude sends resource set to the canonical MCP URL (lowercase scheme and host, no trailing slash, no fragment, no default port). Tokens need that audience, and your server should accept the canonical value instead of doing a strict string comparison to what was typed.
  • No S256 PKCE. Claude sends code_challenge_method=S256 on every request. Your metadata should list it in code_challenge_methods_supported.
  • JSON-only token endpoint. Claude posts application/x-www-form-urlencoded. A 415 Unsupported Media Type means your framework only parses JSON for that route.
  • Slow endpoints. Claude waits 10 seconds for discovery, registration and token responses, and 30 for refresh. A gateway that buffers the response counts against you.
  • Refresh errors. Return invalid_grant for dead refresh tokens, and rotate refresh tokens for public clients.
  • Entra ID. AADSTS9010010 means the MCP URL is not registered as an Application ID URI on the API app registration.

7. Initialize timeouts

Anthropic lists three causes of an initialize timeout: slow OAuth endpoints, an overly strict Origin header check that rejects Anthropic's requests, and a firewall dropping its egress. If you validate Origin for DNS rebinding protection, allow what Claude sends, and test by connecting for real rather than by reasoning about it.

8. Tools: connected, then a tool fails

"Unexpected error while invoking tool" means Claude's call reached your server and your server returned an error. There is no ofid_ ID for it. Compare the same call in Inspector with the same arguments and the same account, then check server logs for the handler error. Two things differ between your Inspector run and Claude's call:

  • The account. You tested as an admin with data. A real user, or Anthropic's reviewer, has a different account state.
  • The arguments. The model fills optional parameters, guesses formats and sends values your happy path never saw. Return a specific error message as a tool result with isError: true so the model can fix its next call, and so reviewers do not see a bare "Internal Server Error".

9. Testing through a tunnel

Claude cannot reach localhost, so people test with Cloudflare Tunnel or ngrok. If you use the TypeScript SDK's createMcpExpressApp(), its DNS rebinding protection accepts only localhost, 127.0.0.1 and [::1] in the Host header. The tunnel hostname produces 403 Invalid Host: <hostname> unless you pass it in allowedHosts.

const app = createMcpExpressApp({ allowedHosts: ['localhost', '127.0.0.1', 'abc123.example.com'] });

Keep auth on while the tunnel is up and shut it down afterward. For ChatGPT submission, OpenAI says temporary tunnels and local endpoints do not qualify as the production endpoint.

Check what the connector sees

Once connected, open the connector's page in Claude and look under Tool permissions. Every tool should be listed with the name and description you wrote, because that is what the model reads. A tool missing from that list, or showing an old description, means Claude has a stale view of tools/list. Then run a real conversation that needs each tool and approve the call.

Do not branch behavior on clientInfo. Anthropic's docs say the name and version vary across surfaces (you might see claude-ai, Anthropic or claude-code), and the field is unauthenticated, so use it for telemetry only.

A short checklist

  • Public A record, no AAAA-only, no private addresses
  • No redirect on the registered MCP URL
  • WAF allows the client's range on the MCP host and on the identity provider
  • 401 plus resource_metadata, PRM resource equals the URL
  • Primary issuer is first in authorization_servers
  • S256 advertised, a registration path exists
  • Token endpoint accepts form encoding and answers in under 10 seconds
  • Audience check accepts the canonical URL
  • Tool errors are specific and returned as results

Check your server

Run the free scan at /scan. It makes the same unauthenticated requests a client makes (the 401, the metadata, the handshake) from outside your network, so it sees the public side of your server.

Check your server against these rules

Scan runs the checks from this guide against a live URL and lists each failing rule with its fix.

Scan a server