Repository navigation
Answer Invalid Params when tool or prompt arguments are not an object - #691
Merged
koic merged 1 commit intoNov 21, 2026
Merged
Conversation
koic
reviewed
Nov 20, 2026
| @@ -1424,6 +1424,12 @@ def call_tool(request, instrumentation_data:, session: nil, related_request_id: | |||
| end | |||
|
|
|||
| arguments = request[:arguments] || {} | |||
Member
There was a problem hiding this comment.
One inconsistency is left: tools/call still accepts arguments: false, because request[:arguments] || {} turns it into {}, while prompts/get now refuses it.
Could tools/call fall back to {} only for an absent or null value, with a false case added to both tests?
Member
|
@yshmarov Looks good to me. Can you squash your commits into one? |
…bject tools/call and prompts/get raised NoMethodError on a non-object arguments value, so the client got -32603 Internal error and the exception reporter saw a server fault for a client mistake.
koic
force-pushed
the
invalid-arguments-object
branch
from
November 21, 2026 07:55
2b8fe07 to
5cc3776
Compare
koic
added a commit
to koic/ruby-sdk
that referenced
this pull request
Nov 21, 2026
## Motivation and Context modelcontextprotocol#691 answers `-32602` when the `arguments` of `tools/call` or `prompts/get` is not an object. The same kind of client mistake still surfaced as `-32603` Internal error, with a `TypeError` or `NoMethodError` handed to the exception reporter as if the server had failed, in these places: - `tools/call`, `prompts/get` and `logging/setLevel` with `params` that is an array, or absent. JSON-RPC allows positional params, so the request reaches the handler, which reads a named member. - `completion/complete` with a `ref` or an `argument` that is not an object. All of them are now refused with `-32602` Invalid params before the handler, the tool or the prompt runs, as `resources/read` and `resources/subscribe` already are. An absent or `null` `arguments` still stands for none. Resolves modelcontextprotocol#694. The issue also asks that such a refusal stay out of the exception reporter. That is not taken: the SDK reports a request its handlers refuse, an unknown tool as much as these, and what the reporter receives is now a `RequestHandlerError` whose `error_type` is `:invalid_params`, in place of the `TypeError` or `NoMethodError`. ## How Has This Been Tested? `test/mcp/server_test.rb`; two of the three new tests fail on the previous library, and the third holds that absent and `null` arguments keep working. ## Breaking Changes None for a request that follows the schema.
This was referenced Nov 21, 2026
koic
added a commit
to koic/ruby-sdk
that referenced
this pull request
Nov 21, 2026
## Motivation and Context modelcontextprotocol#691 answers `-32602` when the `arguments` of `tools/call` or `prompts/get` is not an object. The same kind of client mistake still surfaced as `-32603` Internal error, with a `TypeError` or `NoMethodError` handed to the exception reporter as if the server had failed, in these places: - `tools/call`, `prompts/get` and `logging/setLevel` with `params` that is an array, or absent. JSON-RPC allows positional params, so the request reaches the handler, which reads a named member. - `completion/complete` with a `ref` or an `argument` that is not an object. All of them are now refused with `-32602` Invalid params before the handler, the tool or the prompt runs, as `resources/read` and `resources/subscribe` already are. An absent or `null` `arguments` still stands for none. Resolves modelcontextprotocol#694. The issue also asks that such a refusal stay out of the exception reporter. That is not taken: the SDK reports a request its handlers refuse, an unknown tool as much as these, and what the reporter receives is now a `RequestHandlerError` whose `error_type` is `:invalid_params`, in place of the `TypeError` or `NoMethodError`. ## How Has This Been Tested? `test/mcp/server_test.rb`; two of the three new tests fail on the previous library, and the third holds that absent and `null` arguments keep working. ## Breaking Changes None for a request that follows the schema.
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.
tools/callwith"arguments": "x"(or an array or a number) raisedNoMethodErrorinsidecall_tool. The client got-32603 Internal error, and the server'sexception_reporterreceived theNoMethodErroras if it were a server bug.prompts/getdid the same.The MCP schema requires
argumentsto be an object, and JSON-RPC defines-32602 Invalid paramsfor this. Both handlers now refuse a non-object value withRequestHandlerErroranderror_type: :invalid_params, as the unknown-tool case does. A missingargumentsstill works as before.Reproduced on 1.10.0. The new tests fail on main and pass with the change.
rake testandrake rubocoppass.