Skip to content

fix(server)!: return INVALID_PARAMS for unknown resources - #1172

Merged
devcrocod merged 2 commits into
mainfrom
devcrocod/sep-2164-resource-not-found
Nov 12, 2026
Merged

devcrocod merged 2 commits into
mainfrom
devcrocod/sep-2164-resource-not-found

Conversation

@devcrocod

Copy link
Copy Markdown
Contributor

Per SEP-2164, resources/read for an unknown URI now fails with -32602 (Invalid Params) instead of -32002, on every protocol version. The error data still carries the uri.

Breaking Changes

Client.readResource for a missing resource throws McpException with INVALID_PARAMS instead of RESOURCE_NOT_FOUND. Clients matching on -32002 should also accept -32602.

Closes #805

Copilot AI balanced review requested due to automatic review settings November 10, 2026 16:57

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues block the unknown-resource error-code update.

No open issues 🎉

What changed in this PR

Updates the SDK server’s unknown-resource error handling for SEP-2164. Missing-resource reads now return INVALID_PARAMS (-32602) instead of RESOURCE_NOT_FOUND (-32002) across all protocol versions, while preserving the URI in error data.

Changes:

  • Changes the error code returned when no resource or resource template matches.
  • Updates integration tests for missing resources and unmatched templates, retaining message and URI assertions.
  • Introduces a breaking change for clients that match only on -32002.
File Description
kotlin-sdk-server/​src/​commonMain/​kotlin/​io/​modelcontextprotocol/​kotlin/​sdk/​server/​Server.kt Returns INVALID_PARAMS for unknown resource URIs.
integration-test/​src/​jvmTest/​kotlin/​io/​modelcontextprotocol/​kotlin/​sdk/​server/​ServerResourceTemplateTest.kt Updates the unmatched-template test name and expected error code.
integration-test/​src/​jvmTest/​kotlin/​io/​modelcontextprotocol/​kotlin/​sdk/​server/​ServerFeaturesInvocationTest.kt Updates the missing-resource error assertion.

Review effort: Balanced

@devcrocod
devcrocod requested a review from e5l November 10, 2026 17:11

@e5l e5l left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm

Copilot AI balanced review requested due to automatic review settings November 12, 2026 13:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The missing-resource error-code update has no active review issues.

No open issues 🎉

Review effort: Balanced

@devcrocod
devcrocod merged commit 70ad24e into main Nov 12, 2026
21 checks passed
@devcrocod
devcrocod deleted the devcrocod/sep-2164-resource-not-found branch November 12, 2026 14:12
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.

Implement SEP-2164: Standardize resource not found error code (-32602)

3 participants