From c3fd34a1a62d71e3f5d8a2418ad10c262cb1ab92 Mon Sep 17 00:00:00 2001 From: Tom Sheffler Date: Thu, 20 Mar 2025 09:28:57 -0700 Subject: [PATCH] Enhancement: make stderr of server subprocess configurable (#191) * make stderr of server subprocess configurable * Update stdio.py --------- Co-authored-by: David Soria Parra <167242713+dsp-ant@users.noreply.github.com> --- src/mcp/client/stdio.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/mcp/client/stdio.py b/src/mcp/client/stdio.py index 58e23bc..ac8ae7e 100644 --- a/src/mcp/client/stdio.py +++ b/src/mcp/client/stdio.py @@ -2,7 +2,7 @@ import os import sys from contextlib import asynccontextmanager from pathlib import Path -from typing import Literal +from typing import Literal, TextIO import anyio import anyio.lowlevel @@ -87,7 +87,7 @@ class StdioServerParameters(BaseModel): @asynccontextmanager -async def stdio_client(server: StdioServerParameters): +async def stdio_client(server: StdioServerParameters, errlog: TextIO = sys.stderr): """ Client transport for stdio: this will connect to a server by spawning a process and communicating with it over stdin/stdout. @@ -104,7 +104,7 @@ async def stdio_client(server: StdioServerParameters): process = await anyio.open_process( [server.command, *server.args], env=server.env if server.env is not None else get_default_environment(), - stderr=sys.stderr, + stderr=errlog, cwd=server.cwd, )