From 422267e227db6f7c841e4aa90e0e372de4bd6522 Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 20 Mar 2025 18:43:45 +0000 Subject: [PATCH] Fixed issue #326 - MCP client with npx not working when env parameter of StdioServerParameters is set --- src/mcp/client/stdio.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/mcp/client/stdio.py b/src/mcp/client/stdio.py index ac8ae7e70..df721bbc3 100644 --- a/src/mcp/client/stdio.py +++ b/src/mcp/client/stdio.py @@ -103,7 +103,11 @@ async def stdio_client(server: StdioServerParameters, errlog: TextIO = sys.stder process = await anyio.open_process( [server.command, *server.args], - env=server.env if server.env is not None else get_default_environment(), + env=( + {**get_default_environment(), **server.env} + if server.env is not None + else get_default_environment() + ), stderr=errlog, cwd=server.cwd, )