modelcontextprotocol / modelcontextprotocol/python-sdk

Improve exception tracebacks for easier debugging

Open
#1,744 1 comment 0 reactions 0 assignees View on GitHub

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_exception flag 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

AI Disclaimer

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.