Skip to content

fix(p04): a Python MCP server runs under the interpreter that spawned the agent - #40

Merged
harshuljain13 merged 1 commit into
mainfrom
fix/mcp-interpreter
Sep 9, 2026
Merged

fix(p04): a Python MCP server runs under the interpreter that spawned the agent#40
harshuljain13 merged 1 commit into
mainfrom
fix/mcp-interpreter

Conversation

@harshuljain13

Copy link
Copy Markdown
Collaborator

Found by running the demo suite the way a stranger would — venv not activated.

tests/test_mcp.py  →  McpError: Connection closed

command: python3 resolves through PATH, so outside an activated virtualenv it finds the
system interpreter, which has no mcp. The server subprocess dies on import, and the only
symptom 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 / python3 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, /usr/bin/python3.11) is left exactly as written: that author
named something specific and meant it.

Verification

The exact invocation that failed before now gives 50 passed, 12 skipped in agentship-demo
with no venv on PATH and no provider keys. Framework suite: 813 passed, 14 skipped, 3 xfailed.
Lint clean.

… 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.
@harshuljain13
harshuljain13 merged commit caab83c into main Sep 9, 2026
4 checks passed
@harshuljain13 harshuljain13 self-assigned this Sep 9, 2026
@harshuljain13 harshuljain13 added the bug Something isn't working label Sep 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant