modelcontextprotocol / modelcontextprotocol/python-sdk
Improve log clarity for "Terminating session: None" in stateless mode
まだ誰も着手していません。
- 主要言語
- Python
- スター
- 24.3k
- フォーク
- 4k
- 平均マージ
- 1日 1時間
- マージ済み PR(30日)
- 31
説明
Description
In stateless HTTP mode, every request logs INFO:mcp.server.streamable_http:Terminating session: None. This is correct behavior — stateless mode creates a new transport with mcp_session_id=None per request and terminates it afterward — but the message is confusing to end users who see it and assume their connection is failing or being dropped.
I maintain an MCP server (ha-mcp) that runs in stateless mode, and this log message regularly causes confusion among users who think they aren't connected.
Suggested change
Differentiate the log message for stateless (session-less) terminations:
# Current (streamable_http.py):
logger.info(f"Terminating session: {self.mcp_session_id}")
# Suggested:
if self.mcp_session_id:
logger.info(f"Terminating session: {self.mcp_session_id}")
else:
logger.debug("Stateless request completed, cleaning up transport")
This would:
- Downgrade stateless cleanup to
DEBUG(routine, not noteworthy) - Use wording that doesn't alarm users ("completed" vs "Terminating")
- Keep the existing
INFO-level log for actual session terminations
References
- Source:
streamable_http.pyterminate() method - Stateless transport creation:
streamable_http_manager.py_handle_stateless_request()
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
src/mcp/server/streamable_http.py の terminate() メソッドから始め、次に src/mcp/server/streamable_http_manager.py の _handle_stateless_request() と比較してください。ステートレスなクリーンアップがセッションの終了と区別されていること、および実際のセッション終了では既存のログ動作が維持されることを確認してください。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend, observability
- issue の種類
- バグ
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 45/100