e2b-sandbox-mcp
E2B Sandbox MCPサーバー
Claude CodeとE2Bクラウドサンドボックスを接続するMCP(Model Context Protocol)サーバーです。ローカルマシンを汚すことなく、隔離されたLinux VM上でGitHubリポジトリの作業を行えます。
機能
このサーバーは、クラウドサンドボックスの作成、リポジトリのクローン、コマンド実行、ファイル管理、Git操作を行うための29個のツールをClaude Codeに提供します。これらはすべて、安全で使い捨て可能なLinux環境内で行われます。
ローカルマシンは一切変更されません。 すべての操作はE2BサンドボックスVM内で行われます。
Related MCP server: codex-cli-mcp-tool
トークン節約
ローカルのBashの代わりにE2Bサンドボックス経由でコマンドを実行することで、会話ごとのトークン消費量を削減できます。ツールの出力は構造化され、切り詰められるため(ストリームあたり100KB、合計200KB)、大規模なビルドやテストの出力がコンテキストウィンドウを溢れさせることはありません。
プロジェクト規模 | 例 | ローカルBashトークン | E2Bサンドボックス トークン | 節約率 |
小規模 | Express API, 約10ファイル | ~15K-25K | ~10K-18K | ~20-30% |
中規模 | Next.jsアプリ, 50-100ファイル | ~50K-100K | ~25K-45K | ~40-55% |
大規模 | モノレポ, 500ファイル以上 | ~200K-500K+ | ~60K-120K | ~60-75% |
スケーリングの理由: モノレポでのローカルな npm install は、1万行以上の出力をコンテキストに流し込む可能性があります。フルテストスイートはさらに数千行を追加します。E2Bでは、これらの出力は制限され、構造化されます。バックグラウンドプロセス (sandbox_exec_background) はプロセスIDのみを返し、ストリーミング出力はゼロです。ディレクトリ一覧は1000エントリに制限されます。その結果、コンテキストウィンドウはターミナルのノイズに消費されることなく、実際の作業のために確保されます。
ユースケース
あらゆるGitHubリポジトリをリモートで操作
リポジトリをサンドボックスにクローンし、ビルドやテストスイートを実行し、変更を加えてプッシュするまで、プロジェクトをローカルにインストールすることなく完結できます。
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)安全な実験
依存関係のアップグレード、大規模なリファクタリング、移行スクリプトなどのリスクを伴う変更を、使い捨て環境で試すことができます。壊れた場合は sandbox_kill で破棄し、最初からやり直せます。
永続的な開発セッション
その日の作業が終わったらサンドボックスを一時停止し、翌日、ファイルや状態を保持したまま再開できます。環境をゼロから再構築する必要はありません。
You: "Pause this sandbox, I'll continue tomorrow"
Claude Code:
→ sandbox_pause (saves state)
Next day:
→ sandbox_resume (picks up where you left off)開発サーバーのプレビュー
サンドボックス内でWebアプリを起動し、公開URLを取得してブラウザでプレビューできます。ポートフォワーディングやトンネリングは不要です。
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.dev複数リポジトリの並行作業
複数のサンドボックスを立ち上げ、異なるリポジトリをクローンして、すべて同時に作業できます。各サンドボックスは完全に隔離されています。
CIのようなクリーンなテスト
クリーンなLinux環境でフルテストスイートを実行できます。「自分のマシンでは動く」という問題をCIにプッシュする前に発見できます。
オープンソースへの貢献
リポジトリをフォークし、サンドボックスにクローンして変更を加え、コミットしてフォーク先にプッシュするまで、ローカルでのプロジェクト設定なしで行えます。
ライブ環境でのコードレビュー
PRブランチをサンドボックスにクローンし、テストを実行し、変更を検査して動作を確認できます。ブランチをローカルにチェックアウトする必要はありません。
はじめに
前提条件
Node.js >= 18
Claude Code CLIがインストールされていること
E2B APIキー (無料枠あり)
GitHub Personal Access Token (オプション、プライベートリポジトリやプッシュ用)
1. Claude Codeへの登録
個別のインストールは不要です。npx を使ってClaude Codeにnpmパッケージを指定するだけです:
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-mcpサーバーを追加した後、Claude Codeを再起動してください。
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. 使用方法
Claude Codeを起動し、リポジトリでの作業を依頼します:
"サンドボックスを作成し、https://github.com/expressjs/express をクローンして、テストスイートを実行して"
Claude Codeが自動的にMCPツールを呼び出します。
利用可能なツール
サンドボックスのライフサイクル
ツール | 説明 |
| 新しいクラウドサンドボックス(Linux VM)を作成 |
| アクティブなサンドボックスの一覧を表示 |
| 特定のサンドボックスの詳細を取得 |
| サンドボックスを終了・破棄 |
| サンドボックスのタイムアウトを延長 |
| サンドボックスを一時停止し、状態を保存 |
| 一時停止したサンドボックスを再開 |
ネットワークとファイル転送
ツール | 説明 |
| ポートの公開URLを取得(ブラウザで開発サーバーをプレビュー) |
| サンドボックスにファイルをアップロードするための署名付きURLを取得 |
| サンドボックスからファイルをダウンロードするための署名付きURLを取得 |
コマンド実行
ツール | 説明 |
| シェルコマンドを実行し、stdout/stderr/終了コードを取得 |
| バックグラウンドプロセス(開発サーバー、ウォッチャー)を開始 |
| 実行中のプロセスをPID付きで一覧表示 |
| PIDを指定してプロセスを終了 |
ファイル操作
ツール | 説明 |
| ファイルの内容を読み取る |
| ファイルを書き込み/作成 |
| ディレクトリの内容を一覧表示 |
| ディレクトリを作成 |
| ファイルまたはディレクトリを削除 |
| ファイルメタデータ(サイズ、タイプ、権限)を取得 |
| ファイルまたはディレクトリの存在を確認 |
| ファイルまたはディレクトリの名前変更/移動 |
Git操作
ツール | 説明 |
| リポジトリをクローン(GITHUB_TOKENによるプライベートリポジトリ対応) |
| ワーキングツリーのステータスを取得 |
| ファイルをステージしてコミット |
| リモートへコミットをプッシュ |
| リモートから最新の変更をプル |
| ブランチの一覧表示、作成、切り替え |
| 新しいGitリポジトリを初期化 |
環境変数
変数 | 必須 | 説明 |
| はい | e2b.dev/dashboard から取得したE2B APIキー |
| いいえ | プライベートリポジトリへのアクセスおよび |
アーキテクチャ
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 toolsサーバーはアクティブなサンドボックスインスタンスのレジストリを管理します。各ツールはIDでサンドボックスを参照するため、複数の隔離された環境で同時に作業を行うことができます。
重要な注意点
サンドボックスは実際のVMです。 コマンドはE2Bクラウド上の実際のLinuxマシンで実行されます。
Git pushは本物です。 サンドボックスからのプッシュは、実際のリモートリポジトリに対して行われます。
サンドボックスは自動的に期限切れになります。 デフォルトのタイムアウトは5分です。
sandbox_keep_aliveを使用して延長してください。E2Bの利用にはコストがかかります。 詳細は E2Bの料金ページ を確認してください。無料枠も用意されています。
サンドボックスはローカルマシンからは隔離されていますが、インターネットからは隔離されていません。 ネットワークリクエスト、gitプッシュ、npm公開などはすべて実際に行われます。
ライセンス
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.
Maintenance
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.50 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.330 npmISC