# E2b — how to use (mcp.ai)

Connect your E2b account and use 27 tools for developer tools straight from your AI agent. Connect with your own API key. Open-source Code Interpreting for AI Apps. Run sandboxed code execution environments with support for multiple programming languages.

## Option A — via MCP (recommended)
Remote MCP endpoint (HTTP, streamable): `https://api.mcp.ai/p_e2b?ms=1787293380000`
Add it as a custom/remote MCP connector in your client (Claude, Cursor, VS Code…), then authenticate when prompted. Once connected, ask the agent to use the server's tools (e.g. `e2b_connect_sandbox`).

## Option B — via direct REST API
Base URL: `https://api.mcp.ai/api/e2b`
Auth: `Authorization: Bearer sk_live_…` — create a workspace API key at https://mcp.ai/settings/api-keys
Discover endpoints: `GET https://api.mcp.ai/api/e2b/_endpoints`

### Endpoints
- `POST https://api.mcp.ai/api/e2b/connect/sandbox` — Tool to connect to an existing E2B sandbox and retrieve its details. Use when you need to reconnect to a sandbox from different environments or resume a paused sandbox. The TTL is extended upon connec
  - body: { timeout?: integer, sandbox_id: string }
- `POST https://api.mcp.ai/api/e2b/create/template` — Tool to create a new E2B template with specified configuration. Use when you need to define a new sandbox template that can be used to spawn sandbox environments.
  - body: { alias: string, cpuCount?: integer, memoryMB?: integer }
- `POST https://api.mcp.ai/api/e2b/create/webhook` — Tool to register a new webhook to receive sandbox lifecycle events for the team. Use when you need to set up notifications for sandbox lifecycle events such as creation, updates, or termination.
  - body: { url: string, name: string, events: string[], enabled: boolean, signatureSecret: string }
- `POST https://api.mcp.ai/api/e2b/delete/sandboxes` — Tool to terminate and permanently delete a running E2B sandbox instance. Use when you need to kill a sandbox that is no longer needed. Once terminated, the sandbox cannot be resumed.
  - body: { sandbox_id: string }
- `POST https://api.mcp.ai/api/e2b/delete/webhook` — Tool to unregister a webhook and stop receiving lifecycle events. Use when you need to remove a webhook that is no longer needed or to clean up webhook registrations.
  - body: { webhook_id: string }
- `POST https://api.mcp.ai/api/e2b/get/health` — Tool to check the health status of the E2B API. Use when you need to verify that the API service is operational and accessible.
- `POST https://api.mcp.ai/api/e2b/get/sandbox` — Tool to retrieve detailed information about a specific sandbox by its ID. Use when you need to check sandbox status, metadata, or configuration details.
  - body: { sandbox_id: string }
- `POST https://api.mcp.ai/api/e2b/get/sandbox/lifecycle/events` — Tool to retrieve the latest lifecycle events for a particular sandbox instance. Use when you need to track state changes including creation, pausing, resuming, updates, and termination of a sandbox.
  - body: { limit?: integer, offset?: integer, orderAsc?: boolean, sandbox_id: string }
- `POST https://api.mcp.ai/api/e2b/get/sandbox/metrics` — Tool to retrieve timestamped CPU, memory, and disk usage metrics for a sandbox. Use when you need to monitor resource usage of a running sandbox. Metrics are collected every 5 seconds; returns empty a
  - body: { end?: integer, start?: integer, sandbox_id: string }
- `POST https://api.mcp.ai/api/e2b/get/sandboxes/logs` — Tool to retrieve logs from a specific E2B sandbox instance. Use when you need to debug or monitor sandbox execution by viewing its console output and system logs.
  - body: { limit?: integer, start?: integer, sandbox_id: string }
- `POST https://api.mcp.ai/api/e2b/get/teams/metrics` — Tool to retrieve timestamped CPU, memory, and disk usage metrics for a team. Use when you need to monitor aggregated resource usage across all sandboxes belonging to a team.
  - body: { end?: integer, start?: integer, team_id: string }
- `POST https://api.mcp.ai/api/e2b/get/teams/metrics/max` — Tool to retrieve the maximum value for a specific team metric in a given interval. Use when you need to check team limits or peak usage, such as maximum concurrent sandboxes allowed or highest resourc
  - body: { end?: integer, start?: integer, metric: string, team_id: string }
- `POST https://api.mcp.ai/api/e2b/get/templates/build/status` — Tool to get the status of a template build. Use when you need to check the build status of a template that was started asynchronously. Useful in polling loops to monitor template builds in progress.
  - body: { buildID: string, logsOffset?: integer, templateID: string }
- `POST https://api.mcp.ai/api/e2b/get/templates/files` — Tool to get an upload link for a tar file containing build layer files. Use when you need to retrieve or download template build layer files by their hash.
  - body: { hash: string, templateID: string }
- `POST https://api.mcp.ai/api/e2b/get/webhook` — Tool to retrieve the current webhook configuration for a specific webhook. Use when you need to inspect webhook settings, verify configuration, or check webhook status.
  - body: { webhook_id: string }
- `POST https://api.mcp.ai/api/e2b/list/sandboxes` — Tool to list all running and paused sandboxes associated with your team. Use when you need to view active sandboxes, monitor sandbox state, or retrieve sandbox identifiers for further operations. Supp
  - body: { limit?: integer, state?: string[], metadata?: object, nextToken?: string }
- `POST https://api.mcp.ai/api/e2b/list/sandboxes/metrics` — Tool to retrieve timestamped CPU, memory, and disk usage metrics for multiple sandboxes. Use when you need to monitor resource usage across multiple sandboxes simultaneously. Metrics are collected eve
  - body: { end?: string, start?: string, sandbox_ids: string[] }
- `POST https://api.mcp.ai/api/e2b/list/team/sandbox/lifecycle/events` — Tool to retrieve the latest lifecycle events across all sandboxes associated with the team. Use when you need to monitor sandbox activity, track lifecycle changes, or audit sandbox operations.
  - body: { limit?: integer, offset?: integer, orderAsc?: boolean }
- `POST https://api.mcp.ai/api/e2b/list/templates` — Tool to list all available E2B templates for your team. Use when you need to view available templates, retrieve template identifiers, or audit template configurations.
- `POST https://api.mcp.ai/api/e2b/list/webhooks` — Tool to retrieve all registered webhooks for your team. Use when you need to view all webhook configurations, audit webhook settings, or manage multiple webhooks.
- `POST https://api.mcp.ai/api/e2b/pause/sandbox` — Tool to pause a running E2B sandbox preserving its filesystem and memory state. Use when you need to temporarily suspend a sandbox while maintaining its state for later resumption. Takes approximately
  - body: { sandbox_id: string }
- `POST https://api.mcp.ai/api/e2b/post/sandboxes` — Tool to create a new E2B sandbox from a template. Use when you need to launch a fresh sandbox environment for code execution, testing, or development purposes.
  - body: { envs?: object, timeout?: integer, metadata?: object, autoPause?: boolean, templateID: string }
- `POST https://api.mcp.ai/api/e2b/post/sandboxes/timeout` — Tool to set the timeout for an E2B sandbox. Use when you need to extend or reduce the sandbox lifetime. The timeout is measured from the current time, and calling this multiple times overwrites the pr
  - body: { timeout: integer, sandbox_id: string }
- `POST https://api.mcp.ai/api/e2b/refresh/sandbox` — Tool to refresh an E2B sandbox and extend its time to live. Use when you need to keep a sandbox alive longer and prevent it from timing out.
  - body: { sandbox_id: string }
- `POST https://api.mcp.ai/api/e2b/start/template/build` — Tool to start a build for an E2B template. Use when you need to initiate the build process for a template with specific configuration. The build runs asynchronously and returns immediately with a 202 
  - body: { force?: boolean, steps?: object[], buildID: string, readyCmd?: string, startCmd?: string, fromImage?: string, templateID: string, fromTemplate?: string, fromImageRegistry?: object }
- `POST https://api.mcp.ai/api/e2b/update/template` — Tool to update an E2B template configuration. Use when you need to modify template settings such as changing visibility (public/private status).
  - body: { public?: boolean, template_id: string }
- `POST https://api.mcp.ai/api/e2b/update/webhook` — Tool to update an existing webhook configuration including URL, enabled status, and subscribed events. Use when you need to modify webhook settings, change the destination URL, enable/disable a webhoo
  - body: { url?: string, events?: string[], enabled?: boolean, webhook_id: string }

## Example prompts
- "What can I do in E2b?"
- "Show me a summary of my E2b account"

## More
- Page: https://mcp.ai/e2b
- Agent spec (llms.txt): https://mcp.ai/e2b/llms.txt
- Postman collection: https://mcp.ai/e2b/postman.json
