Skip to content

feat(core): configure MCP OAuth authorization server metadata - #49126

Merged
rekram1-node merged 4 commits into
v2from
mcp-auth-metadata
Sep 15, 2026
Merged

rekram1-node merged 4 commits into
v2from
mcp-auth-metadata

Conversation

@rekram1-node

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes #44790

Type of change

  • Feature

What does this PR do?

Adds oauth.auth_server_metadata_url to remote MCP server config. Some MCP servers do not publish RFC 9728 protected resource metadata that names their authorization server; without it, discovery falls back to treating the resource host as the issuer and builds an authorization URL that does not exist.

When the field is set, McpOAuth.configuredDiscovery loads that OAuth 2.0 (RFC 8414) or OpenID Connect discovery document, validates it with the SDK schemas, and seeds OAuthDiscoveryState with the document's issuer and the configured MCP URL as the protected resource. This is used in two places:

  • authorize() uses it instead of discoverOAuthServerInfo for the interactive login.
  • provider().discoveryState() loads it lazily, so connect-time token refresh also reaches the right token endpoint.

Servers without the field behave exactly as before.

How did you verify your code works?

  • New test in packages/core/test/mcp-oauth.test.ts: the resource server returns 404 for every path, the configured metadata document lives on a separate issuer host. Asserts the authorization URL lands on the issuer, carries the configured MCP URL as resource, and that a connect-time provider refreshes through the configured issuer's token endpoint.
  • bun test test/mcp-oauth.test.ts in packages/core: 17/17.
  • bun run check from the repo root: 35/35 tasks.
  • Regenerated packages/protocol/openapi.json and packages/client types.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add oauth.auth_server_metadata_url for remote MCP servers that do not
publish protected resource metadata naming their authorization server.
When set, the document is loaded directly and seeds discovery state for
both interactive authorization and connect-time token refresh, so the
SDK does not fall back to treating the resource host as the issuer.

Closes #44790
@rekram1-node
rekram1-node merged commit b693c22 into v2 Sep 15, 2026
7 of 8 checks passed
@rekram1-node
rekram1-node deleted the mcp-auth-metadata branch September 15, 2026 19:52
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