Skip to main content
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 the sandbox.getMcpUrl() in JavaScript and sandbox.get_mcp_url() in Python. Install the E2B SDK and an MCP client, and set E2B_API_KEY in your environment. The TypeScript example uses top-level await, so the project must be an ES module.
The example starts the fetch server, which needs no API key, lists its tools and calls one. A tool call that fails does not throw: it returns a result with isError set (is_error in Python), so check it before you use the content. The gateway prefixes each tool name with the server’s name in the catalog, so the fetch tool of the fetch server is fetch-fetch. That name can differ from the key you configure (Airtable’s tools start with airtable-mcp-server-), so list the tools to get the exact names.
Most servers call a third-party API and take its credentials in the same mcp object, for example exa: { apiKey: process.env.EXA_API_KEY }. See Available servers for the fields of each server.

From inside the sandbox

If you need to access the MCP gateway from within the sandbox itself, it’s available at:
You’ll need to include the Authorization header with the MCP token when making requests from inside the sandbox. How that is added depends on the MCP client you use:

Claude

OpenAI Agents

Official MCP client

This list is not exhaustive. You can find more examples in the E2B Cookbook.

Debugging with MCP Inspector

The MCP Inspector is a useful tool for debugging and testing your MCP server setup. Get the command to run:
Run the command in your terminal. This will open a web interface where you can:
  • Browse available tools
  • Test tool calls with different parameters
  • Inspect request/response payloads
  • Debug connection issues