OTel client span stays Unset when the tool result has isError: true

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

从shared/jsonrpc_dispatcher.py开始,阅读现有的 JSON-RPC 错误响应处理,然后将其与server/_otel.py中的工具错误处理以及docs/gen-ai/mcp.md中的指导进行比较。测试一个包含CallToolResult且设置了isError的成功响应。完成的标准是客户端 span 报告error.type=tool_error和 ERROR 状态,并且有一个测试覆盖此行为。

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

描述

bug v2

With mcp==2.3.0, the client span created in shared/jsonrpc_dispatcher.py sets ERROR status and error.type for a JSON-RPC error response (the #3174 fix), but not for a successful response whose CallToolResult.isError is true. The server span for the same call does set error.type=tool_error (server/_otel.py), so the two ends of one call disagree.

The OTel GenAI semantic conventions for MCP (docs/gen-ai/mcp.md, note on error.type) say instrumentation SHOULD set error.type to tool_error when the tool result reports an error.

Reproduction (Python client and server, Streamable HTTP, default OTel setup):

git clone https://github.com/mkwitko/mcp-reliability && cd mcp-reliability
examples/python-sdk-streamable-http/run.sh      # needs docker, uv, go
go run ./cmd/mcp-reliability doctor testdata/python-sdk-default.jsonl

Output includes:

[WARN] MCP-ERR-003: client and server spans for "tools/call fail" disagree on failure: the client span lacks error.type

Captured trace and write-up: https://github.com/mkwitko/mcp-reliability/blob/v0.1.0/docs/research/python-sdk-v2-validation.md

Suggested change: after the response is parsed in the dispatcher, if the result is a CallToolResult with isError, set error.type="tool_error" and status ERROR on the client span, matching server/_otel.py. Happy to send a PR if you agree with the direction.

主要语言
Python
星标
24.7k
派生
4.1k
平均合并
18 小时 27 分钟
30 天内合并 PR
15

环境准备

从这里开始

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

modelcontextprotocol/python-sdk 的其他 Issue

查看 modelcontextprotocol/python-sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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