MCP: Custom OIDC configuration is not reflected in oauth-authorization-server endpoint #2265

Open
opened 2026-03-13 09:39:40 -05:00 by GiteaMirror · 3 comments
Owner

Originally created by @n-siddarth on GitHub (Nov 5, 2025).

Is this suited for github?

  • Yes, this is suited for github

To Reproduce

  1. Pass custom metadata to oidcConfig option in mcp plugin. For example, changing jwks_uri to custom uri
  2. Fetch .../auth/.well-known/oauth-authorization-server metadata
  3. Custom config is not reflected

Current vs. Expected behavior

We expect custom OIDC metadata configurations to be reflected in the mcp provider metadata route, but this is not the case. The mcp plugin passes the MCPOptions instead of the OIDCOptions that getProviderMetadata() expects.

What version of Better Auth are you using?

1.3.34

System info

{
  "system": {
    "platform": "darwin",
    "arch": "arm64",
    "version": "Darwin Kernel Version 25.0.0: Wed Sep 17 21:35:32 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6020",
    "release": "25.0.0",
    "cpuCount": 12,
    "cpuModel": "Apple M2 Pro",
    "totalMemory": "32.00 GB",
    "freeMemory": "0.40 GB"
  },
  "node": {
    "version": "v24.10.0",
    "env": "development"
  },
  "packageManager": {
    "name": "pnpm",
    "version": "10.18.3"
  },
  "frameworks": [],
  "databases": null,
  "betterAuth": {
    "version": "1.3.34",
    "config": null
  }
}

Which area(s) are affected? (Select all that apply)

Package

Auth config (if applicable)

import { betterAuth } from "better-auth"
import { mcp } from "better-auth/plugins"

export const auth = betterAuth({
  plugins: [
    mcp({
      oidcConfig: {
        metadata: {
          // Custom metadata
        },
        ...
      },
      ...
    })
  ],
  ...
});

Additional context

N/A

Originally created by @n-siddarth on GitHub (Nov 5, 2025). ### Is this suited for github? - [x] Yes, this is suited for github ### To Reproduce 1. Pass custom metadata to `oidcConfig` option in `mcp` plugin. For example, changing `jwks_uri` to custom uri 2. Fetch `.../auth/.well-known/oauth-authorization-server` metadata 3. Custom config is not reflected ### Current vs. Expected behavior We expect custom OIDC metadata configurations to be reflected in the mcp provider metadata route, but this is not the case. The mcp plugin passes the `MCPOptions` instead of the `OIDCOptions` that `getProviderMetadata()` expects. ### What version of Better Auth are you using? 1.3.34 ### System info ```bash { "system": { "platform": "darwin", "arch": "arm64", "version": "Darwin Kernel Version 25.0.0: Wed Sep 17 21:35:32 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T6020", "release": "25.0.0", "cpuCount": 12, "cpuModel": "Apple M2 Pro", "totalMemory": "32.00 GB", "freeMemory": "0.40 GB" }, "node": { "version": "v24.10.0", "env": "development" }, "packageManager": { "name": "pnpm", "version": "10.18.3" }, "frameworks": [], "databases": null, "betterAuth": { "version": "1.3.34", "config": null } } ``` ### Which area(s) are affected? (Select all that apply) Package ### Auth config (if applicable) ```typescript import { betterAuth } from "better-auth" import { mcp } from "better-auth/plugins" export const auth = betterAuth({ plugins: [ mcp({ oidcConfig: { metadata: { // Custom metadata }, ... }, ... }) ], ... }); ``` ### Additional context N/A
GiteaMirror added the plugin label 2026-03-13 09:39:40 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Nov 5, 2025):

Hi @SiddarthNarayanan01! I'm Dosu and I’m helping the better-auth team.

This is a confirmed bug in the MCP plugin: the endpoint for /.well-known/oauth-authorization-server passes the entire MCPOptions object to getMCPProviderMetadata, but that function expects only the OIDCOptions (specifically, the oidcConfig part). As a result, custom metadata like your jwks_uri is not reflected in the discovery endpoint response.

To work around this, you can patch your local copy of the MCP plugin (or monkey-patch at runtime) so that the endpoint handler calls:

const metadata = getMCPProviderMetadata(c, options.oidcConfig);

instead of:

const metadata = getMCPProviderMetadata(c, options);

This will ensure your custom OIDC metadata is merged and reflected as expected in the endpoint response. The underlying cause is a type mismatch and missing extraction of the oidcConfig subobject when generating the metadata. See the relevant code and explanation here.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other  Chat with Dosu Join Discord Share on X

@dosubot[bot] commented on GitHub (Nov 5, 2025): <!-- Greeting --> Hi @SiddarthNarayanan01! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the better-auth team. <!-- Answer --> This is a confirmed bug in the MCP plugin: the endpoint for `/.well-known/oauth-authorization-server` passes the entire MCPOptions object to `getMCPProviderMetadata`, but that function expects only the OIDCOptions (specifically, the `oidcConfig` part). As a result, custom metadata like your `jwks_uri` is not reflected in the discovery endpoint response. To work around this, you can patch your local copy of the MCP plugin (or monkey-patch at runtime) so that the endpoint handler calls: ```js const metadata = getMCPProviderMetadata(c, options.oidcConfig); ``` instead of: ```js const metadata = getMCPProviderMetadata(c, options); ``` This will ensure your custom OIDC metadata is merged and reflected as expected in the endpoint response. The underlying cause is a type mismatch and missing extraction of the `oidcConfig` subobject when generating the metadata. See the relevant code and explanation [here](https://github.com/better-auth/better-auth/blob/7e6106707539ec9a8510c02cc84ac2e9c2d88db0/packages/better-auth/src/plugins/mcp/index.ts#L29-L192). <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/0ca33f04-017a-4970-86cf-2c93e64085ff?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/0ca33f04-017a-4970-86cf-2c93e64085ff?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/0ca33f04-017a-4970-86cf-2c93e64085ff?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/0ca33f04-017a-4970-86cf-2c93e64085ff?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/0ca33f04-017a-4970-86cf-2c93e64085ff?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/0ca33f04-017a-4970-86cf-2c93e64085ff?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/0ca33f04-017a-4970-86cf-2c93e64085ff?feedback_type=other)</sup>&nbsp;&nbsp;[![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/cdda13d9-dd27-4d31-b09a-5d8bec92de21/ask?utm_source=github)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/better-auth/better-auth/issues/5782)
Author
Owner

@dvanmali commented on GitHub (Dec 24, 2025):

Hi @n-siddarth, we released the new OAuth Provider Plugin which allows overrides on all resource metadata through getProtectedResourceMetadata. Feel free to let us know how it works :)

@dvanmali commented on GitHub (Dec 24, 2025): Hi @n-siddarth, we released the new [OAuth Provider Plugin](https://www.better-auth.com/docs/plugins/oauth-provider) which allows overrides on all resource metadata through `getProtectedResourceMetadata`. Feel free to let us know how it works :)
Author
Owner

@n-siddarth commented on GitHub (Dec 24, 2025):

Will do, @dvanmali 👍. Great work on that plugin!

@n-siddarth commented on GitHub (Dec 24, 2025): Will do, @dvanmali 👍. Great work on that plugin!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#2265