fix(p04): a Python MCP server runs under the interpreter that spawned the agent - #40
Merged
Conversation
… the agent `command: python3` resolves through PATH, so outside an activated virtualenv it finds the SYSTEM interpreter -- which does not have `mcp`. The server subprocess dies on import and the only symptom the agent sees is "Connection closed", which points at the server rather than at the interpreter that could not import its dependency. Found by running the demo suite the way a stranger would, with the venv NOT activated: tests/test_mcp.py failed there and passed with the same venv on PATH. A spec whose result depends on shell state is not evidence of anything, which is worse than it merely being inconvenient. Bare `python`/`python3` now resolve to sys.executable -- by construction the environment where `mcp` exists, since it is the one running the agent that spawns the server. An absolute path or a non-Python command (npx, a pinned /usr/bin/python3.11) is left exactly as written, because that author named something specific and meant it. Verified end to end: the demo suite now passes 50/12-skipped with no venv on PATH and no provider keys -- the exact invocation that failed before. 813 passed (+2), 14 skipped, 3 xfailed. Lint clean.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Found by running the demo suite the way a stranger would — venv not activated.
command: python3resolves through PATH, so outside an activated virtualenv it finds thesystem interpreter, which has no
mcp. The server subprocess dies on import, and the onlysymptom the agent sees is "Connection closed" — pointing at the server rather than at the
interpreter that could not import its dependency.
The same spec passed with the venv on PATH and failed without it. A spec whose result depends
on shell state is not evidence of anything.
Fix
Bare
python/python3resolve tosys.executable— by construction the environment wheremcpexists, since it is the one running the agent that spawns the server. An absolute path ora non-Python command (
npx,/usr/bin/python3.11) is left exactly as written: that authornamed something specific and meant it.
Verification
The exact invocation that failed before now gives 50 passed, 12 skipped in
agentship-demowith no venv on PATH and no provider keys. Framework suite: 813 passed, 14 skipped, 3 xfailed.
Lint clean.