Skip to content

fix(private-server): return 404 for /.well-known/ OAuth discovery#274

Merged
passcod merged 1 commit into
mainfrom
mcp-oauth-discovery
Jun 25, 2026
Merged

fix(private-server): return 404 for /.well-known/ OAuth discovery#274
passcod merged 1 commit into
mainfrom
mcp-oauth-discovery

Conversation

@passcod

@passcod passcod commented Jun 25, 2026

Copy link
Copy Markdown
Member

🤖 Follow-up to #273. With the Host check fixed, the MCP endpoint's initialize returns 200, but Claude Code still reports needs authentication / SDK auth failed: Failed to parse JSON.

Cause

MCP clients probe /.well-known/oauth-protected-resource (and friends) to discover OAuth. The SPA fallback answered those with 200 text/html (the React index.html), so the client tried to JSON.parse HTML and failed — surfacing as "needs authentication".

Verified against the live deployment:

$ curl -i https://canopy.<tailnet>.ts.net/.well-known/oauth-protected-resource
HTTP/2 200
content-type: text/html; charset=utf-8
<!doctype html> ...

Fix

Serve 404 for /.well-known/ paths instead of the SPA. Per the MCP auth spec a 404 on the protected-resource metadata means "not an OAuth-protected resource", so the client connects with the ambient identity — which here is injected by the Tailscale ingress.

Adds a regression test asserting the OAuth discovery paths return 404.

MCP clients (Claude Code) probe /.well-known/oauth-protected-resource to
discover OAuth. The SPA fallback answered 200 text/html (index.html), which
the client fails to parse as JSON and reports as 'needs authentication /
SDK auth failed: Failed to parse JSON'. Serve 404 for /.well-known/ so the
client concludes there's no OAuth and connects with the ambient Tailscale
identity instead.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@passcod passcod merged commit 6c02885 into main Jun 25, 2026
7 checks passed
@passcod passcod deleted the mcp-oauth-discovery branch June 25, 2026 04:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant