Skip to content

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

Closed

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.

Activity

  1. added
    enhancement
    on Oct 3, 2025
  2. changed the title [-]FR: Capture tool execution errors in traces and metrics[/-] [+]FR: Capture tool execution errors in OTel traces and metrics[/+] on Oct 3, 2025
  3. added
    good-first-issue
    on Oct 3, 2025
  4. Deepam02 commented on Oct 3, 2025

    @Deepam02
    Contributor

    /assign

  5. danbarr commented on Oct 3, 2025

    @danbarr
    CollaboratorAuthor

    Hey @Deepam02 thanks for jumping in! I've assigned this to you; please don't hesitate to reach out if you have questions!
    cc @ChrisJBurns

  6. removed
    enhancement
    on Oct 3, 2025
  7. added a commit that references this issue on Oct 4, 2025
    4b7ac63
  8. ChrisJBurns commented on Feb 20, 2026

    @ChrisJBurns
    Collaborator

    @danbarr I believe they may have been done in the recent OTEL work?

  9. danbarr commented on Mar 3, 2026

    @danbarr
    CollaboratorAuthor

    @ChrisJBurns Maybe? I don't think the docs on the available metrics / trace fields have been updated with the new stuff. 😅

  10. ChrisJBurns commented on Mar 4, 2026

    @ChrisJBurns
    Collaborator

    @danbarr It seems that it is and isn't resolve in the code. The bits inside the code captures HTTP-level errors (5xx), but any JSON-RPC errors returned with a HTTP 200 are not yet captured due to needing to response body parsing which is tracked as #3765. I'm happy to close this ticket because the 5xx errors are captured, with the JSON-RPC errors within HTTP 200 being fixed under #3765.

  11. danbarr commented on Mar 4, 2026

    @danbarr
    CollaboratorAuthor

    @ChrisJBurns Yes I think #3765 addresses the main part of this request, the "MCP protocol-level call succeeded but the underlying tool had a problem reported in the response" aspect.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

good-first-issue

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions