Python MCP server returns no structured error for an unknown tool

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python, typescript
领域
api

调研方向

从 src/selfgraph/mcp/server.py 的 build_server 开始,然后将 Python 对未知工具的处理行为与 issue 中描述的 TypeScript 响应进行比较。检查 MCP 框架如何处理对未注册工具的调用,以及现有错误字段如何生成。未知工具返回包含预期文本和字段的结构化 invalid_argument 错误时,即表示完成。

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

描述

approved-for-pr area: cli-mcp area: errors area: parity bug effort: S P3

What happens

Calling a tool that does not exist gets a structured error from the TypeScript MCP server:

{"error": "unknown tool 'nonexistent_tool'", "error_type": "ValidationError", "code": "invalid_argument", "tool": "nonexistent_tool", "hint": "...", "retryable": false}

The Python server never reaches SelfGraph's error handling. The MCP framework raises ToolError: Unknown tool: nonexistent_tool, so the client gets plain text with no code, hint, retryable, or tool.

AGENTS.md says MCP errors carry the same code, field, and hint in both SDKs. An agent that misspells a tool name, or calls one an older server version lacks, is exactly the reader the hint is for.

Reproduce

On 5a277c9:

import asyncio
import selfgraph.mcp.server as srv

server = srv.build_server()
asyncio.run(server.call_tool("nonexistent_tool", {}))
# mcp.server.mcpserver.exceptions.ToolError: Unknown tool: nonexistent_tool

TypeScript: await callTool("nonexistent_tool", {}) returns the structured result above with isError: true.

Expected

The Python server returns the same structured invalid_argument error, with the text unknown tool 'nonexistent_tool'.

Where

  • src/selfgraph/mcp/server.py, build_server: only registered tools go through _tool / _check_arguments, so an unknown name falls through to the framework
主要语言
TypeScript
星标
173
派生
58
平均合并
6 小时
30 天内合并 PR
120

环境准备

从这里开始

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

hydra-db/selfgraph 的其他 Issue

查看 hydra-db/selfgraph 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

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