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

未关闭 适合新手
#1,346 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
1/5
预计耗时
1 小时以内
新手友好度
85/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
java
领域
backend

调研方向

在 McpAsyncServer.java 和 McpStatelessAsyncServer.java 中查找 tools/call 处理器,该处理器构造 McpError,并带有固定的 "Unknown tool: invalid_tool_name" 消息。将占位符替换为已在作用域中作为 callToolRequest.name() 的所请求名称,保持 data 字段不变。运行现有服务器测试,确认 async 和 stateless 两种变体现在都返回例如 Unknown tool: delete_order。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Java
星标
3.8k
派生
1.1k
平均合并
1 天 3 小时
30 天内合并 PR
38

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

modelcontextprotocol/java-sdk 的其他 Issue

查看 modelcontextprotocol/java-sdk 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。