Skip to content

Fix URI template matching for multi-variable simple expressions#2218

Open
koriyoshi2041 wants to merge 1 commit into
modelcontextprotocol:mainfrom
koriyoshi2041:fix-uri-template-multi-variable-match
Open

Fix URI template matching for multi-variable simple expressions#2218
koriyoshi2041 wants to merge 1 commit into
modelcontextprotocol:mainfrom
koriyoshi2041:fix-uri-template-multi-variable-match

Conversation

@koriyoshi2041
Copy link
Copy Markdown

Summary

Fixes UriTemplate.match() for simple expressions that contain multiple variables, such as /users/{userId,format}.

Previously the matcher generated one capture group for the whole expression and used a pattern that rejected commas, so /users/42,json returned null. This now generates one capture group per variable with literal comma separators.

Fixes #2166.

Testing

  • pnpm --filter @modelcontextprotocol/core test -- packages/core/test/shared/uriTemplate.test.ts
  • pnpm --filter @modelcontextprotocol/core lint
  • pre-push hook: typecheck, build, lint

@koriyoshi2041 koriyoshi2041 requested a review from a team as a code owner May 31, 2026 01:05
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 31, 2026

🦋 Changeset detected

Latest commit: 4c5f78f

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/core Patch

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

@koriyoshi2041 koriyoshi2041 force-pushed the fix-uri-template-multi-variable-match branch from f4c33df to 4c5f78f Compare May 31, 2026 01:06
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 31, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@2218

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/codemod@2218

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@2218

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@2218

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/fastify@2218

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@2218

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@2218

commit: 4c5f78f

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.

UriTemplate.match() returns null for multi-variable path expressions like {userId,format}

1 participant