Propagate parent env to MCP server subprocess (#18)
The mcp SDK's StdioServerParameters does not pass the parent process's environment to the spawned server by default, so env vars set on the CLI process (notably MARCHWARDEN_MODEL) were silently dropped on the way to the researcher. Pass env=os.environ.copy() to StdioServerParameters so the server sees the same environment as the CLI. Also update scripts/docker-test.sh to forward MARCHWARDEN_MODEL into the container and to detect a non-TTY parent so non-interactive `ask` invocations don't fail with "the input device is not a TTY". Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
712638fe8c
commit
d0a732735e
2 changed files with 8 additions and 1 deletions
|
|
@ -40,6 +40,7 @@ async def call_research_tool(
|
||||||
params = StdioServerParameters(
|
params = StdioServerParameters(
|
||||||
command=sys.executable,
|
command=sys.executable,
|
||||||
args=["-m", "researchers.web.server"],
|
args=["-m", "researchers.web.server"],
|
||||||
|
env=os.environ.copy(),
|
||||||
)
|
)
|
||||||
async with stdio_client(params) as (read, write):
|
async with stdio_client(params) as (read, write):
|
||||||
async with ClientSession(read, write) as session:
|
async with ClientSession(read, write) as session:
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,13 @@ case "$cmd" in
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
mkdir -p "$HOME/.marchwarden/traces"
|
mkdir -p "$HOME/.marchwarden/traces"
|
||||||
docker run --rm -it \
|
tty_flag=""
|
||||||
|
if [ -t 0 ] && [ -t 1 ]; then tty_flag="-it"; fi
|
||||||
|
env_flag=""
|
||||||
|
if [ -n "${MARCHWARDEN_MODEL:-}" ]; then
|
||||||
|
env_flag="-e MARCHWARDEN_MODEL=$MARCHWARDEN_MODEL"
|
||||||
|
fi
|
||||||
|
docker run --rm $tty_flag $env_flag \
|
||||||
-v "$ROOT:/app" \
|
-v "$ROOT:/app" \
|
||||||
-v "$HOME/secrets:/root/secrets:ro" \
|
-v "$HOME/secrets:/root/secrets:ro" \
|
||||||
-v "$HOME/.marchwarden:/root/.marchwarden" \
|
-v "$HOME/.marchwarden:/root/.marchwarden" \
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue