modelcontextprotocol / modelcontextprotocol/python-sdk
Improve exception tracebacks for easier debugging
Open
Nobody has claimed this yet.
enhancement
P2
v2
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 31
Description
Summary
Make exception tracebacks clearer and easier to understand by reducing asyncio/anyio wrapper noise.
Problem
- Exceptions are often wrapped in multiple layers of asyncio/anyio task group machinery
- Tracebacks are hard to read and don't clearly point to the root cause
- The
raise_exceptionflag is not consistently respected - Errors from deep inside task groups obscure the actual failure point
Goal
- Cleaner tracebacks that point to user code, not SDK internals
- Raise exceptions from the main context where possible
- Reduce nesting of exception wrappers
Related
- #743 - RuntimeError but the actual root cause is not logged correctly
- #396 - MCP Server: Inconsistent Exception Handling in @app.call_tool
- #1401 - ClientSession Error Handling
- #1742 - Introduce typed error classes with metadata
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No files or tests are identified in the issue. Start by tracing the asyncio/anyio task-group paths and every use of the raise_exception flag, then review the linked exception-handling issues. Done means tracebacks expose the user-level failure, wrapper nesting is reduced, and raise_exception is consistently respected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend-api-design
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100