偵錯 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