Repository navigation
fix(client): accept a protected resource that differs only by a trailing slash - #3042
Open
AmineBenzaazaa wants to merge 1 commit into
Open
AmineBenzaazaa wants to merge 1 commit into
AmineBenzaazaa wants to merge 1 commit into
Conversation
…ing slash checkResourceAllowed returned false early when the requested path was shorter than the configured one, so a server at https://host/mcp whose protected resource metadata advertises https://host/mcp/ failed auth(), while the reverse case passed. The prefix check below already normalises both paths to a trailing slash, so drop the early return. Fixes modelcontextprotocol#3041 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🦋 Changeset detectedLatest commit: 91cf8df The changes in this PR will be included in the next version bump. This PR includes changesets to release 6 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
@modelcontextprotocol/client
@modelcontextprotocol/codemod
@modelcontextprotocol/core
@modelcontextprotocol/server
@modelcontextprotocol/server-legacy
@modelcontextprotocol/express
@modelcontextprotocol/fastify
@modelcontextprotocol/hono
@modelcontextprotocol/node
commit: |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
checkResourceAllowedreturnedfalseearly when the requested path was shorter than the configured one. A client pointed athttps://host/mcptherefore failedauth()against a server whose protected resource metadata advertiseshttps://host/mcp/, while the reverse case passed. The prefix check right below already normalises both paths to a trailing slash, so the early return was only adding the asymmetry.Fixes #3041
What changed
packages/core-internal/src/shared/authUtils.ts: removed the length early-return and noted in the doc comment that a single trailing slash is not significant.packages/core-internal/test/shared/authUtils.test.ts: the trailing-slash test now expects a match in both directions. A new test checks that a shorter, different path is still rejected (/foldervs/folder/sub/,/vs/mcp/,/mcvs/mcp/).How Has This Been Tested?
The updated test fails on
main(expected false to be true) and passes with the change.core-internal(1526 tests) andclient(998 tests) pass, andtypecheckandlintare clean.Breaking Changes
None. Only previously rejected
/xvs/x/pairs are now accepted; origin and path-prefix checks are unchanged.Types of changes
🤖 Generated with Claude Code