Skip to content

Conversation

@mgyarmathy
Copy link
Contributor

This PR addresses several limitations of the current UriTemplate#match implementation:

  • template matching fails when optional query parameters are not provided
  • template matching fails when query parameters are provided out of order from the sequence specified in the template
  • template matching does not decode uri-encoded query parameters

Omitted query parameters are parsed as an empty string per guidance of RFC 6570 Section 2.3.

Motivation and Context

Fixes #1079
Fixes #149

How Has This Been Tested?

New test additions cover all of the cases mentioned in #1079 and #149 as well as a few additional potential edge cases I could come up with.

Breaking Changes

n/a

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

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

Additional context

@mgyarmathy mgyarmathy requested a review from a team as a code owner January 16, 2026 18:48
@changeset-bot
Copy link

changeset-bot bot commented Jan 16, 2026

⚠️ No Changeset found

Latest commit: a6509f6

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jan 16, 2026

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/server

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

@modelcontextprotocol/express

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: a6509f6

@mgyarmathy
Copy link
Contributor Author

v1.x patch for this bugfix is here: #1083

@mgyarmathy mgyarmathy force-pushed the 1079-v2-uritemplate-query-params branch from 316f4c2 to a6509f6 Compare January 16, 2026 19:03
@mgyarmathy mgyarmathy changed the title fix: Update UriTemplate implementation to handle optional/omitted, out-of-order, and encoded query parameters [v2] fix: Update UriTemplate implementation to handle optional/omitted, out-of-order, and encoded query parameters Jan 16, 2026
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.

# MCP SDK ResourceTemplate URI Validation Issue: RFC 6570 Template Matching Behavior Unordered and partial query parameter matching

1 participant