MCP · run-python

run-python

Run Python and install packages from natural language prompts.

MCP endpoint https://next.hal9.ai/mcp/mcpbuild/run-python

First time connecting an MCP? See Installing MCPs for setup steps in Claude, Claude Code, and other clients.

What it does

run-python turns a plain-language request into real Python. Instead of shipping a script or a rigid schema, an agent (or a human) describes the calculation — including which libraries to install — and the MCP writes, installs, and runs the code:

install a package that calculates space orbits and compute the Hohmann transfer time from Earth to Mars and back, departing 2026-09-08

Under the hood, the prompt is passed to a language model with two tools: install_packages and run_python. The model picks PyPI packages (for example skyfield, astropy, or poliastro), installs them into a sandbox, executes Python, and returns the printed result.

How agents use this MCP

Once connected, an agent can just ask in plain English. The MCP exposes two tools:

ToolParameterDescription
install_packagespackagesList of PyPI names, optionally with extras or version pins
run_pythoncodePython source to execute; results must be printed to stdout

The agent doesn't need to call the tools directly with structured arguments — it can just be asked in plain English, and it will:

  1. Read the requeste.g. "install an orbital-mechanics package and time a round trip to Mars departing today"
  2. Install what is neededCalls install_packages for PyPI libraries the code will import
  3. Run PythonWrites a short program, executes it in a sandbox, and returns stdout (and stderr on failure)

Typical uses: science and engineering calculations that need a library you don't have locally, quick numeric checks, or letting an agent install a package and compute something in one prompt.

Self-host or run locally

run-python is open source and built on the Hal9 agent structure. You can run it yourself instead of using the hosted version:

cd run-python
pip install -r requirements.txt
export GROQ_API_KEY=…
echo "print the first 10 primes" | python app.py
VariableRequired
GROQ_API_KEYYes
GROQ_MODELNo — defaults to qwen/qwen3.6-27b
PYTHON_TIMEOUTNo — seconds allowed for each run (default 60)
PIP_TIMEOUTNo — seconds allowed for pip install (default 180)
PACKAGES_DIRNo — directory for installed packages

Code runs in a subprocess with a timeout. API keys and deploy tokens are not passed into the sandbox. Full source, deploy workflow, and contributing guide: github.com/hal9ai/mcp.build/tree/main/run-python

Connecting from Claude, Claude Code, Cursor, or another MCP client? Point it at the endpoint above — full step-by-step instructions live on the Installing MCPs page.