Safe Local Python Executor

by maxim-saplin

44 stars
422 downloads
Not rated
GitHub

About

Stdio MCP Server wrapping custom Python runtime (LocalPythonExecutor) from Hugging Faces' `smolagents` framework. The runtime combines the ease of setup (compared to docker, VM, cloud runtimes) while providing safeguards and limiting operations/imports that are allowed inside the

Details

Author
maxim-saplin
GitHub stars
44
Downloads
422
Categories
Developer Tools, Cloud Service

- Exposes run_python tool for safe code execution
- Runs locally with no Docker or VM required
- Restricts imports to a safe list (collections, math, etc.)
- No file I/O operations allowed
- Uses Hugging Face's LocalPython

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name Safe Local Python Executor
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

Install via Smithery (npx -y @smithery/cli install @maxim-saplin/mcp_safe_local_python_executor --client claude) or manually: install uv, clone the repo, and run uv run mcp_server.py. Then configure Claude Desktop by adding the tool to its configuration file with the command uv and appropriate arguments.

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "safe local python executor": {
            "safe-local-python-executor": {
                "command": "uv",
                "args": [
                    "--directory",
                    "/path/to/mcp_local_python_executor/",
                    "run",
                    "mcp_server.py"
                ]
            }
        }
    }
}

McpServers

{
    "safe-local-python-executor": {
        "command": "uv",
        "args": [
            "--directory",
            "/path/to/mcp_local_python_executor/",
            "run",
            "mcp_server.py"
        ]
    }
}
An MCP server (stdio transport) that wraps Hugging Face's[`LocalPythonExecutor`(from the](https://github.com/huggingface/smolagents/blob/main/src/smolagents/local_python_executor.py)[`smolagents`framework). It is a custom Python runtime that provides basic isolation/security when running Python code generated by LLMs locally. It does not require Docker or VM. This package allows to expose the Python executor via MCP (Model Context Protocol) as a tool for LLM apps like Claude Desktop, Cursor or any other MCP compatible client. In case of Claude Desktop this tool is an easy way to add a missing Code Interpreter (available as a plugin in ChatGPT for quite a while already). - Exposes`run_python`tool - Safer execution of Python code compared to direct use of Python`eva()l` - Ran via uv in Python venv - No file I/O ops are allowed - Restricted list of imports - collections - datetime - itertools - math - queue - random - re - stat - statistics - time - unicodedata Be careful with execution of code produced by LLM on your machine, stay away from MCP servers that run Python via command line or using`eval()`. The safest option is using a VM or a docker container, though it requires some effort to set-up, consumes resources/slower. There're 3rd party servcices providing Python runtime, though they require registration, API keys etc. `LocalPythonExecutor`provides a good balance between direct use of local Python environment (which is easier to set-up) AND remote execution in Dokcer container or a VM/3rd party service (which is safe). Hugginng Face team has invested time into creating a quick and safe option to run LLM generated code used by their code agents. This MCP server builds upon it: To add a first layer of security, code execution in smolagents is not performed by the vanilla Python interpreter. We have re-built a more secure LocalPythonExecutor from the ground up. To install Safe Local Python Executor for Claude Desktop automatically via](https://huggingface.co/docs/smolagents/en/index)[Smithery: ``` `npx -y @smithery/cli install @maxim-saplin/mcp_safe_local_python_executor --client claude` ``` - Install`uv`(e.h.`brew install uv`on macOS or use](https://smithery.ai/server/@maxim-saplin/mcp_safe_local_python_executor)[official docs) - Clone the repo, change the directory`cd mcp_safe_local_python_executor` - The server can be started via command line`uv run mcp_server.py`, venv will be created automatically, depedencies (smollagents, mcp) will be installed - Make sure you have Claude for Desktop installed (download from](https://docs.astral.sh/uv/getting-started/installation/#__tabbed_1_2)[claude.ai) Edit your Claude for Desktop configuration file: - macOS:`~/Library/Application Support/Claude/claude_desktop_config.json` - Windows:`%APPDATA%\Claude\claude_desktop_config.json` - Or open Claude Desktop -> Settings -> Developer -> click "Edit Config" button ``` `{ "mcpServers": { "safe-local-python-executor": { "command": "uv", "args": ](https://claude.ai/desktop)[ "--directory", "/path/to/mcp_local_python_executor/", "run", "mcp_server.py" ] } } }` ``` - Restart Claude for Desktop - The Python executor tool will now be available in Claude (you'll see hammer icon in the message input field) Once configured, you can use prompts like: - "Calculate the factorial of 5 using Python" - "Create a list of prime numbers up to 100" - "Solve this equation (use Python): x^2 + 5x + 6 = 0" Clone the repo. Use`uv`to create venv, install dev dependencies, run tests: ``` `uv venv .venv uv sync --group dev python -m pytest tests/` ``` This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases. A stateful LSP runtime for AI agents: warm language server sessions with 50+ tools for go-to-definition, find-references, diagnostics, rename, and more across 30+ languages. MCP server that gives coding agents program-analysis primitives — data flow, call graphs, taint analysis — so they reason from ground truth instead of grep-and-guess. (same as the GitHub About — keeps your messaging consistent across the web). An MCP service that equips your workspace with a complete set of AI-accessible development tools for reading, editing, executing, and managing code. Visual Studio extension with 20 Roslyn-powered MCP tools for AI assistants. Semantic code navigation, symbol search, inheritance, call graphs, safe rename, build/test. Multi-language code-graph MCP server with 18 tools (find_symbol, callers, callees, blast_radius, dataflow_trace) for AI assistants — local-first, no API key required, ~3× fewer tokens than Claude+grep at the same correctness. AI-to-AI code review platform — Claude, Codex, and Gemini cross-check each other via MCP, REST API, and CLI for consensus-based results. Persistent code index using Tree-sitter for fast, precise code search. Replaces grep with ~50 token responses instead of 2000+. AI-powered code quality analysis to detect best practice violations, security issues, and architectural problems in real-time. Orchestrates a dual-AI engineering loop where a Primary AI plans and implements, while a Review AI validates and reviews, with continuous feedback for optimal code quality. Supports custom AI pairing (Claude, Codex, Gemini, etc.) ### AmazingMCP — MCP Server for .NET / C# Codebases An MCP server that gives AI agents deep understanding of C# codebases via Roslyn — type search, dependency graphs, usage analysis, and architecture overviews, all from a live in-memory compilation.
No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.