Sandbox MCP Server

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Provides isolated Docker environments for code execution, allowing users to create containers with any Docker image, run commands in isolated containers, and save container states as Docker images.

  • Mentioned as an example package that can be installed and used in the isolated containers for data analysis.

  • Mentioned as an example package that can be installed and used in the isolated containers for data manipulation.

サンドボックス MCP サーバー

コード実行のための分離されたDocker環境を提供するMCPサーバー。このサーバーでは、以下のことが可能です。

  • 任意のDockerイメージでコンテナを作成する
  • 複数のプログラミング言語でコードを記述して実行する
  • パッケージをインストールして開発環境をセットアップする
  • 分離されたコンテナでコマンドを実行する

前提条件

  • Python 3.9以上
  • Dockerがインストールされ実行中
  • uv パッケージ マネージャー (推奨)
  • Docker MCP サーバー(推奨)

インストール

  1. このリポジトリをクローンします:
git clone <your-repo-url> cd sandbox_server
  1. uv を使用して仮想環境を作成し、アクティブ化します。
uv venv source .venv/bin/activate # On Unix/MacOS # Or on Windows: # .venv\Scripts\activate
  1. 依存関係をインストールします:
uv pip install .

Claude Desktopとの統合

  1. Claude Desktop の設定ファイルを開きます。
  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  1. サンドボックス サーバーの構成を追加します。
{ "mcpServers": { "sandbox": { "command": "uv", "args": [ "--directory", "/absolute/path/to/sandbox_server", "run", "sandbox_server.py" ], "env": { "PYTHONPATH": "/absolute/path/to/sandbox_server" } } } }

/absolute/path/to/sandbox_serverプロジェクト ディレクトリへの実際のパスに置き換えます。

  1. Claudeデスクトップを再起動します

使用例

基本的な使い方

Claude Desktop に接続すると、次のことが可能になります。

  1. Python コンテナを作成します。
Could you create a Python container and write a simple hello world program?
  1. さまざまな言語でコードを実行します。
Could you create a C program that calculates the fibonacci sequence and run it?
  1. パッケージをインストールして使用します。
Could you create a Python script that uses numpy to generate and plot some random data?

環境の保存と再生

サーバーは、開発環境を保存および再現するためのいくつかの方法を提供します。

永続コンテナの作成

コンテナを作成するときに、それを永続化することができます。

Could you create a persistent Python container with numpy and pandas installed?

これにより、次のコンテナが作成されます。

  • Claude Desktop が終了しても実行を継続します
  • Docker経由で直接アクセス可能
  • インストールされたすべてのパッケージとファイルを保存します

サーバーは次の指示を提供します:

  • コンテナに直接アクセスする( docker exec
  • コンテナの停止と起動
  • 不要になったら削除する

コンテナの状態を保存しています

環境を設定したら、それを Docker イメージとして保存できます。

Could you save the current container state as an image named 'my-ds-env:v1'?

これにより、次のようになります。

  1. 次のすべてを含む新しい Docker イメージを作成します。
    • インストールされたパッケージ
    • 作成されたファイル
    • 構成の変更
  2. 環境を再利用するための手順を提供する

その後、このイメージを共有したり、新しいコンテナの開始点として使用したりできます。

Could you create a new container using the my-ds-env:v1 image?

Dockerfilesの生成

環境を完全に再現可能にするには、Dockerfile を生成します。

Could you export a Dockerfile that recreates this environment?

生成された Dockerfile には次のものが含まれます。

  • ベースイメージの仕様
  • 作成されたファイル
  • 追加のセットアップ手順のテンプレート

この Dockerfile を使用すると次のことができます。

  1. 環境設定を他の人と共有する
  2. 開発環境のバージョン管理
  3. ビルドプロセスを変更およびカスタマイズする
  4. さまざまなシステムに展開

推奨ワークフロー

再現可能な開発環境の場合:

  1. 永続コンテナを作成します。
Create a persistent Python container for data science work
  1. 必要なパッケージをインストールし、環境を設定します。
Install numpy, pandas, and scikit-learn in the container
  1. セットアップをテストします。
Create and run a test script to verify the environment
  1. 状態を保存します:
Save this container as 'ds-workspace:v1'
  1. Dockerfile をエクスポートします。
Generate a Dockerfile for this environment

これにより、環境を再作成するための複数のオプションが提供されます。

  • 保存したDockerイメージを直接使用する
  • Dockerfile から修正を加えてビルドする
  • 必要に応じて元のコンテナにアクセスする

セキュリティノート

  • すべてのコードは分離されたDockerコンテナ内で実行される
  • 使用後は容器が自動的に除去されます
  • ファイルシステムはコンテナ間で分離されている
  • ホストシステムへのアクセスが制限されています

プロジェクト構造

sandbox_server/ ├── sandbox_server.py # Main server implementation ├── pyproject.toml # Project configuration └── README.md # This file

利用可能なツール

サーバーは 3 つの主なツールを提供します。

  1. create_container_environment : 指定されたイメージで新しいDockerコンテナを作成する
  2. create_file_in_container : コンテナ内にファイルを作成する
  3. execute_command_in_container : コンテナ内でコマンドを実行する
  4. save_container_state : コンテナの状態を永続コンテナに保存します
  5. export_dockerfile : 永続的な環境を作成するために docker ファイルをエクスポートします
  6. exit_container : 終了時にコンテナを閉じて環境をクリーンアップします
-
security - not tested
F
license - not found
-
quality - not tested

コード実行用の分離された Docker 環境を提供し、ユーザーがコンテナを作成および管理し、多言語コードを実行し、開発環境を保存および再現して、セキュリティと分離を確保できるようにします。

  1. Prerequisites
    1. Installation
      1. Integration with Claude Desktop
        1. Usage Examples
          1. Basic Usage
          2. Saving and Reproducing Environments
        2. Security Notes
          1. Project Structure
            1. Available Tools
              ID: t3aw07q2a3