Python MCP Sandbox
MCPサンドボックス
ぜひMCPサンドボックスでお試しください
中文档|英語
デモ
Python MCP Sandbox は、ユーザーと LLM が Python コードを安全に実行し、分離された Docker コンテナーにパッケージをインストールできるようにするインタラクティブな Python コード実行ツールです。
ヴィビー
VibyはMCPサンドボックスで動作します
特徴
🐳 Docker Isolation : 分離された Docker コンテナ内で Python コードを安全に実行
📦パッケージ管理: Python パッケージを簡単にインストールおよび管理します
📊ファイル生成: ファイルの生成とWebリンク経由のアクセスをサポート
Related MCP server: mcp-run-isolated-python
インストール
# Clone the repository
git clone https://github.com/JohanLi233/python-mcp-sandbox.git
cd python-mcp-sandbox
uv venv
uv sync
# Start the server
uv run main.pyデフォルトの SSE エンドポイントはhttp://localhost:8000/sse であり、SSE または SSE 接続をサポートするその他のクライアントを介して MCP Inspector 経由で対話できます。
利用可能なツール
create_sandbox : 新しい Python Docker サンドボックスを作成し、後続のコード実行とパッケージのインストールのためにその ID を返します。
list_sandboxes : 再利用するために既存のサンドボックス(Dockerコンテナ)をすべて一覧表示します。
execute_python_code : 指定されたDockerサンドボックスでPythonコードを実行する
install_package_in_sandbox : 指定された Docker サンドボックスに Python パッケージをインストールします
check_package_installation_status : Dockerサンドボックスでパッケージがインストールされているかどうか、またはインストールステータスを確認します。
execute_terminal_command : 指定されたDockerサンドボックスでターミナルコマンドを実行します。パラメータ:
sandbox_id(文字列)、command(文字列)。戻り値:stdout、stderr、exit_code。upload_file_to_sandbox : 指定された Docker サンドボックスにローカル ファイルをアップロードします。パラメーター:
sandbox_id(文字列)、local_file_path(文字列)、dest_path(文字列、オプション、デフォルト:/app/results)。
プロジェクト構造
python-mcp-sandbox/
├── main.py # Application entry point
├── requirements.txt # Project dependencies
├── Dockerfile # Docker configuration for Python containers
├── results/ # Directory for generated files
├── mcp_sandbox/ # Main package directory
│ ├── __init__.py
│ ├── models.py # Pydantic models
│ ├── api/ # API related components
│ │ ├── __init__.py
│ │ └── routes.py # API route definitions
│ ├── core/ # Core functionality
│ │ ├── __init__.py
│ │ ├── docker_manager.py # Docker container management
│ │ └── mcp_tools.py # MCP tools
│ └── utils/ # Utilities
│ ├── __init__.py
│ ├── config.py # Configuration constants
│ ├── file_manager.py # File management
│ └── task_manager.py # Periodic task management
└── README.md # Project documentation例のプロンプト
I've configured a Python code execution sandbox for you. You can run Python code using the following steps:
1. First, use the "list_sandboxes" tool to view all existing sandboxes (Docker containers).
- You can reuse an existing sandbox_id if a sandbox exists, do not create a new one.
- If you need a new sandbox, use the "create_sandbox" tool.
- Each sandbox is an isolated Python environment, and the sandbox_id is required for all subsequent operations.
2. If you need to install packages, use the "install_package_in_sandbox" tool
- Parameters: sandbox_id and package_name (e.g., numpy, pandas)
- This starts asynchronous installation and returns immediately with status
3. After installing packages, you can check their installation status using the "check_package_installation_status" tool
- Parameters: sandbox_id and package_name (name of the package to check)
- If the package is still installing, you need to check again using this tool
4. Use the "execute_python_code" tool to run your code
- Parameters: sandbox_id and code (Python code)
- Returns output, errors and links to any generated files
- All generated files are stored inside the sandbox, and file_links are direct HTTP links for inline viewing
Example workflow:
- Use list_sandboxes to check for available sandboxes, if no available sandboxes, use create_sandbox to create a new one → Get sandbox_id
- Use install_package_in_sandbox to install necessary packages (like pandas, matplotlib), with the sandbox_id parameter
- Use check_package_installation_status to verify package installation, with the same sandbox_id parameter
- Use execute_python_code to run your code, with the sandbox_id parameter
Code execution happens in a secure sandbox. Generated files (images, CSVs, etc.) will be provided as direct HTTP links, which can viewed inline in the browser.
Remember not to use plt.show() in your Python code. For visualizations:
- Save figures to files using plt.savefig() instead of plt.show()
- For data, use methods like df.to_csv() or df.to_excel() to save as files
- All saved files will automatically appear as HTTP links in the results, which you can open or embed directly.MCP の例の設定
以下は claude の設定例です。
{
"mcpServers": {
"mcpSandbox": {
"command": "npx",
"args": ["-y", "supergateway", "--sse", "http://localhost:8000/sse"]
}
}
}オンラインデモ用のMCPサンプル構成
{
"mcpServers": {
"mcpSandbox": {
"command": "npx",
"args": ["-y", "supergateway", "--sse", "http://115.190.87.78/sse?api_key=<API_KEY>"]
}
}
}環境に応じてserverUrl変更します。
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to safely execute code in isolated Docker containers with resource limits and security controls, supporting session management and automatic dependency installation.MIT
- AlicenseNot gradedqualityCmaintenanceEnables LLMs to execute Python code securely in a sandboxed environment. Supports configurable restrictions like no network access and returns results including files.MIT
- FlicenseNot gradedqualityDmaintenanceThis is a secure Python code execution server that enables LLMs to run Python code safely in isolated Docker containers, supporting stdout capture and Matplotlib PNG generation.3
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to securely execute Python and JavaScript code in sandboxed environments, with file management and package installation.46
Related MCP Connectors
Execute code in 8 languages (Python, JS, TS, Go, Java, C++, C, Bash) in gVisor sandboxes.
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Persistent cloud development environments that coding agents create, run and test software in.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/JohanLi233/mcp-sandbox'
If you have feedback or need assistance with the MCP directory API, please join our Discord server