# E2B MCP

> E2B provides secure cloud sandboxes for running code, letting your agent execute Python, JavaScript, or shell commands in isolated Firecracker microVMs. Spin up environments in milliseconds—it's perfect for safely testing untrusted logic without risking core infrastructure.

## Overview
- **Category:** superpower
- **Price:** Free
- **Tags:** sandboxing, code-execution, micro-vms, firecracker, ai-agents, isolated-environment

## Description

When you build AI agents that need to run actual code—say, processing a file or making an API call with Python—you can't just let them run it directly on your main server. The risk is too high. This MCP lets your agent spin up completely isolated environments where all the action happens. It’s like giving your AI client its own tiny, secure computer that only exists for the task at hand. Your agent can launch a sandbox with a specific setup, run the script, and then shut it down clean. You get full visibility into what's running using one set of tools, and you can terminate anything when you’re done. Because this whole system is hosted on Vinkius, your agent connects once to manage these environments across any compatible AI client.

## Tools

### create_sandbox
Starts an isolated Linux virtual machine environment using templates like 'python3', 'node', or 'base'.

### kill_sandbox
Stops and permanently deletes a running sandbox, freeing up the allocated computing resources.

### list_sandboxes
Shows a list of all currently active sandboxes in your account, detailing their status and resource usage.

## Prompt Examples

**Prompt:** 
```
Create a Python sandbox so I can run a data analysis script.
```

**Response:** 
```
Sandbox created successfully!

| Sandbox ID | Template | Status | Info |
|---|---|---|---|
| `sbx_abc123` | python3 | running | Timeout: 300s |

Your sandbox is ready. It's an isolated Linux environment with Python 3.11 pre-installed. Use the sandbox ID to execute code.
```

**Prompt:** 
```
Show me all my running sandboxes.
```

**Response:** 
```
Found 3 active sandboxes:

| Sandbox ID | Template | Status | Info |
|---|---|---|---|
| `sbx_abc123` | python3 | running | Started: 5min ago |
| `sbx_def456` | node | running | Started: 12min ago |
| `sbx_ghi789` | base | running | Started: 1h ago |
```

**Prompt:** 
```
Kill sandbox sbx_ghi789 — I'm done with it.
```

**Response:** 
```
Sandbox terminated successfully!

| Sandbox ID | Status | Info |
|---|---|---|
| `sbx_ghi789` | killed | Sandbox terminated — resources released |
```

## Capabilities

### Launch isolated code runtimes
Starts a new micro-isolated Linux environment for running specific languages like Python or Node.js.

### Monitor active environments
Retrieves a list of every sandbox currently running, showing its status and resource usage.

### Cleanly terminate resources
Permanently deletes a specific sandbox environment to release associated compute cycles and storage space.

## Use Cases

### Testing a data script
A data scientist wants the agent to process a CSV file using pandas. They first use `create_sandbox` with the 'python3' template, run the analysis, and then immediately call `kill_sandbox`. This ensures zero lingering resources and 100% clean reporting.

### Monitoring agent activity
The ops engineer needs to see if their team has left several test sandboxes running overnight. They use `list_sandboxes` to quickly audit all active environments before billing cycle ends, catching resource leaks immediately.

### Building an interactive coding platform
An EdTech developer needs students to write and run JavaScript code without any risk. The agent uses `create_sandbox` with the 'node' template; when done, it relies on clear instructions to use `kill_sandbox`.

### Debugging complex workflows
The developer runs a multi-step workflow and suspects resource leakage. They use `list_sandboxes` multiple times throughout the test run, confirming that every sandbox they intended to shut down was properly terminated by calling `kill_sandbox`.

## Benefits

- Guaranteed isolation: Code runs in dedicated Firecracker microVMs. This means a failure or crash in one sandbox doesn't affect your core system—it just dies in its own little container.
- Speedy setup: You spin up new environments in around 150 milliseconds. It’s fast enough that running code feels like part of the natural conversation flow, not an external delay.
- Full resource control: Use `list_sandboxes` to check what's active and `kill_sandbox` when you're done. You never leave orphaned environments running and eating up credits.
- Reproducibility for data work: Data science teams can run the exact same analysis script multiple times, knowing each run started from a pristine, isolated environment.
- Multi-language support: Need to run Python *and* Node? Just create different sandboxes with specific templates. It handles all three major languages securely.

## How It Works

The bottom line is that your AI client treats running code like a temporary job, not a permanent fixture on the server.

1. Subscribe to this MCP on Vinkius and provide your E2B API key credentials.
2. Your agent calls the `create_sandbox` tool, specifying the desired template (Python, Node, etc.).
3. The sandbox launches in milliseconds. Your agent uses this isolated environment for execution, then calls `kill_sandbox` to clean up.

## Frequently Asked Questions

**How fast is it to create a sandbox using create_sandbox?**
Sandboxes start up quickly; they launch in about 150 milliseconds. This speed makes them ideal for real-time agent interactions where latency matters.

**Do I have to use kill_sandbox after I run a script?**
Yes, you should always call `kill_sandbox` when the work is done. It releases the allocated resources and prevents accidental billing or resource exhaustion from abandoned environments.

**What templates are available for create_sandbox?**
The service supports several predefined templates, including 'base' (the default), 'python3', and 'node'. You pick the template that matches the language you need to run code in.

**Can I check if my sandboxes are running with list_sandboxes?**
Absolutely. `list_sandboxes` lets you see all active environments, giving you a clear overview of resource usage and status across your account.

**How does using `create_sandbox` ensure that code running in one sandbox cannot affect others?**
It uses Firecracker microVMs for strong isolation. This architecture gives every sandbox its own kernel and filesystem, guaranteeing that even if a script crashes or runs malicious code, it stays contained within that specific environment.

**If I forget to call `kill_sandbox`, will it impact my billing?**
While resources are designed to be managed, leaving sandboxes running increases resource consumption and associated costs. Always calling `kill_sandbox` immediately after your task finishes is the best way to stop accruing charges.

**Can I set a custom execution time limit when using the `create_sandbox` tool?**
Yes, you can adjust the timeout parameter. Although the default is 300 seconds, specifying a shorter or longer timeout ensures the sandbox matches your script's expected runtime and prevents unnecessary resource retention.

**What detailed metrics does `list_sandboxes` provide besides status?**
It gives you more than just active status. You can see the template used for each environment, along with details on its current resource usage and when it was last started, which is critical for monitoring.

**How secure are E2B sandboxes?**
E2B sandboxes run as dedicated Firecracker microVMs — the same technology used by AWS Lambda and Fargate. Each sandbox has its own Linux kernel, filesystem, and network stack, providing hardware-level isolation. Code running in a sandbox cannot access your host system, other sandboxes, or any external resources unless explicitly configured.

**What programming languages are supported?**
E2B supports Python, JavaScript/TypeScript, R, Java, and Bash out of the box. You can also create custom sandbox templates with any pre-installed tools, libraries, or system dependencies. The base template provides a full Ubuntu Linux environment where you can install anything via apt or pip.

**How does E2B pricing work?**
E2B uses usage-based pricing billed per second of compute time. The free Hobby plan includes a one-time $100 credit (no credit card required), up to 20 concurrent sandboxes, and 1-hour maximum session length. The Pro plan starts at $150/month with 24-hour sessions and higher concurrency limits.