modelcontextprotocol / modelcontextprotocol/python-sdk

More control over stderr in stdio client

未關閉 適合新手
#1,806 1 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

enhancement needs decision P3
主要語言
Python
星號
24.3k
分支
4k
平均合併
1 天 1 小時
30 天內合併 PR
31

描述

Description

Currently, a TextIO object (defaulting to sys.stderr) must be set for errlog when creating a new stdio client session.
https://github.com/modelcontextprotocol/python-sdk/blob/2aa1ad2a69b56bc6cef089c9b4c3ecccbbc8e84d/src/mcp/client/stdio/__init__.py#L106
However, the underlying calls to Python's native Popen and anyio.create_process both support subprocess.DEVNULL: int = -3 for stderr, which allows the stream to be ignored.
By updating the type hint, we can easily support int for errlog. This change would benefit downstream projects and resolve issues for CLI users. Furthermore, I believe ignoring errlog is a better default than piping them into stderr, as the current behaviour can create unexpected side-effects that are difficult to trace.

References

Related Issues:
https://github.com/modelcontextprotocol/python-sdk/issues/156
https://github.com/langchain-ai/langchain-mcp-adapters/issues/72

Documentation:
https://docs.python.org/3/library/subprocess.html#subprocess.Popen
https://anyio.readthedocs.io/en/stable/api.html#anyio.open_process

貢獻指南

開啟貢獻指南

從這裡開始

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

研究方向

從 issue 中引用的 src/mcp/client/stdio/init.py 內 errlog 定義開始,然後比較 Python subprocess.Popen 和 anyio.create_process 接受的 stderr 值。確認對 subprocess.DEVNULL 的預期處理方式,並相應更新 client API;當呼叫端可以傳入整數值而不會出現型別或執行階段問題,且現有的 stderr 行為仍獲得涵蓋時,即視為完成。

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

評估

技術堆疊
python
領域
api
Issue 類型
功能
難度
2/5
預估耗時
1-3 小時
活躍度
冷清
描述清晰度
基本清楚
新手友好度
68/100

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

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