Skip to content

Commit cfbfbe9

Browse files
authored
fix(MCP): Added error status to traces in MCP server for tool calls (#2914)
Signed-off-by: Felix George <[email protected]>
1 parent d70bea6 commit cfbfbe9

File tree

1 file changed

+5
-0
lines changed
  • packages/opentelemetry-instrumentation-mcp/opentelemetry/instrumentation/mcp

1 file changed

+5
-0
lines changed

packages/opentelemetry-instrumentation-mcp/opentelemetry/instrumentation/mcp/instrumentation.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,11 @@ async def send(self, item: Any) -> Any:
250250
span.set_attribute(
251251
SpanAttributes.MCP_RESPONSE_VALUE, f"{serialize(request.result)}"
252252
)
253+
if hasattr(request.result, "isError"):
254+
if request.result.isError is True:
255+
span.set_status(
256+
Status(StatusCode.ERROR, f"{serialize(request.result)}")
257+
)
253258
if hasattr(request, "id"):
254259
span.set_attribute(SpanAttributes.MCP_REQUEST_ID, f"{request.id}")
255260

0 commit comments

Comments
 (0)