
PRIMS – Python Runtime Interpreter MCP Server
Run arbitrary Python in a secure, throw-away sandbox from your LLM agent via a single run_code MCP tool.
Add to your client
Copy the config for your MCP client and paste it into its config file.
./scripts/setup_env.shPaste into ~/Library/Application Support/Claude/claude_desktop_config.json
{
"mcpServers": {
"prims-python-runtime-interpreter-mcp-server": {
"command": "npx",
"args": [
"-y",
"mcp-remote",
"http://localhost:9000/mcp"
]
}
}
}Claude Desktop connects to remote servers through the `mcp-remote` proxy (installed on first run via npx). Restart Claude Desktop after saving.
Step-by-step guides: Add to Claude Desktop · Add to Cursor · Add to Windsurf
Before you start
- Python
- A virtual environment created via scripts/setup_env.sh (or Docker)
About PRIMS – Python Runtime Interpreter MCP Server
PRIMS is a lightweight MCP server that gives LLM agents a secure, reproducible Python execution sandbox. Each run_code call creates a fresh virtual-env, installs requested pip dependencies, optionally mounts read-only files, executes the code, and tears the workspace down afterward. Companion tools let agents browse the session workspace (list_dir, preview_file), mount remote datasets once (mount_file), and persist output files to permanent storage (persist_artifact). The server runs over MCP streamable HTTP at http://localhost:9000/mcp or inside Docker.
Tools & capabilities (5)
run_codeExecute user-supplied Python in an isolated, throw-away sandbox with optional pip dependencies and file mounts; streams back stdout/stderr.
list_dirList files and directories inside your session workspace.
preview_fileReturn up to 8 KB of a text file from your session workspace for quick inspection.
persist_artifactUpload a file from your output/ directory to a client-provided presigned URL for permanent storage.
mount_fileDownload a remote file once per session into mounts/<path> so it can be reused across run_code calls without re-supplying the URL.
When to use it
- Let an LLM agent run and test arbitrary Python code in a sandbox without touching the host environment
- Install ad-hoc pip packages per execution for one-off data tasks
- Mount a remote CSV or dataset once and analyze it across multiple code runs
- Generate plots or output files and persist them to cloud storage via a presigned URL
Security notes
Executes arbitrary user-supplied Python code. Each invocation runs in an isolated, throw-away virtual environment that is deleted after the call, but the server itself is alpha-stage and binds to 0.0.0.0:9000 by default — restrict network exposure accordingly. The persist_artifact tool uploads files to a client-provided presigned URL.
PRIMS – Python Runtime Interpreter MCP Server FAQ
How is code execution isolated?
Each run_code call spins up a fresh virtual environment, installs any requested pip packages, optionally mounts read-only files, runs the code, and then deletes the workspace.
What transport does it use?
MCP over streamable HTTP. Running python -m server.main binds the MCP endpoint at http://0.0.0.0:9000/mcp (clients connect to http://localhost:9000/mcp).
Can I run it in Docker?
Yes. The repo ships a Dockerfile and a scripts/docker_run.sh helper that builds and runs the server, printing the MCP URL when ready.
How do I retrieve generated files?
Use persist_artifact to upload an output/ file to a presigned URL, or fetch small artifacts directly via the /artifacts/<path> HTTP endpoint with your mcp-session-id header.
Alternatives to PRIMS – Python Runtime Interpreter MCP Server
Compare all alternatives →Microsoft's official browser-automation MCP using Playwright's accessibility tree (no vision model).
Up-to-date, version-specific library documentation injected into your coding agent.
Code intelligence engine that indexes repos into a persistent knowledge graph for AI coding agents.
Compare PRIMS – Python Runtime Interpreter MCP Server with: