Back to MCP Directory
Safe Local Python Executor
Model Context Protocol moderate risk

Safe Local Python Executor

Executes Python code snippets locally within a restricted environment, offering a safer alternative to direct evaluation for LLM-generated code.

Connections & Capabilities

Connects To

GitHubDocker

Capabilities

exec

Quickstart

Install

npx -y @smithery/cli install @maxim-saplin/mcp_safe_local_python_executor --client claude

Config

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

Exposed MCP Tools (1)

moderate
run_python

Executes a Python code snippet and returns the output.

Executes arbitrary code, even within a sandbox.

Safety Assessment

This executor provides a balance between convenience and security. It's safer than direct Python execution but less secure than containerized solutions. Use with caution, especially with untrusted code sources.

  • Uses Hugging Face's LocalPythonExecutor for sandboxing.
  • Restricted list of allowed Python imports.
  • No file I/O operations permitted.
  • Runs in a Python venv via uv.
  • Code execution, even sandboxed, carries inherent risks.
  • Vulnerable to bypasses in the LocalPythonExecutor.
  • Potential for resource exhaustion if code isn't well-behaved.
  • Limited isolation compared to Docker or VMs.