In short.
This E2B guide shows developers how to cache MCP server images in custom sandbox templates, but it requires the mcp-gateway base template and server configuration at sandbox creation. Its examples build a template containing browserbase and exa images, then create a sandbox with credentials supplied through environment variables. The documented benefit is avoiding image-download waits at runtime; the performance improvement and total cost are unknown, and no code was executed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage includes the complete selected page at [https://docs.e2b.dev/mcp-gateway/custom-templates.md], including its documentation-index notice, mandatory mcp-gateway base-template note, explanation and both language examples. The linked documentation index, server catalogue and template guides are excluded. No code, template build, sandbox creation, service connection, performance measurement or cost calculation was executed.
The overview
Identity
Custom templates is an E2B documentation page about using MCP servers with custom sandbox templates [https://docs.e2b.dev/mcp-gateway/custom-templates.md]. It covers building a template with cached server Docker images and creating a sandbox from that template.
The page provides parallel JavaScript/TypeScript and Python examples using the e2b SDK.
Assessment
The guide provides concrete API calls for both template construction and sandbox creation. It is useful when image downloads contribute to the time spent preparing an E2B sandbox.
The page claims a runtime performance improvement from downloading images beforehand, but supplies no measurements. It does not establish how much faster a particular workload would become.
Users
The guide suits developers working with E2B sandboxes and MCP servers in TypeScript or Python. Developers repeatedly creating sandboxes with the same servers have a plausible reason to investigate this approach.
Beginners receive a clear build-then-create sequence, but installation, E2B authentication and obtaining external-service credentials are not explained.
Capabilities
The documented methods are addMcpServer() in TypeScript and add_mcp_server() in Python. They accept a single server or an array of servers to download during template construction.
Server names correspond to keys in the linked Available Servers documentation. The examples cache browserbase and exa images, build a named template and select that template through Sandbox.create().
Using it
Requirements
The page explicitly requires the MCP gateway enabled base template named mcp-gateway. A sandbox created from the resulting custom template still needs configuration for each MCP server.
The examples import the e2b SDK. Their Browserbase configuration uses an API key, a Gemini API key and a project ID; their Exa configuration uses an API key. SDK versions, installation commands and E2B authentication details are unspecified.
The build examples set CPU count to 8 and memory to 8192 MB. The page does not identify these settings as minimum requirements.
Mechanism
During a template build, E2B downloads and caches the Docker images for the specified MCP servers. A sandbox created from that template can then use those cached images without waiting for their download.
This moves image acquisition into template preparation. Server configuration remains a separate step at sandbox creation, so image caching does not remove the need to supply service credentials.
Setup
Define a template using Template().fromTemplate("mcp-gateway") in TypeScript or Template().from_template("mcp-gateway") in Python. Add the desired supported server names with addMcpServer() or add_mcp_server(), then call Template.build() with a template name and build options.
After building, call Sandbox.create() with that template name and an mcp configuration object containing the required server settings. The examples load build-time environment variables with dotenv and read service credentials from environment variables during sandbox creation.
Example
The supplied example builds a template named my-mcp-gateway with browserbase and exa images, requesting 8 CPUs and 8192 MB memory in the build call.
Sandbox creation selects my-mcp-gateway. Browserbase receives apiKey, geminiApiKey and projectId from BROWSERBASE_API_KEY, GEMINI_API_KEY and BROWSERBASE_PROJECT_ID. Exa receives apiKey from EXA_API_KEY. These are documented examples; no build or sandbox creation was executed.
Assessment & evidence
Limitations
This technique requires the mcp-gateway base template and does not eliminate server configuration at sandbox creation. The supported server catalogue is linked but not reproduced on this page.
The page does not specify image versions, cache refresh behavior, failure recovery, SDK compatibility or measured startup times. It does not explain how to use arbitrary server images outside the named-server interface.
Reasoning
Repeated creation of sandboxes using the same MCP servers is a plausible fit because preparing the images once can remove image-download waits from subsequent sandbox creation. This is an inference from the documented caching mechanism, not a measured result.
For occasional sandbox use, the benefit relative to the extra template-building step remains unknown. A decision depends on actual download delays, template reuse and costs that the page does not quantify.
Alternatives
The comparison supported by the page is downloading MCP server images at runtime versus caching them during a custom-template build. It provides no measured comparison between those approaches.
No competing service or other optimization is described, so relative capability, performance and cost are not assessed.
Evidence
The evidence is the complete Custom templates documentation page at [https://docs.e2b.dev/mcp-gateway/custom-templates.md]. It contains the base-template requirement, a caching explanation and TypeScript and Python examples for building and using a template.
The performance statements are documentation claims. No execution logs, benchmarks or independent results are supplied. Linked documentation pages were not assessed.
Access & freshness
Costs
The page provides no prices for template builds, sandbox use or the external services appearing in its examples. Total cost is unknown.
The CPU and memory settings are configuration examples, not a price estimate. The page provides no calculation showing whether reduced runtime download waits offset template preparation costs.
Rights
The supplied page contains no explicit licence or redistribution terms for its documentation or code examples. It also does not establish the licences of the downloaded server images or the terms governing external services.
Permission to redistribute the documentation, examples or server images is unknown from this evidence.
Freshness
The supplied page was captured on 15 November 2026 at 04:36:59.824 UTC. The text provides no publication date, last-updated date or SDK version.
Compatibility with a particular installed SDK version and changes after capture are unknown.
Actions
Confirm the desired server keys and configuration requirements using the linked Available Servers documentation [https://docs.e2b.dev/mcp-gateway/available-servers.md]. For additional template guidance, the page links to Template Quickstart [https://docs.e2b.dev/template/quickstart.md] and Template Build [https://docs.e2b.dev/template/build.md]. Those linked contents are not assessed here.
Before adopting the approach, verify SDK compatibility, appropriate resource settings and current costs. Measure template preparation and sandbox startup with the servers you intend to use; the page does not establish the benefit for your workload.
