modelcontextprotocol / modelcontextprotocol/python-sdk

FastMCP.run(transport="stdio") produces noisy traceback on KeyboardInterrupt instead of clean exit

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

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

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

説明

Initial Checks
Description

Running a FastMCP stdio server from the terminal and interrupting with Ctrl-C produces a multi-frame traceback through anyio.run() → asyncio.runners → mcp.server.lowlevel.server.run → anyio.streams.memory.receive. The server is correctly waiting on stdin in an async loop; the trace surfaces because anyio/asyncio don't suppress the cancellation chain. Suggested fix: catch KeyboardInterrupt (or asyncio.CancelledError at the outer boundary) inside FastMCP.run and exit cleanly. Cosmetic but reduces user confusion when testing MCP servers from the terminal.

Example Code

Python & MCP Python SDK
Python 3.13.5
MCP Python SDK 1.27.1

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

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

はじめの一歩

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

調査の方向性

まず FastMCP の stdio サーバーでの Ctrl-C の動作を再現し、次に mcp.server.lowlevel.server.run と anyio のメモリ受信パスを通る FastMCP.run を追跡します。サーバーを割り込みしたときに traceback なしで正常に終了し、通常のシャットダウン動作が変わらなければ修正完了です。

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

評価

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

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

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