Skip to content

fix: allow integer file descriptors for errlog in stdio_client#2410

Open
RudrenduPaul wants to merge 2 commits intomodelcontextprotocol:mainfrom
RudrenduPaul:fix/stdio-errlog-accept-int
Open

fix: allow integer file descriptors for errlog in stdio_client#2410
RudrenduPaul wants to merge 2 commits intomodelcontextprotocol:mainfrom
RudrenduPaul:fix/stdio-errlog-accept-int

Conversation

@RudrenduPaul
Copy link
Copy Markdown

Fixes #1806

stdio_client() typed errlog as TextIO, preventing callers from passing
integer file descriptors such as subprocess.DEVNULL. The underlying subprocess
calls (anyio.open_process and subprocess.Popen) already accept integers for
stderr — this was a type-annotation gap, not a runtime limitation.

Motivation and Context

Users running CLI tools or embedding MCP servers in larger applications often
want to suppress server stderr entirely. subprocess.DEVNULL is the standard
Python way to do this, but passing it to stdio_client() raised a type error
because errlog was annotated as TextIO only.

How Has This Been Tested?

Type annotation change only — no runtime behaviour changes. The underlying
anyio.open_process and subprocess.Popen calls already accept int for
stderr. All existing tests continue to pass.

Breaking Changes

None. Existing callers using TextIO (e.g. sys.stderr) are unaffected.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added or updated documentation as needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

More control over stderr in stdio client

1 participant