e2b-mcp

star 2

Set up E2B's MCP (Model Context Protocol) gateway to give sandboxes access to 200+ external tools (Browserbase, Exa, Notion, Slack, etc.). Use when connecting sandboxes to third-party services via MCP.

beran-t By beran-t schedule Updated 2/17/2026

name: e2b-mcp description: > Set up E2B's MCP (Model Context Protocol) gateway to give sandboxes access to 200+ external tools (Browserbase, Exa, Notion, Slack, etc.). Use when connecting sandboxes to third-party services via MCP.

E2B MCP Gateway

The E2B MCP gateway gives sandboxes access to 200+ external tools through MCP (Model Context Protocol). Configure tool servers when creating a sandbox, then connect any MCP client.

Important: Use the Base e2b Package

MCP uses the base e2b package, not the code-interpreter package.

# JavaScript/TypeScript
npm install e2b

# Python
pip install e2b
import Sandbox from 'e2b'
from e2b import AsyncSandbox

Setup

Pass an mcp config to Sandbox.create() with one or more named servers and their environment variables:

import Sandbox from 'e2b'

const sandbox = await Sandbox.create({
  mcp: {
    browserbase: {
      envs: {
        BROWSERBASE_API_KEY: process.env.BROWSERBASE_API_KEY,
        BROWSERBASE_PROJECT_ID: process.env.BROWSERBASE_PROJECT_ID,
      },
    },
    exa: {
      envs: {
        EXA_API_KEY: process.env.EXA_API_KEY,
      },
    },
    notion: {
      envs: {
        NOTION_TOKEN: process.env.NOTION_TOKEN,
      },
    },
  },
})
import os
from e2b import AsyncSandbox

sandbox = await AsyncSandbox.create(
    mcp={
        "browserbase": {
            "envs": {
                "BROWSERBASE_API_KEY": os.environ["BROWSERBASE_API_KEY"],
                "BROWSERBASE_PROJECT_ID": os.environ["BROWSERBASE_PROJECT_ID"],
            },
        },
        "exa": {
            "envs": {
                "EXA_API_KEY": os.environ["EXA_API_KEY"],
            },
        },
        "notion": {
            "envs": {
                "NOTION_TOKEN": os.environ["NOTION_TOKEN"],
            },
        },
    },
)

MCP Connection Details

What Method (JS) Method (Python) Description
External URL sandbox.getMcpUrl() sandbox.get_mcp_url() URL for connecting from outside the sandbox
Internal URL http://localhost:50005/mcp (from inside sandbox)
Auth token sandbox.getMcpToken() sandbox.get_mcp_token() Bearer token for Authorization header

Client Examples

Official MCP SDK (JS/TS)

import { Client } from '@modelcontextprotocol/sdk/client/index.js'
import { StreamableHTTPClientTransport } from '@modelcontextprotocol/sdk/client/streamableHttp.js'

const mcpClient = new Client({ name: 'my-client', version: '1.0.0' })

await mcpClient.connect(
  new StreamableHTTPClientTransport(
    new URL(sandbox.getMcpUrl()),
    {
      requestInit: {
        headers: {
          Authorization: `Bearer ${sandbox.getMcpToken()}`,
        },
      },
    },
  ),
)

// List available tools
const tools = await mcpClient.listTools()
console.log(tools)

// Call a tool
const result = await mcpClient.callTool({
  name: 'browserbase_navigate',
  arguments: { url: 'https://example.com' },
})

Official MCP SDK (Python)

from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

async with streamablehttp_client(
    sandbox.get_mcp_url(),
    headers={"Authorization": f"Bearer {sandbox.get_mcp_token()}"},
) as (read_stream, write_stream, _):
    async with ClientSession(read_stream, write_stream) as session:
        await session.initialize()

        tools = await session.list_tools()
        print(tools)

        result = await session.call_tool(
            "browserbase_navigate",
            arguments={"url": "https://example.com"},
        )

Claude Code

Add to your Claude Code MCP settings:

{
  "mcpServers": {
    "e2b-mcp": {
      "type": "streamable-http",
      "url": "<sandbox.getMcpUrl()>",
      "headers": {
        "Authorization": "Bearer <sandbox.getMcpToken()>"
      }
    }
  }
}

OpenAI Agents SDK

from agents import Agent
from agents.mcp import MCPServerStreamableHttp

mcp_server = MCPServerStreamableHttp(
    name="e2b-tools",
    url=sandbox.get_mcp_url(),
    headers={"Authorization": f"Bearer {sandbox.get_mcp_token()}"},
)

agent = Agent(
    name="research-agent",
    instructions="Use available tools to research topics.",
    mcp_servers=[mcp_server],
)

Debugging with MCP Inspector

Use the MCP Inspector to explore available tools and test calls:

npx @anthropic-ai/mcp-inspector \
  --transport streamable-http \
  --url "<sandbox.getMcpUrl()>" \
  --header "Authorization: Bearer <sandbox.getMcpToken()>"

Internal MCP Access (From Inside the Sandbox)

Code running inside the sandbox can connect to the MCP gateway without authentication:

# Inside the sandbox — no auth needed
from mcp import ClientSession
from mcp.client.streamable_http import streamablehttp_client

async with streamablehttp_client("http://localhost:50005/mcp") as (read, write, _):
    async with ClientSession(read, write) as session:
        await session.initialize()
        tools = await session.list_tools()
Install via CLI
npx skills add https://github.com/beran-t/e2b-claude-skills --skill e2b-mcp
Repository Details
star Stars 2
call_split Forks 0
navigation Branch main
article Path SKILL.md
More from Creator