Span status contains tool result content and exception messages

Offen Anfängerfreundlich
#2,060 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 1 Tag

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
67/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
csharp
Bereich
observability

Rechercherichtung

Das Issue verweist auf McpSessionHandler.AddResponseTags und AddExceptionTags als die Stellen, an denen Span-Statusbeschreibungen gesetzt werden. Lies diese Methoden und die Tracing-Konventionen für MCP-Fehler und prüfe dann die zugehörigen Tests für Span-Statusbeschreibungen. Fertig ist die Arbeit, wenn der Inhalt von Tool-Ergebnissen und Meldungen, die keine McpProtocolException sind, ausgelassen werden, Protokollfehlermeldungen jedoch erhalten bleiben und Tests diese Fälle abdecken.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

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.

Vorherrschende Sprache
C#
Sterne
4.7k
Forks
863
Ø Merge
15 Std. 29 Min.
Gemergte PRs (30 T.)
8

Entwicklungsumgebung

In Codespaces öffnen

Startet den Dev-Container des Projekts im Browser, mit Ihrem eigenen GitHub-Konto.

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus modelcontextprotocol/csharp-sdk

Alle Issues in modelcontextprotocol/csharp-sdk

Ähnliche Issues

Weitere Issues zu C#

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.