Span status contains tool result content and exception messages

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

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

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

调研方向

issue 指出,设置 span 状态描述的位置是 McpSessionHandler.AddResponseTags 和 AddExceptionTags。阅读这些方法以及 MCP 错误的 tracing 约定,然后检查与 span 状态描述相关的测试。完成标准是省略工具结果内容和非 McpProtocolException 消息,保留协议错误消息,并且测试覆盖这些情况。

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

描述

bug

Describe the bug
When a tool returns isError, the server span's status description is set to the whole content array as JSON (McpSessionHandler.AddResponseTags). When a handler throws, it's set to e.Message (AddExceptionTags).

We run two MCP servers on 1.4.2 and found confirmation tokens and customer data from tool results in our tracing backend because of this. It's the same on main after 2.4.0.

To Reproduce

  1. Listen to the Experimental.ModelContextProtocol activity source on the server.
  2. Call a tool that returns isError: true with some content, or one that throws.
  3. Look at the server span's status description.

Expected behavior
No description for isError results, since error.type=tool_error already marks them, and none for exceptions that aren't an McpProtocolException. The conventions only ask for the JSONRPCError.message, and the result content has its own opt-in attribute.

Additional context
For now we clear the description in a span processor before export.

Happy to open a PR for this. If you agree with the direction.

主要语言
C#
星标
4.7k
派生
863
平均合并
15 小时 29 分钟
30 天内合并 PR
8

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 没有 Pull Request 模板
  • 阅读贡献指南

从这里开始

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

modelcontextprotocol/csharp-sdk 的其他 Issue

查看 modelcontextprotocol/csharp-sdk 的全部 Issue

相似的 Issue

更多 C# Issue

把新 issue 发到你的邮箱

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