Return JSON-RPC protocol errors for unknown tool calls
Per the MCP specification, an unknown tool call is a protocol-level error, not a tool execution error. Return JSON-RPC -32602 (Invalid params) instead of successful responses with `isError: true`. https://modelcontextprotocol.io/specification/2025-11-25/server/tools#error-handling Fixes #228.
This commit is contained in:
parent
b8f1cc92e6
commit
15710ef0aa
1 changed files with 14 additions and 12 deletions
|
|
@ -377,7 +377,7 @@ module MCP
|
|||
unless tool
|
||||
add_instrumentation_data(tool_name: tool_name, error: :tool_not_found)
|
||||
|
||||
return error_tool_response("Tool not found: #{tool_name}")
|
||||
raise RequestHandlerError.new("Tool not found: #{tool_name}", request, error_type: :invalid_params)
|
||||
end
|
||||
|
||||
arguments = request[:arguments] || {}
|
||||
|
|
@ -401,6 +401,8 @@ module MCP
|
|||
end
|
||||
|
||||
call_tool_with_args(tool, arguments)
|
||||
rescue RequestHandlerError
|
||||
raise
|
||||
rescue => e
|
||||
report_exception(e, request: request)
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue