Skip to content

No mechanism on MCP and LangChain exceptions #5242

Closed

Description

Errors captured by automatic instrumentation should have a mechanism so capture data is available, and the popularity of integrations can be determined.
See

except Exception as e:
# Set error flag for tools
if handler_type == "tool":
span.set_data(SPANDATA.MCP_TOOL_RESULT_IS_ERROR, True)
sentry_sdk.capture_exception(e)
raise

and

def _handle_error(self, run_id: "UUID", error: "Any") -> None:
with capture_internal_exceptions():
if not run_id or run_id not in self.span_map:
return
span_data = self.span_map[run_id]
span = span_data.span
set_span_errored(span)
sentry_sdk.capture_exception(error, span.scope)

Activity

  1. linear commented on Dec 16, 2025

    @linear
  2. added a commit that references this issue on Aug 22, 2026
    f5fcb50
  3. gmassello commented on Aug 22, 2026

    @gmassello
    Contributor

    Opened a draft PR for this: #7226

    One correction worth flagging: the mechanism isn't missing, it's the default
    {"type": "generic", "handled": True} from utils.py:692. The handled: True
    half is arguably the bigger problem — all six MCP call sites re-raise, so these
    errors do reach the user's code, but they don't count as unhandled and don't
    affect the crash-free rate.

    While extending the tests I also found that under fastmcp==4.0.0b2 +
    mcp==2.0.0 a failing tool never reaches any of the six MCP capture sites
    (measured with coverage: zero executed). fastmcp catches and logs it itself, and
    the only event Sentry gets comes from LoggingIntegration, with
    mechanism.type == "logging". That also means test_fastmcp_tool_with_error
    isn't currently exercising MCP error capture on that env. I left it out of the
    PR since it's a separate problem — happy to open an issue for it if useful.

  4. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Aug 22, 2026
  5. added a commit that references this issue on Sep 7, 2026
    02f93c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions