e2b-sandbox-mcp
E2B Sandbox MCP Server
An MCP (Model Context Protocol) server that connects Claude Code with E2B cloud sandboxes, giving you isolated Linux VMs to work on any GitHub repository without touching your local machine.
What It Does
This server provides Claude Code with 29 tools to create cloud sandboxes, clone repos, run commands, manage files, and perform git operations — all in a secure, disposable Linux environment.
Your local machine stays untouched. Every operation happens inside an E2B sandbox VM.
Related MCP server: codex-cli-mcp-tool
Token Savings
Running commands through E2B sandboxes instead of local Bash reduces the tokens consumed per conversation. Tool outputs are structured and truncated (100KB per stream, 200KB total), so large build/test outputs don't flood your context window.
Project Size | Example | Local Bash Tokens | E2B Sandbox Tokens | Savings |
Small | Express API, ~10 files | ~15K-25K | ~10K-18K | ~20-30% |
Medium | Next.js app, 50-100 files | ~50K-100K | ~25K-45K | ~40-55% |
Large | Monorepo, 500+ files | ~200K-500K+ | ~60K-120K | ~60-75% |
Why it scales: A local npm install on a monorepo can dump 10K+ lines into context. A full test suite adds thousands more. With E2B, those outputs are capped and structured. Background processes (sandbox_exec_background) return only a process ID — zero streaming output. Directory listings are capped at 1000 entries. The result: your context window stays available for actual work instead of being consumed by terminal noise.
Use Cases
Work on Any GitHub Repo Remotely
Clone any repository into a sandbox, run its build and test suite, make changes, and push — without ever installing the project locally.
You: "Clone github.com/fastify/fastify, run the tests, and find why test X fails"
Claude Code:
→ sandbox_create
→ sandbox_git_clone "https://github.com/fastify/fastify"
→ sandbox_exec "npm install"
→ sandbox_exec "npm test"
→ sandbox_file_read (inspect failing test)
→ sandbox_file_write (apply fix)
→ sandbox_exec "npm test" (verify)Safe Experimentation
Try risky changes — dependency upgrades, major refactors, migration scripts — in a throwaway environment. If it breaks, sandbox_kill and start fresh.
Persistent Development Sessions
Pause a sandbox when you're done for the day, resume it tomorrow with all your files and state intact. No more rebuilding environments from scratch.
You: "Pause this sandbox, I'll continue tomorrow"
Claude Code:
→ sandbox_pause (saves state)
Next day:
→ sandbox_resume (picks up where you left off)Preview Dev Servers
Start a web app in a sandbox and get a public URL to preview it in your browser — no port forwarding or tunneling needed.
You: "Start the dev server and give me a URL to preview it"
Claude Code:
→ sandbox_exec_background "npm run dev"
→ sandbox_get_url 3000
→ Returns: https://abc123-3000.e2b.devMulti-Repo Parallel Work
Spin up multiple sandboxes, clone different repos, work on all of them simultaneously. Each sandbox is fully isolated.
Clean CI-Like Testing
Run your full test suite in a fresh Linux environment. Catch "works on my machine" issues before pushing to CI.
Open Source Contributions
Fork a repo, clone it in a sandbox, make your changes, commit, and push to your fork — all without local project setup.
Code Review in a Live Environment
Clone a PR branch into a sandbox, run the tests, inspect the changes, and verify the behavior — without checking out the branch locally.
Getting Started
Prerequisites
Node.js >= 18
Claude Code CLI installed
E2B API key (free tier available)
GitHub Personal Access Token (optional, for private repos and push)
1. Register with Claude Code
No separate install needed — just point Claude Code at the npm package with npx:
claude mcp add e2b-sandbox -s user \
-e E2B_API_KEY=your-e2b-api-key \
-e GITHUB_TOKEN=your-github-token \
-- npx -y e2b-sandbox-mcpRestart Claude Code after adding the server.
If you prefer a global install instead of npx:
npm install -g e2b-sandbox-mcp
claude mcp add e2b-sandbox -s user \
-e E2B_API_KEY=your-e2b-api-key \
-e GITHUB_TOKEN=your-github-token \
-- e2b-sandbox-mcp2. Use It
Start Claude Code and ask it to work on any repo:
"Create a sandbox, clone https://github.com/expressjs/express, and run the test suite"
Claude Code will call the MCP tools automatically.
Available Tools
Sandbox Lifecycle
Tool | Description |
| Create a new cloud sandbox (Linux VM) |
| List all active sandboxes |
| Get details about a specific sandbox |
| Terminate and destroy a sandbox |
| Extend a sandbox's timeout |
| Pause a sandbox, preserving its state for later |
| Resume a previously paused sandbox |
Networking & File Transfer
Tool | Description |
| Get a public URL for a port (preview dev servers in browser) |
| Get a presigned URL to upload files to the sandbox |
| Get a presigned URL to download files from the sandbox |
Command Execution
Tool | Description |
| Run a shell command and get stdout/stderr/exit code |
| Start a background process (dev servers, watchers) |
| List all running processes with PIDs |
| Kill a running process by PID |
File Operations
Tool | Description |
| Read file contents |
| Write/create a file |
| List directory contents |
| Create a directory |
| Delete a file or directory |
| Get file metadata (size, type, permissions) |
| Check if a file or directory exists |
| Rename or move a file or directory |
Git Operations
Tool | Description |
| Clone a repository (supports private repos with GITHUB_TOKEN) |
| Get working tree status |
| Stage files and commit |
| Push commits to remote |
| Pull latest changes from remote |
| List, create, or switch branches |
| Initialize a new git repository |
Environment Variables
Variable | Required | Description |
| Yes | Your E2B API key from e2b.dev/dashboard |
| No | GitHub personal access token for private repo access and |
Architecture
src/
├── index.ts # MCP server entry point (stdio transport)
├── types.ts # Shared types and error helpers
├── services/
│ └── sandbox-manager.ts # Sandbox registry (tracks active VMs)
└── tools/
├── sandbox.ts # Lifecycle tools
├── commands.ts # Command execution tools
├── filesystem.ts # File operation tools
└── git.ts # Git operation toolsThe server manages a registry of active sandbox instances. Each tool references sandboxes by ID, allowing concurrent work across multiple isolated environments.
Important Notes
Sandboxes are real VMs. Commands execute on actual Linux machines in E2B's cloud.
Git push is real. Pushing from a sandbox pushes to the actual remote repository.
Sandboxes auto-expire. Default timeout is 5 minutes. Use
sandbox_keep_aliveto extend.E2B usage has costs. Check E2B pricing for details. Free tier is available.
Sandboxes are isolated from your machine, but not from the internet. Network requests, git pushes, and npm publishes are real.
License
MIT
Available Tools
29 toolssandbox_createA
Create a new E2B cloud sandbox (secure Linux VM). Returns a sandboxId to use with other tools.
Inputs: templateId, timeoutMs, metadata.
sandbox_download_urlA
Get a presigned URL to download a file from the sandbox. Use this to retrieve build artifacts, logs, or any file from the sandbox.
Inputs: sandboxId (required), path (required).
sandbox_execA
Execute a shell command in a sandbox and return stdout, stderr, and exit code. Use for running builds, tests, installs, or any CLI command.
Inputs: sandboxId (required), command (required), cwd, timeoutMs, +1 more.
sandbox_exec_backgroundA
Start a background process in a sandbox (e.g., dev server, file watcher). Returns immediately without waiting for completion.
Inputs: sandboxId (required), command (required), cwd, envs.
sandbox_file_existsA
Check if a file or directory exists in a sandbox. Returns true/false without throwing an error if not found.
Inputs: sandboxId (required), path (required).
sandbox_file_infoA
Get metadata about a file or directory in a sandbox (size, type, permissions).
Inputs: sandboxId (required), path (required).
sandbox_file_listC
List files and directories in a sandbox path.
Inputs: sandboxId (required), path.
sandbox_file_mkdirB
Create a directory (and parent directories) in a sandbox.
Inputs: sandboxId (required), path (required).
sandbox_file_readB
Read the contents of a file in a sandbox.
Inputs: sandboxId (required), path (required).
sandbox_file_removeC
Delete a file or directory in a sandbox.
Inputs: sandboxId (required), path (required).
sandbox_file_renameC
Rename or move a file or directory in a sandbox.
Inputs: sandboxId (required), oldPath (required), newPath (required).
sandbox_file_writeA
Write content to a file in a sandbox. Creates parent directories automatically. Overwrites if file exists.
Inputs: sandboxId (required), path (required), content (required).
sandbox_get_urlA
Get the public URL for a port running inside a sandbox. Use this to access dev servers, web apps, or any HTTP service running in the sandbox from a browser.
Inputs: sandboxId (required), port (required).
sandbox_git_branchB
Manage git branches: list, create, or switch branches in a sandbox repository.
Inputs: sandboxId (required), repoPath (required), action (required), branchName.
sandbox_git_cloneA
Clone a GitHub repository into a sandbox. Supports private repos when GITHUB_TOKEN is configured.
Inputs: sandboxId (required), repoUrl (required), path, branch, +1 more.
sandbox_git_commitB
Stage files and create a git commit in a sandbox repository.
Inputs: sandboxId (required), repoPath (required), message (required), files, +2 more.
sandbox_git_initB
Initialize a new git repository in a sandbox directory.
Inputs: sandboxId (required), path (required).
sandbox_git_pullC
Pull latest changes from a remote repository in a sandbox.
Inputs: sandboxId (required), repoPath (required), remote, branch.
sandbox_git_pushA
Push commits to a remote repository. Requires GITHUB_TOKEN for authentication.
Inputs: sandboxId (required), repoPath (required), remote, branch, +1 more.
sandbox_git_statusA
Get the git status of a repository in a sandbox (current branch, modified/staged/untracked files).
Inputs: sandboxId (required), repoPath (required).
sandbox_infoC
Get details about a specific sandbox.
Inputs: sandboxId (required).
sandbox_keep_aliveA
Extend a sandbox timeout to prevent it from being automatically terminated.
Inputs: sandboxId (required), timeoutMs (required).
sandbox_killA
Terminate and clean up a sandbox. The sandbox and all its data will be destroyed.
Inputs: sandboxId (required).
sandbox_listA
List all active E2B sandboxes managed by this server.
Inputs: no named parameters.
sandbox_pauseA
Pause a sandbox to preserve its state. The sandbox can be resumed later with sandbox_resume using the same sandbox ID. Paused sandboxes persist across sessions and do not count against timeout.
Inputs: sandboxId (required).
sandbox_process_killA
Kill a running process in a sandbox by its PID. Use sandbox_process_list to find the PID.
Inputs: sandboxId (required), pid (required).
sandbox_process_listA
List all running processes (commands and PTY sessions) in a sandbox. Shows PID, command, and arguments for each process.
Inputs: sandboxId (required).
sandbox_resumeA
Resume a previously paused sandbox. Reconnects to the sandbox and restores its state including filesystem and running processes.
Inputs: sandboxId (required), timeoutMs.
sandbox_upload_urlA
Get a presigned URL to upload a file to the sandbox. Send a POST request with the file as multipart/form-data to the returned URL.
Inputs: sandboxId (required), path.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 29 tools
Each tool targets a distinct operation on sandboxes (create, exec, file ops, git, lifecycle management, process control). No overlapping purposes; even similar operations like sandbox_exec vs sandbox_exec_background are clearly differentiated by synchronous vs background execution.
All tools follow the consistent pattern of `sandbox_<action>`, using snake_case. Actions are clear verbs (create, exec, list, kill, etc.). This provides a predictable and intuitive naming scheme.
29 tools is on the higher side but justified by the broad scope of sandbox management (execution, file system, git, process management, lifecycle). The count is reasonable for a comprehensive server, though could be slightly trimmed by merging some rare operations.
The tool set covers the full lifecycle of sandboxes: create, list, info, keep-alive, pause/resume, kill. It includes file operations (CRUD), execution (command + background), process management, git operations (init, clone, branch, status, commit, pull, push), and utilities like download/upload URLs. No obvious gaps for typical sandbox usage.
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
Shared memory MCP server for Claude Code, Codex, Gemini CLI and Cursor. Cited, editable.
Hosted YouTube MCP server for Claude, ChatGPT and Cursor, with each action switched per account.
Related MCP Servers
- AlicenseAqualityDmaintenanceMCP server that spawns autonomous Claude Code agents in GitHub repos, enabling task delegation with persistent state, multi-step workflows, and job monitoring.47161 npm2Apache 2.0
- AlicenseNot gradedqualityDmaintenanceAn MCP server that allows Claude Code to interact with the OpenAI Codex CLI.40 npm20MIT
- AlicenseAqualityDmaintenanceAn MCP server that gives Claude live access to your GitHub workspace — PR reviews, issue triaging, repo search, and weekly digest reports through natural language.7MIT
- AlicenseNot gradedqualityCmaintenanceA self-hosted MCP server that gives Claude access to your GitHub account — read files, browse repos, commit changes, and manage issues and pull requests, all from a conversation.497 npmISC