Skip to main content
Glama

run_python_in_venv

Execute Python code within a project's virtual environment to access its installed dependencies. Each call runs in a fresh interpreter subprocess, ensuring isolation.

Instructions

Run Python code inside a project's virtual environment.

    Spawns a fresh subprocess running `<venv>/bin/python -c CODE`.
    No namespace carries over between calls — each invocation is a
    new interpreter. Use this when the project has dependencies that
    aren't installed in the MCP server's Python environment.

    Args:
        code: Python source to execute.
        venv_path: Path to the venv directory (e.g., "/proj/.venv")
            OR direct path to the python binary. `~` is expanded.
        repl_id: Optional REPL to inherit cwd from. Falls back to
            cwd argument, then to server's cwd.
        cwd: Explicit working directory override.
        timeout_seconds: Kill after N seconds (capped at 600).
        env_extra: Additional env vars merged onto os.environ.
            PYTHONPATH is NOT auto-set — pass it via env_extra if
            the project uses src-layout and needs it.

    Returns:
        VenvResult dict with ok/python_path/cwd/stdout/stderr/
        exit_code/duration_ms/timed_out/truncation flags/error.
    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cwdNo
codeYes
repl_idNo
env_extraNo
venv_pathYes
timeout_secondsNo
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Discloses that each call spawns a new subprocess with no namespace carryover. Mentions timeout cap (600s) and that PYTHONPATH must be manually passed. Without annotations, this is strong, though it could note whether stderr is silently captured.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loaded with a one-line summary, followed by organized blocks for behavioral notes, parameter docs, and return type. Every sentence adds value; no redundancy or fluff.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Covers all 6 parameters, explicates the return structure (VenvResult), and includes edge cases like timeout truncation and env_extra PYTHONPATH guidance. Fully compensates for missing annotations and output schema.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Despite 0% schema description coverage, the description explains every parameter in detail. It clarifies venv_path can be a directory or binary path, repl_id inherits cwd, and env_extra merges onto os.environ. Adds substantial meaning beyond the bare schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Clearly states 'Run Python code inside a project's virtual environment' using a specific verb and resource. Distinguishes from sibling tools like run_python_in_repl by emphasizing isolation and dependency separation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly advises use when project dependencies are missing from the MCP server's environment. Gives important caveats like PYTHONPATH not being auto-set, but could be improved by naming an alternative sibling (e.g., run_python_in_repl) for contrast.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/angrysky56/local-repl-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server