Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Client transports/sessions swallow the original exception; applications cannot classify 401/403/429 transport failures

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

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
55/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
api, backend

调研方向

Look at the client transport and session code handling HTTP requests, likely in modules like mcp/client/transports or mcp/client/session. The issue mentions SSE/streamable-HTTP transports and httpx.HTTPStatusError. Start by finding where exceptions are caught and logged, and where the stream is closed. The goal is to modify the error propagation so the original exception reaches send_request callers. Testing will involve simulating transport failures (401, 403, 429) to verify the exception is correctly delivered.

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

描述

Initial Checks
  • I confirm that I'm using the newest release of my line (verified on main and 2.2.0)
  • I confirm that I searched for my issue in the issues before opening this one (searched "exception pending request", "error classification", "McpError generic")
Release line

v2 (v1 shares the code)

Description

When a transport request fails mid-flight (HTTP 401/403/429, connection reset, etc.), the client transports log the exception and close the stream, and pending send_request callers get a generic closed-stream error. The original exception — with its status code — never reaches the application, so a host cannot distinguish "token expired, re-authorize" from "rate limited, back off" from "server gone".

Proposal, in two parts (we run both in production and can PR them):

  1. SSE/streamable-HTTP transports forward the caught exception into the read stream (instead of only logger.exception), so the session sees it.
  2. Client/shared sessions deliver that raw exception to the pending request(s) — the default message handler re-raises Exception instances — so send_request callers receive the real httpx.HTTPStatusError and can classify it.

One caveat worth discussing: httpx exceptions stringify with the request URL, which can carry credentials in query strings; our transport-side change logs only the exception type name and leaves scrubbing to the application that receives the raw exception.

Happy to be assigned and open the PR(s).

🤖 Generated with Claude Code

主要语言
Python
星标
24.3k
派生
4k
平均合并
1 天 16 小时
30 天内合并 PR
25

贡献指南

打开贡献指南

从这里开始

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

modelcontextprotocol/python-sdk 的其他 Issue

查看 modelcontextprotocol/python-sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

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