调试 MCP 工具被错误调用的根因
何时使用: 你发布了一个工具,但 Claude 总是用错误的参数调用它。
前置条件
- Inspector 已运行 — npx -y @mcpjam/inspector(在 localhost:6274 打开浏览器)
- 你的 MCP 服务器 — 准备好通过 stdio 命令或 SSE URL 启动
步骤
-
连接服务器In the inspector UI, add a stdio server: command=node, args=[./dist/server.js].✓ 已复制→ 工具列表出现,附带描述和 schema
-
查看 LLM 视角Look at the rendered description in the tool detail panel — that's exactly what the model sees.✓ 已复制→ 发现歧义(比如「id」应该是「task_id」,或缺少示例)
-
复现误调用Open Chat tab. Send the user prompt that caused the failure. Watch the tool_use payload.✓ 已复制→ 出现与生产环境相同的错误调用
-
修改描述,重新测试Update the tool's description and example in your server code, restart, retry the same prompt.✓ 已复制→ 这次调用正确
结果: 有证据支撑的前后对比,确定具体修复方案。
注意事项
- 服务器重启后 schema 缓存未刷新 — 点击服务器面板中的「Reconnect」;inspector 会重新获取 list_tools