mcp_safe_local_python_executor MCP Server
mcp_safe_local_python_executor MCP Server GithubIntroducing Safe Local Python Executor: A Secure MCP Server for LLM Code Execution
If you're looking for a reliable and secure MCP server to execute Python code generated by LLMs, the Safe Local Python Executor is an excellent choice. Designed for users of MCP-compatible clients like Claude Desktop or Cursor, this server offers a safer way to run Python scripts locally without needing Docker or a VM.
What is Safe Local Python Executor?
Safe Local Python Executor is an MCP server that integrates Hugging Face's LocalPythonExecutor from the smolagents framework. It provides a custom Python runtime with basic isolation and security features, ensuring safer execution of LLM-generated code compared to using direct Python eval() functions. This server exposes a run_python tool for seamless integration into LLM applications.
Key Features of Safe Local Python Executor
- Safer code execution with restricted imports and no file I/O operations.
- Easy setup using uv in a Python virtual environment.
- Compatible with MCP clients like Claude Desktop for adding code interpreter functionality.
- Built on Hugging Face's secure LocalPythonExecutor for balanced security and ease of use.
How to Use Safe Local Python Executor
To get started, install uv, clone the repository, and run the server with a simple command. Configure it in your MCP client, such as Claude Desktop, by updating the configuration file. Once set up, you can use prompts like "Calculate the factorial of 5 using Python" directly in the app.
User Case
Ideal for developers and AI enthusiasts, Safe Local Python Executor enables secure local execution of Python scripts in LLM apps, enhancing productivity without compromising safety.
FAQ
- Is Safe Local Python Executor secure? Yes, it offers better security than direct eval() by restricting operations and imports.
- Do I need Docker? No, it runs locally without additional containers.
Visual Examples
## Demo Videos