OTel client span sets ERROR status for -32602 and other caller-error codes

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

首先阅读设置客户端 span 状态和 error.type 的 dispatcher 代码,然后将其行为与服务器端分类以及 docs/gen-ai/mcp.md 中关于 MCP 语义约定的说明进行比较。如果可行,请使用 issue 中的命令复现。完成标准是:列出的五个 caller-error 代码仍会填充 rpc.response.status_code,但状态保持为 Unset,并省略 error.type,且测试覆盖这一行为。

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

描述

bug v2

Since 2.3.0 (#3174) every JSON-RPC error response marks the client span ERROR with error.type set to the code. The OTel GenAI semantic conventions for MCP (docs/gen-ai/mcp.md, footnote on error.type) say the codes -32700, -32600, -32601, -32602 and -32002 "indicate that the caller sent a request the receiver could not serve and SHOULD NOT be considered errors"; only other codes should be. rpc.response.status_code should still carry the code.

The most common case is calling an unknown tool: the Go SDK server (and the TypeScript SDK) answer -32602, and the Python client span becomes ERROR with error.type=-32602.

Reproduction (Python 2.3.0 client against a Go SDK server):

git clone https://github.com/mkwitko/mcp-reliability && cd mcp-reliability
examples/python-sdk-streamable-http/run.sh
go run ./cmd/mcp-reliability doctor testdata/cross-python-client-go-server.jsonl
[WARN] MCP-ERR-005: span "tools/call missing" is marked failed (status=Error, error.type present=true) for a JSON-RPC code the semconv says SHOULD NOT be considered an error

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

Suggested change: in the dispatcher, when the error code is one of the five caller-error codes, set rpc.response.status_code but leave the span status Unset and skip error.type. The server side already has the equivalent classification. I can send a PR.

主要语言
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 摘要。