E2B provides a batteries-included MCP gateway that runs inside sandboxes, giving you type-safe access to 200+ MCP tools from the Docker MCP Catalog or custom MCP servers through a unified interface. This integration gives developers instant access to tools like Browserbase, Exa, Notion, Stripe, or GitHub. The Model Context Protocol (MCP) is an open standard for connecting AI models to external tools and data sources. E2B sandboxes provide an ideal environment for running MCP tools, giving AI full access to an internet-connected Linux machine where it can safely install packages, write files, run terminal commands, and AI-generated code.Documentation Index
Fetch the complete documentation index at: https://e2b-squash-sandbox-pages.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.

Quickstart
Create a sandbox with MCP servers configured and connect it to an AI agent. This example sets up Browserbase, Exa, and Airtable MCP servers and uses Claude to orchestrate them.Connecting to the MCP gateway
You can connect to the MCPs running inside the sandbox both from outside and inside the sandbox.From outside the sandbox
To connect to the MCPs running inside the sandbox, use thesandbox.getMcpUrl() in JavaScript and sandbox.get_mcp_url() in Python.
From inside the sandbox
If you need to access the MCP gateway from within the sandbox itself, it’s available at:MCP client integrations
Claude
OpenAI Agents
Official MCP client
Custom templates
You can prepull MCP server Docker images during template build time to significantly improve runtime performance. When you build a template with prepulled MCP servers, the Docker images for those servers are downloaded and cached during the build process. This means when you create a sandbox from that template, the MCP servers are ready to use immediately without waiting for image downloads.You must use the MCP gateway enabled template (
mcp-gateway) as your base template to use this feature.Building a template with MCP servers
Use theaddMcpServer() method (TypeScript) or add_mcp_server() method (Python) to prepull MCP server images during template build. You can pass a single server or an array of servers.
The server names (like "browserbase" and "exa") correspond to the keys defined in the Available Servers documentation.
Using the template
Once built, create sandboxes from your template. You still need to provide the configuration for each MCP server.- Template Quickstart - Get started with custom templates
- Defining Templates - Learn all template configuration options
- Template Build - Understand the build process
Custom MCP servers
In addition to the 200+ pre-built MCP servers from the Docker MCP Catalog, you can run custom MCP servers directly from public GitHub repositories. When you specify a GitHub repository, E2B will:- Clone the repository into the sandbox
- Run the
installCmd(optional) to install dependencies - Run the
runCmdto start the MCP server with stdio transport
runCmd must start an MCP server that follows the MCP specification and communicates via stdio (standard input/output).
Configuration
Optional command to run before starting the MCP server. Use this to install dependencies (e.g.,
npm install, pip install -r requirements.txt).Command to start the MCP server. Must launch a stdio-enabled MCP server.
Important for npx-based servers: Always include
installCmd: 'npm install' (or equivalent) when using npx in your runCmd. Without installing dependencies first, npx will try to use the local repository and fail.Troubleshooting
If your custom MCP server doesn’t work as expected:- Explore the sandbox either via the dashboard or by connecting to it via
e2b connect <sandbox-id> - Check the gateway log file with
sudo cat /var/log/mcp-gateway/gateway.log.
Debugging with MCP Inspector
The MCP Inspector is a useful tool for debugging and testing your MCP server setup. Get the command to run:- Browse available tools
- Test tool calls with different parameters
- Inspect request/response payloads
- Debug connection issues
Examples
Claude Code
Claude Code with MCP integration
Browserbase
Web automation agent with Browserbase
Groq + Exa
AI research using Groq and Exa
Research agent
Research Agent using the OpenAI Agents framework
MCP client
Basic MCP client connecting to an E2B Sandbox
Custom MCP server
Use custom MCP servers installed from GitHub
Custom template
Create a custom E2B Sandbox with pre-installed MCP servers