Unknown tool error always says "Unknown tool: invalid_tool_name" instead of the name that was called

Open Beginner friendly
#1,346 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
1/5
Estimated time
Under an hour
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
java
Domain
backend

Research direction

Look in McpAsyncServer.java and McpStatelessAsyncServer.java for the tools/call handler that builds McpError with the fixed "Unknown tool: invalid_tool_name" message. Replace the placeholder with the requested name already in scope as callToolRequest.name(), leaving the data field unchanged. Run the existing server tests to confirm both async and stateless variants now return e.g. Unknown tool: delete_order.

Written by the indexing model from the issue text.

Description

The error for a tools/call with an unknown tool name has a fixed message, Unknown tool: invalid_tool_name, whatever name was called:

// McpAsyncServer.java (and McpStatelessAsyncServer.java)
return Mono.error(McpError.builder(McpSchema.ErrorCodes.INVALID_PARAMS)
    .message("Unknown tool: invalid_tool_name")
    .data("Tool not found: " + callToolRequest.name())
    .build());

A call to delete_order, which the server does not have, gets:

{"code": -32602, "message": "Unknown tool: invalid_tool_name", "data": "Tool not found: delete_order"}

The text looks like it was taken from the error example in the MCP specification, where invalid_tool_name is a placeholder. Clients and logs usually show only message, so the name of the tool is lost, and it looks as if the tool were called invalid_tool_name.

Expected: the message names the tool that was called, such as Unknown tool: delete_order, in both McpAsyncServer and McpStatelessAsyncServer. data can stay as it is.

Seen with mcp-core 2.2.0, and still in main (779893c).

Claude Code on behalf of Claus Ibsen

Dominant language
Java
Stars
3.8k
Forks
1.1k
Avg merge
1d 3h
Merged PRs (30d)
38

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from modelcontextprotocol/java-sdk

All issues in modelcontextprotocol/java-sdk

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.