本地 SDK 实测
MCP 工具报错,HTTP 仍返回 200
两次查询都收到 HTTP 200。查询已有键得到 isError: false,查询缺失键得到 isError: true。
观测记录
如何判断返回 HTTP 200 的 tools/call 是否真的查到了数据?
- 已有键 / 缺失键的 HTTP 状态
- 200 / 200
- 已有键 · isError
- false
- 缺失键 · isError
- true
结果解读
使用结果前检查 MCP 响应里的 isError。单独记录工具错误,才能计算查到有效内容的比例。
如何复现
在空目录中运行以下命令。可先下载脚本,检查测试如何构造请求和记录结果。
mkdir -p niubiagent-mcp-lab && cd niubiagent-mcp-lab
npm install --prefix . --ignore-scripts --no-audit --no-fund @modelcontextprotocol/sdk@1.30.0 zod@4.5.4
curl -fsSLo reproduce.mjs https://www.niubiagent.com/lab/reproduce.mjs
node reproduce.mjs tool-error-http-200下载复现脚本 ↓