Execute code in secure cloud sandboxes using E2B. Use when running untrusted code, testing code generation output, creating isolated execution environments, running data analysis scripts, or needing ephemeral compute resources without local installation. Supports Python, JavaScript, TypeScript, and custom containers.
Run code in secure, isolated cloud sandboxes. Perfect for:
{
"mcpServers": {
"e2b": {
"command": "npx",
"args": ["-y", "@e2b/mcp-server"],
"env": {
"E2B_API_KEY": "your-api-key"
}
}
}
}
from e2b_code_interpreter import Sandbox
with Sandbox() as sandbox:
result = sandbox.run_code("print('Hello from sandbox!')")
print(result.logs.stdout)
| Sandbox | Pre-installed | Use Case |
|---|---|---|
code-interpreter | Python, numpy, pandas | Data analysis |
base | Minimal | Custom setups |
| Custom | User-defined | Specific needs |
sandbox.run_code("""
import pandas as pd
df = pd.DataFrame({'a': [1,2,3]})
print(df.describe())
""")
sandbox.run_code("!pip install requests")
sandbox.files.write("/tmp/data.txt", "content")
content = sandbox.files.read("/tmp/data.txt")
Copy and track progress:
Sandbox Task:
- [ ] Configure E2B API key
- [ ] Create sandbox instance
- [ ] Run code in sandbox
- [ ] Capture output/results
- [ ] Handle any errors
- [ ] Verify sandbox cleanup