modelcontextprotocol / modelcontextprotocol/python-sdk
More control over stderr in stdio client
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 24.3k
- Forks
- 4k
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 31
Description
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
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/mcp/client/stdio/init.py at the errlog definition referenced in the issue, then compare the accepted stderr values in Python subprocess.Popen and anyio.create_process. Confirm the intended handling of subprocess.DEVNULL and update the client API accordingly; done means callers can pass the integer value without type or runtime issues and the existing stderr behavior remains covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 68/100