Provides safe Python code execution capabilities in isolated Docker containers with automatic container lifecycle management using docker-compose
MCP AgentRun Server
An MCP (Model Context Protocol) server that provides Python code execution capabilities using AgentRun. This server can execute Python code in isolated Docker containers for safe and reproducible code execution.
Features
- Safe Code Execution: Execute Python code in isolated Docker containers
- Container Management: Automatic container lifecycle management with docker-compose
- Environment Isolation: Each execution runs in a clean, isolated environment
- Error Handling: Comprehensive error handling and logging
- Easy Integration: Simple MCP interface for AI assistants and tools
Installation
Prerequisites
- Python 3.13 or higher
- Docker and Docker Compose
- UV package manager (recommended)
Setup
- Clone the repository:
- Run the setup script:
Usage
From Cursor
Go to Cursor Settings > Tools and Integrations > [New MCP Server] In the mcp.json file add the following:
Running the Server
Available Tools
Execute Python Code
Execute Python code in a container:
Returns the output of the code execution as a string.
Example Usage
See tests/test_build_container.py
for a complete example:
Project Structure
Configuration
The server requires a .env.dev
file in the agentrun/agentrun-api/
directory with the following variables:
Testing
Dependencies
agentrun>=0.2.5
: Python code execution in containersdocker>=7.1.0
: Docker API clientfastmcp>=2.10.5
: MCP server frameworkpydantic>=2.11.7
: Data validationdotenv>=0.9.9
: Environment variable managementtenacity>=9.1.2
: Retry logic
Development
Adding New Features
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Running in Development Mode
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Related Projects
This server cannot be installed
remote-capable server
The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.
Enables safe Python code execution in isolated Docker containers through the AgentRun framework. Provides automatic container lifecycle management and comprehensive error handling for secure and reproducible code execution.
Related MCP Servers
- -securityFlicense-qualityProvides isolated Docker environments for code execution, enabling users to create and manage containers, execute multi-language code, save and reproduce development environments, ensuring security and isolation.Last updated -10Python
- -securityAlicense-qualityAn interactive Python code execution environment that allows users and LLMs to safely execute Python code and install packages in isolated Docker containers.Last updated -20PythonApache 2.0
- -securityFlicense-qualityA secure Docker-based environment that allows AI assistants to safely execute code without direct access to the host system by running all code within isolated containers.Last updated -2Python
- -securityAlicense-qualityAn interactive Python code execution tool that allows users and LLMs to safely execute Python code and install packages in isolated Docker containers.Last updated -20PythonApache 2.0