Get the FREE Ultimate OpenClaw Setup Guide →

mcp-demo

Example of using MCP Gateway with E2B sandboxes

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio e2b-dev-mcp-demo node path/to/arxiv/server.js \
  --env STORAGE_PATH="/"

How to use

This MCP demo sets up a gateway that exposes multiple MCP servers (duckduckgo and arxiv) inside an E2B sandbox. The SDK client allows you to initialize a sandbox with a selected set of MCP servers and then query and use the available tools exposed by those servers. For example, you can spin up a sandbox that includes arxiv for paper lookups and duckduckgo for web search capabilities, then retrieve the MCP URL to access the aggregated toolset. You can also connect to the MCP servers from the provided client (mcp-client.ts) to list available tools and begin sending commands to the MCP endpoints. The Python beta also exists, enabling the same MCP composition from AsyncSandbox.beta_create and retrieving the MCP URL via beta_get_mcp_url.

How to install

Prerequisites:

  • Node.js or Bun (the README shows Bun usage: bun install)
  • Access to an environment where you can run the MCP gateway (sandbox) and the underlying MCP servers (duckduckgo, arxiv)
  • Optional API keys for tools used in examples (Anthropic/Claude, OpenAI) as shown in the docs

Installation steps:

  1. Install Bun (or Node.js) if not already installed. For Bun: curl https://bun.sh/install | bash
  2. Install dependencies for the project (as shown in the README): bun install
  3. If you want to run Python examples, ensure Python is installed and install the Python beta package: pip install e2b==2.3.3
  4. Start or configure the MCP gateway with the appropriate mcp_config (see the generated mcp_config in this doc).
  5. Run the example scripts to verify:
    • bun examples/basic.ts
    • bun examples/mcp-client.ts
    • bun examples/research-agent.ts
  6. For Python usage, run the Python beta example after ensuring the Python package is installed and configured.

Additional notes

Notes and tips:

  • The MCP setup here demonstrates composing multiple MCP servers (duckduckgo and arxiv) within a single sandbox. The arxiv server uses a storagePath configuration (set to "/" in the example).
  • To run the Python beta, you can install e2b with pip and use AsyncSandbox.beta_create to compose MCP servers similarly to the JS example.
  • If you encounter environment-related errors, verify that required API keys (such as ANTHROPIC_API_KEY or OPENAI_API_KEY) are set in your environment when using the corresponding examples.
  • The mcp_config section is a conceptual mapping for how to launch the individual MCP servers. Replace path/to/... with the actual entry points in your deployment.
  • This demo is intended for testing within sandboxes; production deployments should securely manage storage paths and API keys.

Related MCP Servers

Sponsor this space

Reach thousands of developers