
E2B SDK
Author: e2b-dev
Description: Open-source infrastructure/SDK for running AI-generated code in secure isolated cloud sandboxes (core SDK used by E2B Code Interpreter). Requires an E2B API key to create and control sandboxes.
Stars: 11.2k
Forks: 793
License: Apache License 2.0
Category: Enterprise
Overview
Installation
npm i @e2b/code-interpreterpip install e2b-code-interpreterE2B_API_KEY=e2b_***import { Sandbox } from '@e2b/code-interpreter'
const sandbox = await Sandbox.create()
await sandbox.runCode('x = 1')
const execution = await sandbox.runCode('x+=1; x')
console.log(execution.text) // outputs 2from e2b_code_interpreter import Sandbox
with Sandbox.create() as sandbox:
sandbox.run_code("x = 1")
execution = sandbox.run_code("x+=1; x")
print(execution.text) # outputs 2Sandbox.create
Create a new E2B Sandbox instance (cloud-isolated environment) for running code
sandbox.runCode
Execute code inside a Sandbox (JavaScript/TypeScript API) and return an execution result (e.g., with a .text output)
sandbox.run_code
Execute code inside a Sandbox (Python API) and return an execution result (e.g., with a .text output)
FAQs
How does E2B's Firecracker microVM isolation differ from Docker container isolation for running AI-generated code?
Firecracker microVMs provide hardware-level isolation with dedicated kernel instances, preventing kernel exploits from escaping to the host. Docker containers share the host kernel through namespaces, making them vulnerable to privilege escalation. For AI-generated code, Firecracker's hypervisor layer blocks malicious outputs from exploiting kernel vulnerabilities at the hardware virtualization boundary that containers cannot enforce.
How do I configure E2B sandbox timeouts to avoid the silent 60-second default fallback issue?
Explicitly set timeout parameters in both the start and wait methods of your sandbox calls. The silent fallback occurs when you specify timeout in only one location. For example, use `sandbox.start(timeout=300)` and `execution.wait(timeout=300)` together. If you only set one, the system reverts to sixty seconds regardless of your specified value, causing unexpected terminations during longer operations.
How do I set up the E2B MCP server with Cursor or VS Code instead of Claude Desktop?
The manual installation method should work: add the JSON configuration snippet to your client's MCP config file with your E2B API key in the env section. For Cursor, check the MCP server settings. For VS Code with GitHub Copilot, enable MCP features first. Neither platform has published E2B-specific documentation, so reference their general MCP integration guides.
Can MCP servers be customized for specific enterprise applications?
Yes, MCP servers support extensive enterprise customization. Organizations can build custom servers using the protocol specification, creating domain-specific tools, proprietary API integrations, and tailored environments. Open-source implementations allow modification of authentication, compliance logging, data residency enforcement, and internal infrastructure integration. Platforms like E2B enable custom sandbox templates matching enterprise tech stacks.
Can MCP servers act as proxies for other MCP servers?
Yes, MCP servers can proxy other MCP servers. Projects like MCPJungle operate as unified registries, while AWS MCP Proxy and Databricks provision managed endpoints that bridge clients to backend servers. This proxy pattern centralizes authentication, simplifies multi-server access, and has led to "MCP Gateway" architectures that handle infrastructure complexity across distributed MCP resources.
What are the best methods to implement strong authentication for MCP servers?
Strong MCP server authentication requires phishing-resistant MFA like FIDO2 security keys or passkeys using hardware-backed cryptography resistant to interception. Enforce Conditional Access policies blocking legacy protocols, apply risk-based step-up authentication via identity protection tools, and replace user-based service accounts with workload identities like managed identities to secure automation without MFA friction. Start with report-only testing to avoid disrupting legacy integrations.