Python Interpreter — MCP server: what it does, how to install
Python Interpreter — an MCP server that runs Python snippets with stateful session memory. It retains imports, variables, and calculations across tool calls.
no license updated 2026-10-29
Open on GitHubWhat Python Interpreter does
This server supplies an AI agent with the execute_code tool to run Python commands interactively. Instead of terminating after each snippet, the execution runtime mimics a Jupyter notebook. Every variable, imported library, and function stays in memory for subsequent steps. The agent can verify its logic before returning output to you.
Running it locally via uv executes commands directly on your machine. To isolate executions from the host system, the author recommends the Docker MCP Toolkit with a volume mapped to /app/notebooks.
What it helps with
- run Python snippets directly through model tool calls
- retain state, imports, and variables across separate prompts
- let the model test code output before writing the final solution
- isolate script execution inside a Docker container
Example prompts for the agent
- Calculate 50 factorial using
execute_codeand store it in variablen - Use the variable
nfrom the previous step and convert it to string - Define a data cleanup function and verify it with sample inputs
How to install Python Interpreter
Install
The MCP registry has no launch command for it: see the repository README
Step by step, with commands for each platform: How to add an MCP server to Claude Code, Codex, Cursor, VS Code, Gemini CLI and more
Questions about Python Interpreter
How do you install Python Interpreter locally using uv?
Run uv pip install . inside the repository root, then register the server using uv run mcp install src/server.py.
What does Python Interpreter do?
It gives LLMs a persistent Python environment to test snippets, preserve variables, and verify outputs incrementally.
How can you test the tools before connecting an agent?
Execute uv run mcp dev src/server.py from the project root to open the developer web interface.