modelcontextprotocol / modelcontextprotocol/python-sdk

Improve exception tracebacks for easier debugging

未关闭
#1,744 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

enhancement P2 v2
主要语言
Python
星标
24.3k
派生
4k
平均合并
1 天 1 小时
30 天内合并 PR
31

描述

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

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

该 issue 中未确定任何文件或测试。首先跟踪 asyncio/anyio 任务组路径以及 raise_exception 标志的所有使用位置,然后审查链接的异常处理相关 issue。完成的标准是:traceback 能暴露用户级别的失败,减少 wrapper 嵌套,并始终遵循 raise_exception。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
backend-api-design
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
活跃
描述清晰度
需要澄清
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。