diff --git a/src/mcp/client/stdio.py b/src/mcp/client/stdio.py index 58e23bc6..ac8ae7e7 100644 --- a/src/mcp/client/stdio.py +++ b/src/mcp/client/stdio.py @@ -2,7 +2,7 @@ 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, )