You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
mcp: activate the per-session venv for child processes (#315)
## What
Sessions now export venv activation to the worker and any child it
spawns: `VIRTUAL_ENV` points at the per-session venv and its `bin` is
prepended to `PATH`.
## Why
Fixes#314. The worker was launched with the venv's `bin/python`, so
`import` resolved from the venv, but the child inherited the server's
`PATH` with no `VIRTUAL_ENV`. An in-session `pip install` (or any
`subprocess` that resolves a tool by name) hit the host instead of the
session venv, so the writable-venv promise only held through `python -m
pip`. This is the promise that justified removing the bring-your-own
interpreter in #312, so it should be fully true.
## Changes
- `create_venv` returns the venv directory; `venv_env` builds the
activation env (`VIRTUAL_ENV` + prepended `PATH`).
- `PythonSession::start` and the `repl` CLI apply it; the `#[cfg(test)]
spawn_command` seam passes an empty env, so unit tests stay venv-free.
## Tests
- New passthru test `mcp.tests.sessionVenv`: runs `ix-mcp eval
'__import__("shutil").which("pip")'` and asserts the resolved `pip`
lives under the session `.venv/bin`. Without activation this returns the
host pip or `None`, so the test actually distinguishes fixed from
broken.
- `cargo test -p ix-mcp` (4 pass), `cargo clippy` clean, `nix run
.#lint` clean, `nix build .#mcp.tests.sessionVenv` passes.
0 commit comments