Skip to content

FR: Capture tool execution errors in OTel traces and metrics #2084

@danbarr

Description

@danbarr

Overview

Currently, the OpenTelemetry traces include the result of the client HTTP call to the MCP server in the http.status_code field, but there's nothing that indicates whether the tool call itself succeeded, just that the client successfully invoked the MCP server.

Consider an MCP interacting with a backend API, if the API returns a 500 status code or some application-level error, the client->MCP http.status_code still correctly returns a 200 success code, but users cannot do any tracing of problematic tool calls.

Proposal

Add additional field(s) in the mcp. section of traces/metrics to propagate an indicator of tool execution errors (result.isError: true in the spec) and the error messages so users can collect information about problems with tool calls.

Reproduce

An easy way to see this is using the fetch MCP and asking for an invalid website:

Fetch the contents of https://toolhive.ai and summarize

This results in an error, and clients like VS Code indicate this.

Image

But the OTel trace record emitted by ToolHive doesn't contain any indication that an error occurred.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions