Skip to main content

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

  1. 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
  2. kill_sandbox(sandbox_id: str)

    • Kills an existing sandbox
    • Returns empty string on success, error message on failure
  3. run_code(code: str, sandbox_id: str = None)

    • Executes Python code in a sandbox
    • Uses Jupyter Notebook syntax
    • If sandbox_id is provided, connects to existing sandbox
    • Otherwise creates a new sandbox
    • Returns stdout and stderr
  4. run_command(command: str, sandbox_id: str = None)

    • Executes a shell command in a sandbox
    • If sandbox_id is 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

Metadata

Release files for code-sandbox-mcp 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for code-sandbox-mcp 0.1.0
File Size Uploaded Provenance
code_sandbox_mcp-0.1.0.tar.gz 46.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for code-sandbox-mcp 0.1.0
File Interpreter ABI Platform
code_sandbox_mcp-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 50.9 kB

Release files / code_sandbox_mcp-0.1.0.tar.gz

Download URL code_sandbox_mcp-0.1.0.tar.gz
Size 46.8 kB
Tags Source
SHA-256 checksum
How to use checksums
746b5abf53b441983a0d0e9c12c0849577c13194b99b804540f6659c726462a3
BLAKE2b-256 checksum
How to use checksums
3083841a1f71faedad9a307b3d9a94cc68a3e3416a4e83a7d4294150fe153f3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.0

Release files / code_sandbox_mcp-0.1.0-py3-none-any.whl

Download URL code_sandbox_mcp-0.1.0-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0600f71bff4f66fd4f73eb21d21d016fe7d3598ab7a22fe88e9852348ed1f2e3
BLAKE2b-256 checksum
How to use checksums
072e4a7e66bb97a4b2a02b6dee14fd2424a7a9d72637378400c62f6e2ac04e2e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.10.0

Security for code-sandbox-mcp 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page