Skip to content

Conversation

@kashishhora
Copy link
Member

Summary

Added

  • New exceptions.py module with capture_exception() for structured error capture
  • Stack trace parsing via parse_python_traceback() that walks the traceback chain
  • is_in_app() detection to distinguish user code from library code (site-packages, stdlib)
  • Exception chain unwrapping for __cause__ (explicit raise from) and __context__ (implicit)
  • Context line extraction using linecache for user code frames
  • Context variables (store_captured_error/get_captured_error) to preserve exceptions before MCP SDK converts them
  • ErrorData, StackFrame, and ChainedErrorData TypedDicts in types.py
  • Comprehensive test suite with 30 tests

Modified

  • official/monkey_patch.py: Uses capture_exception() for full stack traces, preserves exceptions before MCP SDK conversion
  • community/monkey_patch.py: Same error capture improvements

Test Plan

  • All 30 exception tests pass (uv run python -m pytest tests/test_exceptions.py)
  • Manually test with a FastMCP server that throws exceptions
  • Verify error events in MCPcat dashboard show full stack traces and cause chains

@kashishhora kashishhora requested a review from naji247 November 24, 2025 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants