Skip to content

Commit c3fd34a

Browse files
shefflerdsp-ant
andauthored
Enhancement: make stderr of server subprocess configurable (#191)
* make stderr of server subprocess configurable * Update stdio.py --------- Co-authored-by: David Soria Parra <[email protected]>
1 parent ae77772 commit c3fd34a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/mcp/client/stdio.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import sys
33
from contextlib import asynccontextmanager
44
from pathlib import Path
5-
from typing import Literal
5+
from typing import Literal, TextIO
66

77
import anyio
88
import anyio.lowlevel
@@ -87,7 +87,7 @@ class StdioServerParameters(BaseModel):
8787

8888

8989
@asynccontextmanager
90-
async def stdio_client(server: StdioServerParameters):
90+
async def stdio_client(server: StdioServerParameters, errlog: TextIO = sys.stderr):
9191
"""
9292
Client transport for stdio: this will connect to a server by spawning a
9393
process and communicating with it over stdin/stdout.
@@ -104,7 +104,7 @@ async def stdio_client(server: StdioServerParameters):
104104
process = await anyio.open_process(
105105
[server.command, *server.args],
106106
env=server.env if server.env is not None else get_default_environment(),
107-
stderr=sys.stderr,
107+
stderr=errlog,
108108
cwd=server.cwd,
109109
)
110110

0 commit comments

Comments
 (0)