Compare commits

...

2 commits

Author SHA1 Message Date
8293cbfb68 Merge pull request 'Propagate parent env to MCP server subprocess' (#23) from fix/mcp-env-propagation into main
Reviewed-on: #23
Reviewed-by: archeious <archeious@unbiasedgeek.com>
2026-04-08 21:32:10 +00:00
Jeff Smith
d0a732735e 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>
2026-04-08 15:31:14 -06:00
2 changed files with 8 additions and 1 deletions

View file

@ -40,6 +40,7 @@ async def call_research_tool(
params = StdioServerParameters(
command=sys.executable,
args=["-m", "researchers.web.server"],
env=os.environ.copy(),
)
async with stdio_client(params) as (read, write):
async with ClientSession(read, write) as session:

View file

@ -31,7 +31,13 @@ case "$cmd" in
exit 1
fi
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 "$HOME/secrets:/root/secrets:ro" \
-v "$HOME/.marchwarden:/root/.marchwarden" \