Skip to main content
Glama
code-sandbox-mcp

code-sandbox-mcp

by feifeigood

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

Related MCP server: e2b-sandbox-mcp

Installation

pip install code-sandbox-mcp

Or using uv:

uv pip install code-sandbox-mcp

Usage

Configuration

Add the following configuration to your MCP client settings JSON file (e.g., ~/.config/claude_desktop/claude_desktop_config.json for Claude Desktop, or .cursor/mcp.json for Cursor):

{
  "mcpServers": {
    "code-sandbox-mcp": {
      "command": "uv",
      "args": ["run", "code-sandbox-mcp"],
      "env": {
        "E2B_API_KEY": "your_api_key_here",
        "E2B_DOMAIN": "your_domain_here"
      }
    }
  }
}

Replace your_api_key_here and your_domain_here with your actual E2B credentials.

Restart your MCP client to load the configuration. The tools will be available in your MCP-enabled application!

License

MIT

Available Tools

4 tools
create_sandboxA
Create a new E2B sandbox and return its ID.

Args:
    timeout: Timeout for the sandbox in seconds, default is 300 seconds
    template: Optional template name or ID to use for creating the sandbox. If not provided, the default template is used.

Returns:
    JSON string containing the sandbox ID

Inputs: timeout, template. Returns: result

kill_sandboxA
Kill an E2B sandbox by its ID.

Args:
    sandbox_id: The ID of the sandbox to kill
    
Returns:
    JSON string containing error message if failed, empty string if successful

Inputs: sandbox_id (required). Returns: result

run_codeA
Run python code in a secure sandbox by E2B. Using the Jupyter Notebook syntax.

Args:
    code: Python code to execute
    sandbox_id: Optional sandbox ID to connect to an existing sandbox. If not provided, a new sandbox will be created.
    
Returns:
    JSON string containing stdout and stderr from code execution

Inputs: code (required), sandbox_id. Returns: result

run_commandA
Run a shell command in an E2B sandbox.

Args:
    command: Shell command to execute
    sandbox_id: Optional sandbox ID to connect to an existing sandbox. If not provided, a new sandbox will be created.

Returns:
    JSON string containing stdout, stderr, and exit code from command execution

Inputs: command (required), sandbox_id. Returns: result

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 4 tools

    Disambiguation4/5

    Each tool has a clear primary purpose, but run_command and run_code can implicitly create sandboxes, which overlaps with create_sandbox's role. Descriptions are clear enough to avoid confusion, but the optional sandbox_id in both creates some ambiguity about which tool to use for sandbox creation.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern: create_sandbox, kill_sandbox, run_command, run_code. This makes the API predictable and easy to navigate.

    Tool Count4/5

    Four tools is slightly on the small side but well-matched to the server's narrow scope of sandbox lifecycle management and code execution. It falls within the typical well-scoped range, though one or two additional tools (e.g., list_sandboxes) would be reasonable.

    Completeness2/5

    The tool set has a significant lifecycle gap: run_command and run_code can create sandboxes implicitly but do not return the sandbox ID, making those sandboxes impossible to kill or reuse. There is also no way to list active sandboxes or check their status, limiting operational visibility and control.

    Maintenance

    ActivityInactive
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers