fix(frame): 未知工具错误码 -32601 改为 -32602,符合 MCP 规范
MCP 规范《Tools / Error Handling》把「未知工具」归为**协议错误**,
示例即为 {"code": -32602, "message": "Unknown tool: invalid_tool_name"}。
基座原先回 -32601(Method not found),语义偏 JSON-RPC 方法层。
- mcp_configParser.cpp: mcp_Tools::Call 改 -32601 → -32602,
消息改为 "Unknown tool: <name>"。
- 无需改 mcp_server.cpp 的 HandleToolsCall:其协议错误白名单
{-32700,-32600,-32601,-32602} 已含 -32602,分类逻辑不变。
- 同步更新 verify_mcp_frame.py 与 verify_stdio_bridge.py 的断言
(未知「方法」仍是 -32601,语义正确,不动)。
验证(重建基座 + 重启 CAD 后实测):
- 直连 TCP:{"error":{"code":-32602,"message":"Unknown tool: __no_such_tool__"}}
- verify_mcp_frame.py 4/4 PASS;verify_stdio_bridge.py 24/24 PASS
- 回归:verify_annotate.py 9/9、dwg_review --check 正常
- MCP Inspector 冒烟:tools/list 26 个工具、tools/call get_drawing_info 正常
This commit is contained in:
1 parent
f33d42afe9
commit
3bd77d950e
4 files changed
+14
-10
No files matched your search
+3
-3
@@ -49,7 +49,7 @@ def test_string_id():
|
||||
|
||||
|
||||
def test_large_request():
|
||||
"""构造 >2KB 的 arguments;旧基座会截断成 -32700,新基座应正常返回 -32601。"""
|
||||
"""构造 >2KB 的 arguments;旧基座会截断成 -32700,新基座应正常返回 -32602。"""
|
||||
big = {"blob": "x" * 5000}
|
||||
resp = json.loads(
|
||||
_call(
|
||||
@@ -62,8 +62,8 @@ def test_large_request():
|
||||
).decode()
|
||||
)
|
||||
code = (resp.get("error") or {}).get("code")
|
||||
assert code == -32601, f"期望 -32601(工具不存在),实际 {resp}"
|
||||
print("[PASS] >2KB 请求未被截断(返回 -32601 而非 -32700)")
|
||||
assert code == -32602, f"期望 -32602(未知工具,协议错误),实际 {resp}"
|
||||
print("[PASS] >2KB 请求未被截断(返回 -32602 而非 -32700)")
|
||||
|
||||
|
||||
def test_notification_no_reply():
|
||||
|
||||
Reference in new issue
Block a user