Skip to content

fix(server): resolve equivalent percent-encoded URIs in SkillCatalog - #3229

Open
xgbtxy wants to merge 1 commit into
modelcontextprotocol:mainfrom
xgbtxy:fix/skills-catalog-uri-key
Open

xgbtxy wants to merge 1 commit into
modelcontextprotocol:mainfrom
xgbtxy:fix/skills-catalog-uri-key

Conversation

@xgbtxy

@xgbtxy xgbtxy commented Nov 23, 2026

Copy link
Copy Markdown

Summary

  • Fixes URI lookup mismatches in SkillCatalog (packages/server/src/ext/skills/catalogSource.ts) when handling resources/read and resources/directory/read.
  • Previously readChecked and readDirectory looked up incoming request URIs via canonicalUri(uri) (which wraps new URL(uri).href), while skill resource entries are normalized with skillFileKey(uri) (packages/core-internal/src/ext/skills/uri.ts).
  • Because canonicalUri does not normalize path percent-encoding against skillFileKey, equivalent valid URIs failed lookup with -32602:
    • percent-encoded unreserved/sub-delim characters such as references/Q%26A.md vs references/Q&A.md
    • lowercase hex escapes such as templates/Rembours%c3%a9.md
    • raw ^ paths returned by new URL() on Node 20/22 (references/x^y.md) vs %5E on Node 24

Changes

  • packages/server/src/ext/skills/catalogSource.ts:
    • Added catalogUriKey(uri) helper that parses the URI via new URL(uri), rejects #fragment or ?query components, and delegates path normalization below ${url.protocol}//${url.host} to skillFileKey().
    • Updated readChecked and readDirectory to resolve entries using catalogUriKey(uri) while keeping get(uri) on canonicalUri(uri).
  • packages/server/test/ext/skills/catalog.test.ts:
    • Added regression test resolves equivalent percent-encodings, lowercase hex, and raw carets in resources/read and resources/directory/read.
  • .changeset/skills-catalog-uri-key.md:
    • Added a patch changeset for @modelcontextprotocol/server.

Verification

Tested on Node v22.21.0:

  • pnpm --filter @modelcontextprotocol/server run typecheck — passed
  • pnpm --filter @modelcontextprotocol/server exec eslint src/ — passed
  • prettier --end-of-line crlf --check .changeset/skills-catalog-uri-key.md packages/server/src/ext/skills/catalogSource.ts packages/server/test/ext/skills/catalog.test.ts — passed
  • pnpm --filter @modelcontextprotocol/server run build — passed
  • pnpm --filter @modelcontextprotocol/server test — 57 files passed, 723 passed | 3 skipped (3 POSIX symlink tests in test/ext/skills/node.test.ts skipped on Windows)
  • pnpm --filter @modelcontextprotocol/test-integration exec vitest run test/skills/ — 2 files passed, 51 passed

SkillCatalog previously normalized resources/read and resources/directory/read
lookup URIs with canonicalUri(uri) (raw new URL(uri).href), while skill resource
entries are indexed by skillFileKey(uri). As a result, equivalent spellings such
as Q%26A.md vs Q&A.md, lowercase hex escapes like Rembours%c3%a9.md, and raw ^
preserved by new URL() on Node 20/22 (vs %5E on Node 24) missed the catalog
lookup and returned -32602.

Add catalogUriKey() in catalogSource.ts to parse and reject query/fragment
components before delegating path normalization to skillFileKey(), keeping
get(uri) on canonicalUri(uri), and add regression coverage in catalog.test.ts
plus a patch changeset for @modelcontextprotocol/server.
@xgbtxy
xgbtxy requested a review from a team as a code owner November 23, 2026 12:09
Copilot AI balanced review requested due to automatic review settings November 23, 2026 12:09
@changeset-bot

changeset-bot Bot commented Nov 23, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 58e67c4

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

This PR includes changesets to release 6 packages
Name Type
@modelcontextprotocol/server Patch
@modelcontextprotocol/client Patch
@modelcontextprotocol/codemod Patch
@modelcontextprotocol/core Patch
@modelcontextprotocol/server-legacy Patch
@modelcontextprotocol/core-internal 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

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/@modelcontextprotocol/client@3229

@modelcontextprotocol/codemod

npm i https://pkg.pr.new/@modelcontextprotocol/codemod@3229

@modelcontextprotocol/core

npm i https://pkg.pr.new/@modelcontextprotocol/core@3229

@modelcontextprotocol/server

npm i https://pkg.pr.new/@modelcontextprotocol/server@3229

@modelcontextprotocol/server-legacy

npm i https://pkg.pr.new/@modelcontextprotocol/server-legacy@3229

@modelcontextprotocol/express

npm i https://pkg.pr.new/@modelcontextprotocol/express@3229

@modelcontextprotocol/fastify

npm i https://pkg.pr.new/@modelcontextprotocol/fastify@3229

@modelcontextprotocol/hono

npm i https://pkg.pr.new/@modelcontextprotocol/hono@3229

@modelcontextprotocol/node

npm i https://pkg.pr.new/@modelcontextprotocol/node@3229

commit: 58e67c4

@claude claude Bot added the v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes label Nov 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v2 Ideas, requests and plans for v2 of the SDK which will incorporate major changes and fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants