fix: add OAuth discovery endpoints so claude.ai connector can complete handshake #2
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
claude.ai's custom connector flow now sends discovery requests to
/.well-known/oauth-protected-resourceand/.well-known/oauth-authorization-serverbefore attempting the MCPinitializehandshake. Both currently return 404, causing the connector to fail with "Couldn't reach the MCP server" before any MCP traffic is sent.This is a claude.ai-side behaviour change — the connector was working previously without these endpoints. oauth2-proxy is not the fix; it was deliberately removed because Anthropic's backend performs server-to-server calls that cannot follow browser OAuth redirects.
The correct fix is to implement the OAuth protected resource metadata endpoint (RFC 9728 / MCP spec 2025-06-18) returning an empty
authorization_serversarray, which signals to claude.ai that the resource exists but requires no OAuth.Verified via:
Task
Add two well-known discovery endpoint handlers to
main.goand add aHEADhandler toserver.gothat returns the requiredMCP-Protocol-Versionheader.Implementation
1.
main.go— add well-known routesRegister before the MCP handler:
The empty
authorization_serversarray in the protected-resource response is the signal to clients that this resource requires no OAuth. The authorization-server endpoint returning 404 is consistent with that — there is no AS.2.
internal/mcp/server.go— add HEAD handlerclaude.ai also sends
HEAD /mcpto discover the protocol version beforeinitialize. Currently returns 405. Add toServeHTTP:3. Verify after deploy
Acceptance criteria
GET /.well-known/oauth-protected-resourcereturns 200 with valid JSON containingauthorization_servers: []HEAD /mcpreturns 200 withMCP-Protocol-Version: 2025-06-18headerPOST /mcpinitialize handshake continues to work as beforeBranch
fix/oauth-discovery-endpointsfrommainNotes
resourcefield in the protected-resource response must match the public URL exactly.Created via git-mcp on behalf of @mathiasbq