maxim-saplin/mcp_safe_local_python_executor
FreeSafe Python interpreter based on HF Smolagents `LocalPythonExecutor`
About maxim-saplin/mcp_safe_local_python_executor
A Model Context Protocol (MCP) server that wraps Hugging Face's LocalPythonExecutor from the smolagents framework to provide a safer local Python execution environment for LLM-generated code. It runs via uv in a Python virtual environment, restricts file I/O operations, and limits allowed imports to a curated set (collections, datetime, itertools, math, queue, random, re, stat, statistics, time, unicodedata). The server exposes a run_python tool that can be used with MCP clients such as Claude Desktop, Cursor, or any other compatible application. It balances ease of setup (no Docker or VM required) with basic security, making it a quick local alternative to remote code interpreter services while still requiring caution when executing LLM-produced code.
Key Features
Pros & Cons
- Quick and easy setup: no Docker, VM, or cloud registration required
- Provides basic isolation and security compared to using `eval()` or command-line execution
- Free and open-source (MIT license)
- Uses proven safeguards from Hugging Face's smolagents framework
- Works with popular MCP clients like Claude Desktop and Cursor
- Not as secure as running code in a Docker container or VM (still runs on the local machine)
- Limited to a restricted set of imports; many standard library modules unavailable
- No file I/O allowed, limiting certain use cases (e.g., reading/writing files)
- Still requires trust in the LLM output—user must be cautious about what code is executed