Skip to content

More control over stderr in stdio client #1806

Open

Description

@sesajad

Description

Currently, a TextIO object (defaulting to sys.stderr) must be set for errlog when creating a new stdio client session.

async def stdio_client(server: StdioServerParameters, errlog: TextIO = sys.stderr):

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:
#156
langchain-ai/langchain-mcp-adapters#72

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

Activity

  1. changed the title [-]More Control over stderr in stdio client[/-] [+]More control over stderr in stdio client[/+] on Dec 25, 2025
  2. added
    enhancementRequest for a new feature that's not currently supported
    ready for workEnough information for someone to start working on
    P3Nice to haves, rare edge cases
    on Dec 31, 2025
  3. SamSi0322 commented on Apr 10, 2026

    @SamSi0322

    I'll take this. The fix is straightforward — updating the type hints on stdio_client() and _create_platform_compatible_process() to accept int (for subprocess.DEVNULL, subprocess.PIPE, etc.) in addition to TextIO. Will have a PR up shortly.

  4. added
    needs decisionIssue is actionable, needs maintainer decision on whether to implement
    and removed
    ready for workEnough information for someone to start working on
    on Apr 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Nice to haves, rare edge casesenhancementRequest for a new feature that's not currently supportedneeds decisionIssue is actionable, needs maintainer decision on whether to implement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions