run_pythonLABSCO SUMMARY
A code interpreter for Claude Desktop that sits between raw local Python and a full container.
The restricted import list is the whole design: arithmetic, dates, regex and statistics work, while file access and everything else does not. That makes it right for calculations and one-off scripting, and wrong for anything that needs to read your disk or hit the network — for those, a VM is still the honest answer.
What it is
A stdio server that wraps Hugging Face's LocalPythonExecutor from smolagents — a restricted Python runtime built for running code an LLM produced.
What you get
- run_python — one tool that executes a snippet and returns the result
- No file I/O: the executor refuses filesystem operations outright
- Imports limited to a fixed list — collections, datetime, itertools, math, queue, random, re, stat, statistics, time, unicodedata
- Runs locally under uv in a project venv, so there is no container to build and no remote runtime to sign up for
Requirements
uv, and a clone of the repository. The server starts with uv run mcp_server.py, which creates the venv and pulls smolagents and mcp on first launch. No account, no API key.
Setup effort
Build from source
USE CASES
Doing the arithmetic instead of guessing at it
Ask in plain language and let the model write and actually run the Python, so the number comes from math rather than from a token sampler.
Adding a code interpreter to Claude Desktop
One entry in the config file gives the desktop app a Python runtime it does not ship with.
Running generated code you have not read line by line
The executor blocks file I/O and allows only a fixed import list, so a bad snippet fails instead of touching your disk.
1 tool
Listed in project docs. Your client may show a different list.
BEFORE YOU INSTALL
What to know first
Tools you get
1 tool named in the project's documentation.
Where it runs
The documented client runs the server on your machine.
INSTALLATION
Connect your client
MCP Clients
Claude Desktop
{
"mcpServers": {
"safe-local-python-executor": {
"command": "uv",
"args": [
"--directory",
"<YOUR_PATH_TO_MCP_LOCAL_PYTHON_EXECUTOR>",
"run",
"mcp_server.py"
]
}
}
}