modelcontextprotocol / modelcontextprotocol/python-sdk

401 in Streamable HTTP should be handled gracefully

オープン
#1,295 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

bug P2 ready for work
主要言語
Python
スター
24.3k
フォーク
4k
平均マージ
1日 1時間
マージ済み PR(30日)
31

説明

Initial Checks
Description

Currently, streamable_http will call response.raise_for_status() when handling POST requests. (ref).

This means that a 401 will bubble up and cause the entire program to crash.

While a 401 on server initialize could warrant an exception, we have a use case where a MCP server will return 401 for specific unauthorized operations, and allow others.

This should be handled gracefully, similar to how _handle_unexpected_content_type works, returning a JSONRPC message outlining an unauthorized exception was thrown.

This would let an agent or other client handle it instead of crashing the program.

Python & MCP Python SDK
Python 3.12 and MCP SDK v1.13.1

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

src/mcp/client/streamable_http.py の response.raise_for_status() 周辺にある POST 処理から始め、その後 _handle_unexpected_content_type と比較してください。HTTP エラーがどのようにクライアントの結果になるかを追跡します。完了条件は、認証されていない操作からの 401 によって、クライアントがクラッシュせずに処理できる JSON-RPC unauthorized エラーメッセージが生成されることです。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
api
issue の種類
バグ
難易度
3/5
見積もり時間
1〜2日
活発さ
活発
明瞭さ
おおむね明確
初心者へのやさしさ
74/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。