Skip to content

add cwd to StdioServerParameters #292

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/mcp/client/stdio.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import os
import sys
from contextlib import asynccontextmanager
from pathlib import Path
from typing import Literal

import anyio
Expand Down Expand Up @@ -66,6 +67,9 @@ class StdioServerParameters(BaseModel):
If not specified, the result of get_default_environment() will be used.
"""

cwd: str | Path | None = None
"""The working directory to use when spawning the process."""

encoding: str = "utf-8"
"""
The text encoding used when sending/receiving messages to the server
Expand Down Expand Up @@ -101,6 +105,7 @@ async def stdio_client(server: StdioServerParameters):
[server.command, *server.args],
env=server.env if server.env is not None else get_default_environment(),
stderr=sys.stderr,
cwd=server.cwd,
)

async def stdout_reader():
Expand Down