modelcontextprotocol / modelcontextprotocol/python-sdk

More control over stderr in stdio client

Open Beginner friendly
#1,806 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs decision P3
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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.