Enables interaction via curl commands for executing Python code, checking server health, and streaming real-time output through the HTTP API.
Leverages Docker containers for secure code execution and isolation, with the ability to run Python code in the 'my-llm-sandbox' container.
Uses Express as the server framework as indicated in the project structure.
Provides integration with n8n automation platform, allowing execution of Python code with dynamic inputs and data processing capabilities through HTTP API endpoints.
Requires Node.js (version 18+) as a runtime environment for the server.
Supports testing and interaction through Postman for code execution, health checking, and SSE streaming capabilities.
Enables execution of Python code with full library access in isolated Docker containers, supporting various operations from simple scripts to data processing.
Built with TypeScript as shown in the project structure with TypeScript configuration files.
MCP Executor Server
A secure, Docker-based code execution server that provides HTTP API endpoints for running Python code in isolated containers. Perfect for integration with automation tools like n8n, web applications, or any HTTP client.
🚀 Features
- 🔒 Secure Execution - Code runs in isolated Docker containers
- ⚡ Fast Performance - Optimized for quick code execution
- 📡 Real-time Streaming - Server-Sent Events (SSE) for live output
- 🌐 HTTP API - RESTful endpoints for easy integration
- 📊 Health Monitoring - Built-in health check endpoint
- 🐍 Python Support - Execute Python code with full library access
- 🔧 Docker Integration - Uses
my-llm-sandbox
container for execution
📋 Prerequisites
- Docker Desktop - Must be running and in Linux containers mode
- Node.js - Version 18+ recommended
- Docker Image -
my-llm-sandbox
image must be available locally
🛠️ Installation & Setup
1. Clone and Navigate
2. Install Dependencies
3. Start the Server
Development Mode (Recommended):
Production Mode:
The server will start on http://localhost:3000
📡 API Endpoints
1. Execute Code
POST /execute
Execute Python code in a secure Docker container.
Request Body:
Response:
2. Real-time Streaming
GET /sse
Connect to Server-Sent Events for real-time output streaming.
Usage:
- Open in browser:
http://localhost:3000/sse
- Or use curl:
curl http://localhost:3000/sse
Output Format:
3. Health Check
GET /health
Check if the server is running properly.
Response:
🧪 Testing
Using Postman
- Test Health Check:
- Method:
GET
- URL:
http://localhost:3000/health
- Method:
- Test Code Execution:
- Method:
POST
- URL:
http://localhost:3000/execute
- Headers:
Content-Type: application/json
- Body:
- Method:
- Test SSE Streaming:
- Method:
GET
- URL:
http://localhost:3000/sse
- Keep connection open while testing
/execute
- Method:
Using curl
🔧 n8n Integration
Basic Setup
- Add HTTP Request Node
- Configure:
- Method:
POST
- URL:
http://localhost:3000/execute
- Headers:
Content-Type: application/json
- Body (JSON):
- Method:
Advanced Examples
Dynamic Code Execution:
Data Processing:
File Operations:
📁 Project Structure
🔍 Troubleshooting
Common Issues
- Docker not running:
- Ensure Docker Desktop is running
- Check that it's in Linux containers mode
- Container not found:
- Verify
my-llm-sandbox
image exists:docker images
- Rebuild if needed:
docker build -t my-llm-sandbox .
- Verify
- Permission denied:
- Ensure Docker has proper permissions
- Check Docker socket access
- Slow responses:
- First request may take 2-3 seconds (container startup)
- Subsequent requests should be fast (1-2 seconds)
Debug Mode
Enable detailed logging by checking the server console output for:
[STDOUT]
- Docker container output[STDERR]
- Docker container errorsExecuting code in Docker container...
- Request processing
🚀 Deployment
Docker Deployment
- Build the image:
- Run the container:
Environment Variables
PORT
- Server port (default: 3000)NODE_ENV
- Environment (development/production)
📝 Examples
Simple Python Code
Mathematical Operations
Data Processing
File Operations
🤝 Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
📄 License
This project is licensed under the ISC License.
🆘 Support
For issues and questions:
- Check the troubleshooting section
- Review the console logs
- Test with simple code examples
- Verify Docker setup
Happy coding! 🎉
This server cannot be installed
A secure server that enables code execution in isolated Docker environments, supporting Python with strict security constraints including network isolation, limited filesystem access, and resource limitations.
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-qualityFacilitates isolated code execution within Docker containers, enabling secure multi-language script execution and integration with language models like Claude via the Model Context Protocol.Last updated -2PythonMIT License
- -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 -18PythonApache 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