Skip to content

[Server] fix OIDC discovery for issuers with trailing slash - #506

Merged
chr-hertel merged 2 commits into
modelcontextprotocol:mainfrom
karedum:fix/oidc-discovery-trailing-slash
Sep 14, 2026
Merged

chr-hertel merged 2 commits into
modelcontextprotocol:mainfrom
karedum:fix/oidc-discovery-trailing-slash

Conversation

@karedum

@karedum karedum commented Sep 12, 2026

Copy link
Copy Markdown
Contributor

Preserve the original OIDC issuer for issuer validation and use a separate value without the trailing slash when constructing discovery URLs.

Motivation and Context

OidcDiscovery::fetchMetadata() currently removes the trailing slash from the configured issuer before performing discovery. The normalized value is also used for issuer validation.

This causes discovery to fail when the authorization server uses a trailing slash as part of its canonical issuer, such as Authentik.

OpenID Connect Discovery requires a terminating slash to be removed when constructing the discovery URL, while issuer validation must preserve the issuer identifier.

How Has This Been Tested?

Tested against an Authentik OAuth2/OpenID Connect provider whose issuer contains a trailing slash.

The existing test suite also passes locally.

Breaking Changes

None expected. Discovery URLs are constructed as before; the change only preserves the originally configured issuer for exact issuer validation.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@chr-hertel chr-hertel changed the title fix OIDC discovery for issuers with trailing slash [Server] fix OIDC discovery for issuers with trailing slash Sep 14, 2026
@chr-hertel chr-hertel added Server Issues & PRs related to the Server component bug Something isn't working labels Sep 14, 2026
@chr-hertel chr-hertel added the auth Issues and PRs related to Authentication / OAuth label Sep 14, 2026

@chr-hertel chr-hertel left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @karedum!

@chr-hertel
chr-hertel merged commit ef6bee5 into modelcontextprotocol:main Sep 14, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auth Issues and PRs related to Authentication / OAuth bug Something isn't working Server Issues & PRs related to the Server component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants