Purpose: This is a stdio-transport MCP (Model Context Protocol) server that wraps the LocalPythonExecutor from the Hugging Face smolagents framework, exposing the Python executor as a tool to MCP-compatible clients such as Claude Desktop and Cursor, giving clients that lack a code interpreter the ability to execute Python locally.
Main capabilities: exposes the run_python tool; safer than using Python eval() directly; file I/O operations are not allowed; imports are restricted, allowing only collections, datetime, itertools, math, queue, random, re, stat, statistics, time, unicodedata; runs in a Python virtual environment via uv.
Usage: Can be automatically installed into Claude Desktop via Smithery, or installed manually—first install uv (e.g., brew install uv on macOS), clone the repository and cd mcp_safe_local_python_executor, then start it with uv run mcp_server.py; the virtual environment will be created automatically and the smolagents and mcp dependencies installed. When configuring Claude Desktop, edit the configuration file (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json; Windows: %APPDATA%\Claude\claude_desktop_config.json), or open it via Settings -> Developer -> Edit Config, add the configuration and restart; a hammer icon appearing in the input box indicates it is available. Example prompts include "Use Python to calculate the factorial of 5", "Generate a list of prime numbers under 100", "Use Python to solve the equation x^2 + 5x + 6 = 0".
Use cases: users who want to provide lightweight code interpretation capability for LLM applications locally without setting up Docker or a virtual machine.
Limitations: Official materials advise cautionwhen executing LLM-generated code, the safest solution is still a virtual machine or Docker container; this tool strikes a balance between ease of use and security, and is not fully isolated. Other details are not yet provided.