Repository navigation
Description
Someone sent our MCP server (Rails app, stateless Streamable HTTP) a tools/call whose arguments was a string instead of an object. The client got back -32603 Internal error, and our exception reporter got a NoMethodError. Nothing bad happened, but it looks like a server bug from the outside, and it lands in the error log every time, even though the client simply sent invalid params.
The spec defines arguments as an object ({ [key: string]: unknown } in CallToolRequestParams, schema), so I'd expect -32602 Invalid params here, the same answer the SDK already gives when params itself is a string.
To reproduce
With 1.11.0 (main at 971be86 has the same code):
require "mcp"
MCP.configure do |config|
config.exception_reporter = ->(error, _context) { warn "reported: #{error.class}: #{error.message}" }
end
echo = MCP::Tool.define(
name: "echo",
description: "Echoes the text back",
input_schema: { properties: { text: { type: "string" } }, required: ["text"] },
) do |text:, server_context: nil|
MCP::Tool::Response.new([{ type: "text", text: text }])
end
server = MCP::Server.new(name: "repro", version: "1.0.0", tools: [echo], capabilities: { tools: {} })
server.handle_json('{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"echo","arguments":"hi"}}')
# reported: NoMethodError: undefined method 'keys' for an instance of String
# => {"jsonrpc":"2.0","id":1,"error":{"code":-32603,"message":"Internal error","data":"Internal error calling tool echo"}}An array (["hi"]) or a number (42) as arguments gives the same result. params as an array ("params":["echo"]) ends the same way, with a TypeError: no implicit conversion of Symbol into Integer. "params":"echo" is already answered correctly with -32602.
Cause
Server#call_tool takes request[:arguments] || {} and passes it to InputSchema#missing_required_arguments, which calls arguments.keys. Nothing checks before that that it is a Hash. params as an array is accepted by JsonRpcHandler (plain JSON-RPC allows positional params), and call_tool then does request[:name] on the array.
Expected behavior
argumentsthat is not an object (and not missing/null, which already works as{}) is answered with-32602 Invalid params, and the tool doesn't run.- The same for
tools/callwithparamsas an array, since MCP requests take named params only. - Neither ends up in the exception reporter, since it's a client error.
Additional context
We work around it for now by checking the body before handing it to the transport. Happy to open a PR if a check at the top of call_tool sounds right to you.
Activity
Answer Invalid params for the remaining malformed `params`
koic commentedon Nov 21, 2026
Thanks for the report and the reproduction.
Non-object
argumentsis fixed by #691. #701 covers the rest:paramsthat is an array or absent fortools/call,prompts/getandlogging/setLevel, and the malformedrefandargumentofcompletion/complete.On the exception reporter: the SDK reports a request its handlers refuse, an unknown tool as much as this one. With these changes the reporter receives a
RequestHandlerErrorwhoseerror_typeis:invalid_params, so it can be filtered there by class anderror_type.Answer Invalid params for the remaining malformed `params`