modelcontextprotocol / modelcontextprotocol/python-sdk

Streamable HTTP client logs a WARNING for valid 202 Accepted on session termination (DELETE)

オープン 初心者向け
#3,546 コメント 4 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

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

説明

Problem

mcp/client/streamable_http.py treats any DELETE session-termination response outside {200, 204} as a failure and logs:

WARNING mcp.client.streamable_http: Session termination failed: 202

But 202 Accepted is a valid, spec-compliant response for an asynchronous delete — the server accepted the request and will process it later. The current code path:

if response.status_code == 405:
    logger.debug("Server does not allow session termination")
elif response.status_code not in (200, 204):
    logger.warning(f"Session termination failed: {response.status_code}")
Evidence

A long-running Hermes Agent (NousResearch) deployment with several Streamable HTTP MCP servers accumulated 72 Session termination failed: 202 warnings in ~36 hours in errors.log — pure noise from servers that correctly answer 202 to asynchronous termination. Real failures (connection errors) also surface through this same line, so the constant false positives bury the signal.

Suggested fix

Treat 2xx as success on termination, e.g.:

if response.status_code == 405:
    logger.debug("Server does not allow session termination")
elif 200 <= response.status_code < 300:
    pass  # 200/202/204 all acceptable
else:
    logger.warning(f"Session termination failed: {response.status_code}")
Environment
  • mcp Python SDK (client, streamable HTTP transport), observed on recent Hermes 0.21.x installs
  • Servers: multiple Streamable HTTP MCP endpoints (remote + local)

Happy to send a PR if the direction is agreed.

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

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

はじめの一歩

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

調査の方向性

mcp/client/streamable_http.py の DELETE セッション終了レスポンス処理から始めます。202 レスポンスが警告なしで成功として扱われ、405 は引き続き debug ケースとして扱われ、その他の失敗ステータスでは引き続き警告が出ることを確認してください。利用可能であれば、該当する client test suite を実行してください。

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

評価

技術スタック
python
領域
api, networking
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
活発
明瞭さ
明確に書かれている
初心者へのやさしさ
85/100

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

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