Skip to content

Commit 1ba1beb

Browse files
authored
set PATH envvar for stdio if not provided (#57)
1 parent 349ebdc commit 1ba1beb

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

langchain_mcp_adapters/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import os
12
from contextlib import AsyncExitStack
23
from types import TracebackType
34
from typing import Any, Literal, Optional, TypedDict, cast
@@ -184,6 +185,13 @@ async def connect_to_server_via_stdio(
184185
encoding: Character encoding
185186
encoding_error_handler: How to handle encoding errors
186187
"""
188+
# NOTE: execution commands (e.g., `uvx` / `npx`) require PATH envvar to be set.
189+
# To address this, we automatically inject existing PATH envvar into the `env` value,
190+
# if it's not already set.
191+
env = env or {}
192+
if "PATH" not in env:
193+
env["PATH"] = os.environ.get("PATH", "")
194+
187195
server_params = StdioServerParameters(
188196
command=command,
189197
args=args,

0 commit comments

Comments
 (0)