Skip to content

fix(server): return Invalid Params for malformed resource URIs#2451

Merged
felixweinberger merged 1 commit into
mainfrom
fix/resource-uri-invalid-params
Jul 7, 2026
Merged

fix(server): return Invalid Params for malformed resource URIs#2451
felixweinberger merged 1 commit into
mainfrom
fix/resource-uri-invalid-params

Conversation

@mattzcarey

Copy link
Copy Markdown
Contributor

Previously unaddressed

#2333 correctly returns -32602 with data.uri for a valid but unknown resource URI. A syntactically malformed URI still throws from new URL() and falls through the generic handler-error path.

This PR

Convert that parse failure to Invalid Params with the exact request value and a distinct data shape:

{ "uri": "...", "reason": "invalid_uri" }

The extra reason keeps this distinguishable from ResourceNotFoundError's exact { uri } shape.

Verification

  • integration resource/server suite: 120 tests
  • pnpm check:all
  • pnpm build:all

Follow-up to #2267, #2333, and #2286.

@mattzcarey mattzcarey requested a review from a team as a code owner July 7, 2026 11:11
@changeset-bot

changeset-bot Bot commented Jul 7, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 6ae0e98

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

This PR includes changesets to release 1 package
Name Type
@modelcontextprotocol/server 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

pkg-pr-new Bot commented Jul 7, 2026

Copy link
Copy Markdown

Open in StackBlitz

@modelcontextprotocol/client

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

@modelcontextprotocol/codemod

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

@modelcontextprotocol/core

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

@modelcontextprotocol/server

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

@modelcontextprotocol/server-legacy

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

@modelcontextprotocol/express

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

@modelcontextprotocol/fastify

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

@modelcontextprotocol/hono

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

@modelcontextprotocol/node

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

commit: 6ae0e98

@felixweinberger felixweinberger merged commit 7e69735 into main Jul 7, 2026
19 checks passed
@felixweinberger felixweinberger deleted the fix/resource-uri-invalid-params branch July 7, 2026 12:48
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.

2 participants