Repository navigation
fix(server)!: return INVALID_PARAMS for unknown resources - #1172
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
🟢 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Per SEP-2164,
resources/readfor an unknown URI now fails with-32602(Invalid Params) instead of-32002, on every protocol version. The error data still carries theuri.Breaking Changes
Client.readResourcefor a missing resource throwsMcpExceptionwithINVALID_PARAMSinstead ofRESOURCE_NOT_FOUND. Clients matching on-32002should also accept-32602.Closes #805