6
6
7
7
from __future__ import annotations
8
8
9
- import os
10
9
from contextlib import asynccontextmanager
11
10
from datetime import timedelta
12
11
from typing import TYPE_CHECKING , Any , Literal , Protocol
@@ -69,7 +68,17 @@ class StdioConnection(TypedDict):
69
68
"""Command line arguments to pass to the executable."""
70
69
71
70
env : NotRequired [dict [str , str ] | None ]
72
- """The environment to use when spawning the process."""
71
+ """The environment to use when spawning the process.
72
+
73
+ If not specified or set to None, a subset of the default environment
74
+ variables from the current process will be used.
75
+
76
+ Please refer to the MCP SDK documentation for details on which
77
+ environment variables are included by default. The behavior
78
+ varies by operating system.
79
+
80
+ https://github.com/modelcontextprotocol/python-sdk/blob/c47c767ff437ee88a19e6b9001e2472cb6f7d5ed/src/mcp/client/stdio/__init__.py#L51
81
+ """
73
82
74
83
cwd : NotRequired [str | Path | None ]
75
84
"""The working directory to use when spawning the process."""
@@ -196,6 +205,8 @@ async def _create_stdio_session( # noqa: PLR0913
196
205
command: Command to execute.
197
206
args: Arguments for the command.
198
207
env: Environment variables for the command.
208
+ If not specified, inherits a subset of the current environment.
209
+ The details are implemented in the MCP sdk.
199
210
cwd: Working directory for the command.
200
211
encoding: Character encoding.
201
212
encoding_error_handler: How to handle encoding errors.
@@ -204,13 +215,6 @@ async def _create_stdio_session( # noqa: PLR0913
204
215
Yields:
205
216
An initialized ClientSession.
206
217
"""
207
- # NOTE: execution commands (e.g., `uvx` / `npx`) require PATH envvar to be set.
208
- # To address this, we automatically inject existing PATH envvar into the `env`,
209
- # if it's not already set.
210
- env = env or {}
211
- if "PATH" not in env :
212
- env ["PATH" ] = os .environ .get ("PATH" , "" )
213
-
214
218
server_params = StdioServerParameters (
215
219
command = command ,
216
220
args = args ,
0 commit comments