Skip to content

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

Done

Description

@dominikklein

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

  • arguments that 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/call with params as 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

  1. added
    bug
    on Nov 20, 2026
  2. added a commit that references this issue on Nov 21, 2026
    676c263
  3. koic commented on Nov 21, 2026

    @koic
    Member

    Thanks for the report and the reproduction.

    Non-object arguments is fixed by #691. #701 covers the rest: params that is an array or absent for tools/call, prompts/get and logging/setLevel, and the malformed ref and argument of completion/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 RequestHandlerError whose error_type is :invalid_params, so it can be filtered there by class and error_type.

  4. added a commit that references this issue on Nov 21, 2026
    afb3e3e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions