MCP server for E2B code sandbox - Execute code and commands in secure E2B sandboxes
Project description
Code Sandbox MCP
MCP (Model Context Protocol) server for E2B code sandbox. This server provides tools to create, manage, and execute code in secure E2B sandboxes.
Features
- Create Sandbox: Create new E2B sandboxes with customizable timeout and template
- Kill Sandbox: Terminate existing sandboxes by ID
- Run Code: Execute Python code in sandboxes using Jupyter Notebook syntax
- Run Command: Execute shell commands in sandboxes
Installation
pip install -e .
Or using uv:
uv pip install -e .
Configuration
Create a .env file in the project root with your E2B credentials:
E2B_API_KEY=your_api_key_here
E2B_DOMAIN=your_domain_here
Usage
Running the Server
Using MCP CLI with Inspector (for testing):
uv run mcp dev code_sandbox_mcp/server.py
Or using MCP CLI:
uv run mcp run code_sandbox_mcp/server.py
Or directly with Python:
python -m code_sandbox_mcp.server
Or using the installed command:
code-sandbox-mcp
Available Tools
-
create_sandbox(timeout: int = 300, template: str = None)
- Creates a new E2B sandbox
- Returns the sandbox ID
- Parameters:
timeout: Sandbox timeout in seconds (default: 300)template: Optional template name or ID
-
kill_sandbox(sandbox_id: str)
- Kills an existing sandbox
- Returns empty string on success, error message on failure
-
run_code(code: str, sandbox_id: str = None)
- Executes Python code in a sandbox
- Uses Jupyter Notebook syntax
- If
sandbox_idis provided, connects to existing sandbox - Otherwise creates a new sandbox
- Returns stdout and stderr
-
run_command(command: str, sandbox_id: str = None)
- Executes a shell command in a sandbox
- If
sandbox_idis provided, connects to existing sandbox - Otherwise creates a new sandbox
- Returns stdout, stderr, and exit code
Development
This project uses:
- Python 3.10+
- E2B Code Interpreter SDK
- MCP Python SDK (FastMCP)
- python-dotenv for environment variable management
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file code_sandbox_mcp-0.1.0.tar.gz.
File metadata
- Download URL: code_sandbox_mcp-0.1.0.tar.gz
- Upload date:
- Size: 46.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
746b5abf53b441983a0d0e9c12c0849577c13194b99b804540f6659c726462a3
|
|
| MD5 |
8e6be10a2a8f2f792f04d86413cbf756
|
|
| BLAKE2b-256 |
3083841a1f71faedad9a307b3d9a94cc68a3e3416a4e83a7d4294150fe153f3e
|
File details
Details for the file code_sandbox_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: code_sandbox_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0600f71bff4f66fd4f73eb21d21d016fe7d3598ab7a22fe88e9852348ed1f2e3
|
|
| MD5 |
030c83a1ec93c0b46c8cf961c2144635
|
|
| BLAKE2b-256 |
072e4a7e66bb97a4b2a02b6dee14fd2424a7a9d72637378400c62f6e2ac04e2e
|