fix(auth): accept /mcp alias as OAuth audience

Merged
SA
4mo ago
+7-1

First step toward making api.superset.sh/mcp the canonical MCP URL (de-versioning the v2 path).

/mcp re-exports the v2 MCP handler and marketing llms.txt already advertises it as an alias — but it was missing from validAudiences (token issuance) and from the mcp-v2 verifier's audience list. An OAuth client that used the alias as its RFC 8707 resource got working discovery, a successful consent flow, and then every token rejected.

  • packages/auth: add ${API_URL}/mcp to validAudiences
  • packages/mcp-v2: add it to the verification audience list

The remaining canonical-URL flip (docs, .well-known, server card, openapi advertising /mcp first; /api/v2/agent/mcp kept forever as legacy alias) rides with the A3 transport-hygiene PR. Both URLs become declared OAuth resources in the B2 protected-resources migration, which removes these duplicated lists entirely.

Note: may need a trivial conflict resolution with #6077, which removes the adjacent v1 audience line.

Verify: OAuth flow with resource https://api.superset.sh/mcp issues tokens that pass tool calls on both URLs.

https://claude.ai/code/session_01Kub4p3Eim9pc1qaRRmGea2


Open in Stage

Summary by cubic

Accept /mcp as a valid OAuth audience so clients using the alias get tokens that verify with the v2 MCP handler. Adds ${API_URL}/mcp to both issuance and verification audience lists.

  • Bug Fixes
    • packages/auth: add ${API_URL}/mcp to validAudiences.
    • packages/mcp-v2: add ${API_URL}/mcp to JWT verification audiences.

Summary by CodeRabbit

  • Bug Fixes
    • Improved OAuth authentication compatibility for MCP requests by accepting the MCP API endpoint as a valid token audience.
    • Prevented valid access tokens from being rejected when issued for the MCP endpoint.