Skip to content

Answer Invalid params for the remaining malformed params - #701

Open
koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:answer_invalid_params_for_the_remaining_malformed_params
Open

koic wants to merge 1 commit into
modelcontextprotocol:mainfrom
koic:answer_invalid_params_for_the_remaining_malformed_params

Conversation

@koic

@koic koic commented Nov 21, 2026

Copy link
Copy Markdown
Member

Motivation and Context

#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 #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.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

## 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.
@koic
koic force-pushed the answer_invalid_params_for_the_remaining_malformed_params branch from 676c263 to afb3e3e Compare November 21, 2026 18:31

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

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

tools/call with non-object arguments returns -32603 Internal error instead of -32602 Invalid params

1 participant