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>
68 lines
1.7 KiB
Bash
Executable file
68 lines
1.7 KiB
Bash
Executable file
#!/usr/bin/env bash
|
|
# Helper for the dockerized test/run environment.
|
|
#
|
|
# Usage:
|
|
# scripts/docker-test.sh build Build the image
|
|
# scripts/docker-test.sh test Run pytest in the container
|
|
# scripts/docker-test.sh ask "..." Run `marchwarden ask` end-to-end
|
|
# (mounts ~/secrets ro and ~/.marchwarden rw)
|
|
# scripts/docker-test.sh shell Drop into a bash shell in the container
|
|
|
|
set -euo pipefail
|
|
|
|
IMAGE="marchwarden-test"
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
|
|
cmd="${1:-test}"
|
|
shift || true
|
|
|
|
case "$cmd" in
|
|
build)
|
|
docker build -t "$IMAGE" "$ROOT"
|
|
;;
|
|
|
|
test)
|
|
docker run --rm -v "$ROOT:/app" "$IMAGE" pytest -q "$@"
|
|
;;
|
|
|
|
ask)
|
|
if [ ! -f "$HOME/secrets" ]; then
|
|
echo "error: ~/secrets not found on host" >&2
|
|
exit 1
|
|
fi
|
|
mkdir -p "$HOME/.marchwarden/traces"
|
|
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" \
|
|
"$IMAGE" marchwarden ask "$@"
|
|
;;
|
|
|
|
replay)
|
|
mkdir -p "$HOME/.marchwarden/traces"
|
|
docker run --rm \
|
|
-v "$ROOT:/app" \
|
|
-v "$HOME/.marchwarden:/root/.marchwarden" \
|
|
"$IMAGE" marchwarden replay "$@"
|
|
;;
|
|
|
|
shell)
|
|
docker run --rm -it \
|
|
-v "$ROOT:/app" \
|
|
-v "$HOME/secrets:/root/secrets:ro" \
|
|
-v "$HOME/.marchwarden:/root/.marchwarden" \
|
|
"$IMAGE" bash
|
|
;;
|
|
|
|
*)
|
|
echo "unknown command: $cmd" >&2
|
|
echo "usage: $0 {build|test|ask|replay|shell}" >&2
|
|
exit 1
|
|
;;
|
|
esac
|