« All posts

venv-manager: A Python venv runtime built for humans and AI agents

venv-manager is an open-source Go tool with an MCP server and file watcher that manages Python venvs for both humans and AI coding agents.

venv-manager is a Python virtual-environment management tool distributed as a single static Go binary. Beyond a conventional CLI, it ships a Model Context Protocol (MCP) server that lets agentic clients like Claude Desktop, Cursor, or Zed call typed, JSON-schema-defined tools instead of guessing shell invocations.

The tool targets two recurring failure modes: humans accumulating sprawling, inconsistent venvs across machines, and LLMs generating Python that installs into the wrong interpreter, forgets to set VIRTUAL_ENV, or leaves broken environments after a crash. Its file watcher scans a script's imports with a lightweight AST parser and auto-installs missing packages on every save, keeping the venv converged with the code. An ephemeral exec mode adds OS-level sandboxing via sandbox-exec on macOS and bwrap on Linux for network-isolated, disposable runs.

Features like snapshot/rollback, clone, export/import, and a single-call JSON describe command — complete with a freeze_hash for O(1) drift detection — give agents a structured way to reason about environment state instead of parsing shell output. Optional uv backend support speeds up venv creation substantially. The project is MIT-licensed and buildable from source with Go 1.21+.