Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

HTTP transport swallows non-2xx status codes causing client to hang

未關閉
#2,110 7 則留言 2 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
4/5
預估耗時
3-5 天
新手友好度
48/100
Issue 類型
缺陷
描述清晰度
基本清楚
活躍度
冷清
技術堆疊
python
領域
api, backend

研究方向

先追蹤 src/mcp/client/streamable_http.py 中的錯誤處理,尤其是 post_writer,以及 src/mcp/client/sse.py 中的錯誤處理,尤其是 sse_reader。檢視相關 issue #1742,了解具型別錯誤的設計。當非 2xx 回應以例外形式傳遞給呼叫端、保留其 HTTP 狀態、區分 401/403,且不再讓呼叫端無限期等待時,即表示完成。

由索引模型根據 Issue 內容生成。

描述

bug P1 v2

Summary

When an MCP server returns non-2xx HTTP status codes (401/403/404/5xx), the Streamable HTTP and SSE transports do not reliably propagate the error to the caller. In the Streamable HTTP transport, post_writer catches exceptions and logs them, but the caller blocks indefinitely waiting for a response on the read stream. HTTP 404 responses are also converted to JSONRPCError(code=32600), losing the original HTTP status information.

Expected Behavior

  • Non-2xx HTTP responses should be surfaced as exceptions to the caller, not silently logged
  • The original HTTP status code should be preserved and accessible
  • Auth-related errors (401/403) should be distinguishable from other failures

Current Behavior

  • post_writer in Streamable HTTP transport catches and logs errors without forwarding them through the read stream
  • Callers hang indefinitely waiting for a response
  • HTTP 404 is converted to JSONRPCError(code=32600), destroying HTTP-level context

Affected Code

  • src/mcp/client/streamable_http.py (post_writer)
  • src/mcp/client/sse.py (sse_reader)

Related

  • #1742 — broader typed error classes design
主要語言
Python
星號
24.3k
分支
4k
平均合併
1 天 11 小時
30 天內合併 PR
30

貢獻指南

開啟貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

modelcontextprotocol/python-sdk 的其他 Issue

查看 modelcontextprotocol/python-sdk 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。