Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/mcp/client/stdio.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,16 @@ class StdioServerParameters(BaseModel):

@asynccontextmanager
async def stdio_client(
server: StdioServerParameters, errlog: TextIO = sys.stderr
server: StdioServerParameters, errlog: TextIO | int = sys.stderr
) -> AsyncGenerator[TransportStreams, None]:
"""Spawns an MCP server subprocess and connects to it over stdin/stdout.

Args:
server: Parameters for the server process to spawn.
errlog: Where to send the server's stderr. Accepts a text stream
(e.g. ``sys.stderr``) or an integer file descriptor, including
``subprocess.DEVNULL`` to discard stderr entirely.

Raises:
OSError: If the server process cannot be spawned.
ValueError: If the spawn parameters are invalid (embedded NUL bytes).
Expand Down Expand Up @@ -329,7 +335,7 @@ async def _create_platform_compatible_process(
command: str,
args: list[str],
env: dict[str, str] | None = None,
errlog: TextIO = sys.stderr,
errlog: TextIO | int = sys.stderr,
cwd: Path | str | None = None,
) -> ServerProcess:
"""Spawns the server in its own kill scope.
Expand Down
7 changes: 5 additions & 2 deletions src/mcp/os/win32/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ async def create_windows_process(
command: str,
args: list[str],
env: dict[str, str] | None = None,
errlog: TextIO | None = sys.stderr,
errlog: TextIO | int | None = sys.stderr,
cwd: Path | str | None = None,
) -> Process | FallbackProcess:
"""Creates a subprocess with Job Object support for tree termination.
Expand All @@ -149,6 +149,9 @@ async def create_windows_process(
with it; children spawned before the assignment completes are not captured
(see the inline note below).

errlog accepts a text stream (e.g. ``sys.stderr``), an integer file
descriptor (e.g. ``subprocess.DEVNULL``), or ``None``.

Returns:
Process | FallbackProcess: The spawned process with async stdin/stdout streams.
"""
Expand Down Expand Up @@ -177,7 +180,7 @@ async def _create_windows_fallback_process(
command: str,
args: list[str],
env: dict[str, str] | None = None,
errlog: TextIO | None = sys.stderr,
errlog: TextIO | int | None = sys.stderr,
cwd: Path | str | None = None,
) -> FallbackProcess:
"""Spawns via subprocess.Popen and wraps it in FallbackProcess."""
Expand Down
Loading