Skip to content

fix(core): match multi-variable URI template path expressions#2216

Open
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/uri-template-multi-var-path
Open

fix(core): match multi-variable URI template path expressions#2216
he-yufeng wants to merge 1 commit into
modelcontextprotocol:mainfrom
he-yufeng:fix/uri-template-multi-var-path

Conversation

@he-yufeng
Copy link
Copy Markdown

Fixes #2166.

UriTemplate.match() built a single capture group for simple expressions with multiple variable names, so a template like /users/{userId,format} rejected the comma separator and only knew about the first variable. The matcher now emits one capture group per variable for non-exploded simple expressions, separated by literal commas.

This keeps the existing single-variable and exploded matching behavior intact, and adds a regression test for /users/42,json returning both userId and format.

Validation:

  • pnpm --filter @modelcontextprotocol/core test -- test/shared/uriTemplate.test.ts
  • pnpm --filter @modelcontextprotocol/core typecheck
  • pnpm --filter @modelcontextprotocol/core lint
  • pnpm changeset status --since upstream/main
  • pre-push hook: typecheck:all, build:all, lint:all

@he-yufeng he-yufeng requested a review from a team as a code owner May 30, 2026 15:32
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 30, 2026

🦋 Changeset detected

Latest commit: 7f65ae4

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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented May 30, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

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

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 7f65ae4

@he-yufeng
Copy link
Copy Markdown
Author

Rebased this onto current main and reran the focused checks.

Local checks:

  • pnpm --filter @modelcontextprotocol/core test -- uriTemplate.test.ts -> 39 passed
  • pnpm --filter @modelcontextprotocol/core typecheck
  • git diff --check

The branch now contains only the UriTemplate fix, its regression test, and the changeset.

@he-yufeng he-yufeng force-pushed the fix/uri-template-multi-var-path branch from fc61b9b to 7f65ae4 Compare June 4, 2026 21:15
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