[Server] Return invalid-params for unknown tool in tools/call - #423
Open
latent-9 wants to merge 1 commit into
Open
[Server] Return invalid-params for unknown tool in tools/call#423latent-9 wants to merge 1 commit into
latent-9 wants to merge 1 commit into
Conversation
An unknown tool name is an invalid parameter of the tools/call request, not a missing JSON-RPC method: the tools/call method exists, only its `name` argument does not resolve. Return -32602 (Invalid params) to match the argument-validation path in the same handler, which already reports invalid input for tools/call as -32602.
latent-9
requested review from
CodeWithKyrian,
Nyholm,
chr-hertel and
soyuka
as code owners
August 15, 2026 15:16
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.
Summary
CallToolHandlerreturns-32601(Method not found) when atools/callrequest names a tool that is not registered. The tool name is a parameter of a method that does exist, so the correct JSON-RPC error for this case is-32602(Invalid params).Details
tools/callis a valid, supported method. When itsnameargument does not resolve to a registered tool, the method was found but a parameter was invalid.-32601is reserved for an unknown method (an unsupported JSON-RPC method name), which is not what happened here.The same handler already treats bad tool input as invalid params: when the arguments fail schema validation it returns
Error::forInvalidParams(...)(-32602). An unknown tool name belongs to the same class of error and should use the same code.The reference TypeScript schema classifies an unknown tool name under
InvalidParamsError, and the other SDKs have converged on-32602for the unknown-name case (for example modelcontextprotocol/ruby-sdk#517 forprompts/get).Impact
A client that receives
-32601fortools/callcan reasonably conclude that the server does not implementtools/callat all and stop issuing tool calls, when in fact only the specific tool name was wrong.-32602correctly signals that the request was understood but a parameter was invalid, so the client can recover by choosing a valid tool.Scope
This is limited to the tool-not-found path and is independent of #337 and #359 (resource and prompt not-found moving from
-32002to-32602). No protocol-version gate is needed:-32602is a standard JSON-RPC code valid in every MCP revision, and-32601was never the specified value for an unknown tool name.Changes
CallToolHandler: returnError::forInvalidParams(...)instead ofError::METHOD_NOT_FOUNDwhen a tool is not found.Error::INVALID_PARAMS.