[GH-ISSUE #5782] MCP: Custom OIDC configuration is not reflected in oauth-authorization-server endpoint #27674

Closed
opened 2026-04-17 18:49:26 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @n-siddarth on GitHub (Nov 5, 2025).
Original GitHub issue: https://github.com/better-auth/better-auth/issues/5782

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). Original GitHub issue: https://github.com/better-auth/better-auth/issues/5782 ### 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 locked label 2026-04-17 18:49:26 -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

<!-- gh-comment-id:3492727060 --> @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 :)

<!-- gh-comment-id:3688610608 --> @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!

<!-- gh-comment-id:3689987335 --> @n-siddarth commented on GitHub (Dec 24, 2025): Will do, @dvanmali 👍. Great work on that plugin!
Author
Owner

@dosubot[bot] commented on GitHub (Mar 25, 2026):

Hi, @n-siddarth. I'm Dosu, and I'm helping the better-auth team manage their backlog and am marking this issue as stale.

Issue Summary:

  • You reported that custom OIDC metadata passed via the MCP plugin's oidcConfig option was not reflected correctly.
  • The root cause was identified as the plugin passing the entire MCPOptions instead of just the oidcConfig subobject to getProviderMetadata.
  • I suggested a local patch to fix this bug.
  • The maintainer recommended switching to the new OAuth Provider Plugin, which supports full metadata overrides.
  • You responded positively to trying the new OAuth Provider Plugin.

Next Steps:

  • Please confirm if this issue is still relevant with the latest version of better-auth or if the new OAuth Provider Plugin resolved your concerns.
  • If it is still relevant, feel free to comment to keep the discussion open; otherwise, this issue will be automatically closed in 7 days.

Thanks for your understanding and contribution!

<!-- gh-comment-id:4127833362 --> @dosubot[bot] commented on GitHub (Mar 25, 2026): Hi, @n-siddarth. I'm [Dosu](https://dosu.dev), and I'm helping the better-auth team manage their backlog and am marking this issue as stale. **Issue Summary:** - You reported that custom OIDC metadata passed via the MCP plugin's oidcConfig option was not reflected correctly. - The root cause was identified as the plugin passing the entire MCPOptions instead of just the oidcConfig subobject to getProviderMetadata. - I suggested a local patch to fix this bug. - The maintainer recommended switching to the new OAuth Provider Plugin, which supports full metadata overrides. - You responded positively to trying the new OAuth Provider Plugin. **Next Steps:** - Please confirm if this issue is still relevant with the latest version of better-auth or if the new OAuth Provider Plugin resolved your concerns. - If it is still relevant, feel free to comment to keep the discussion open; otherwise, this issue will be automatically closed in 7 days. Thanks for your understanding and contribution!
Author
Owner

@n-siddarth commented on GitHub (Mar 25, 2026):

No longer an issue in latest version of Better Auth with oauthProvider plugin.

<!-- gh-comment-id:4127857314 --> @n-siddarth commented on GitHub (Mar 25, 2026): No longer an issue in latest version of Better Auth with oauthProvider plugin.
Author
Owner

@github-actions[bot] commented on GitHub (Apr 2, 2026):

This issue has been locked as it was closed more than 7 days ago. If you're experiencing a similar problem or you have additional context, please open a new issue and reference this one.

<!-- gh-comment-id:4173718052 --> @github-actions[bot] commented on GitHub (Apr 2, 2026): This issue has been locked as it was closed more than 7 days ago. If you're experiencing a similar problem or you have additional context, please open a new issue and reference this one.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/better-auth#27674