Related MCP Server Resources

Explore more AI models, providers, and integration options:

  • Explore AI Models
  • Explore AI Providers
  • Explore MCP Servers
  • LangDB Pricing
  • Documentation
  • AI Industry Blog
  • MCP Package Docs Server
  • MCP Unreal Server
  • TripAdvisor Vacation Planner MCP Server
  • doc-lib-mcp
  • Python Codebase Analysis RAG System
Back to MCP Servers
MCP Sandbox

MCP Sandbox

Public
JohanLi233/mcp-sandbox

An interactive Python code execution tool that allows users and LLMs to safely execute Python code and install packages in isolated Docker containers.

Verified
python
0 tools
May 30, 2025
Updated May 30, 2025

MCP Sandbox

Feel free to try on mcp sandbox

δΈ­ζ–‡ζ–‡ζ‘£ | English

Demo

Python MCP Sandbox is an interactive Python code execution tool that allows users and LLMs to safely execute Python code and install packages in isolated Docker containers.

Viby

Viby works with mcp sandbox

Features

  • 🐳 Docker Isolation: Securely run Python code in isolated Docker containers
  • πŸ“¦ Package Management: Easily install and manage Python packages
  • πŸ“Š File Generation: Support for generating files and accessing them via web links

Installation

# 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

The default SSE endpoint is http://localhost:8000/sse, and you can interact with it via the MCP Inspector through SSE or any other client that supports SSE connections.

Available Tools

  1. create_sandbox: Creates a new Python Docker sandbox and returns its ID for subsequent code execution and package installation
  2. list_sandboxes: Lists all existing sandboxes (Docker containers) for reuse
  3. execute_python_code: Executes Python code in a specified Docker sandbox
  4. install_package_in_sandbox: Installs Python packages in a specified Docker sandbox
  5. check_package_installation_status: Checks if a package is installed or installation status in a Docker sandbox
  6. execute_terminal_command: Executes a terminal command in the specified Docker sandbox. Parameters: sandbox_id (string), command (string). Returns stdout, stderr, exit_code.
  7. upload_file_to_sandbox: Uploads a local file to the specified Docker sandbox. Parameters: sandbox_id (string), local_file_path (string), dest_path (string, optional, default: /app/results).

Project Structure

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

Example Prompt

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 Example Config

Below is an example config for claude:

{ "mcpServers": { "mcpSandbox": { "command": "npx", "args": ["-y", "supergateway", "--sse", "http://localhost:8000/sse"] } } }

MCP Example Config for Online Demo

{ "mcpServers": { "mcpSandbox": { "command": "npx", "args": ["-y", "supergateway", "--sse", "http://115.190.87.78/sse?api_key="] } } }

Modify the serverUrl as needed for your environment.

Publicly Shared Threads0

Discover shared experiences

Shared threads will appear here, showcasing real-world applications and insights from the community. Check back soon for updates!

Share your threads to help others
Related MCPs5
  • MCP Package Docs Server
    MCP Package Docs Server

    Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python...

    11 tools
    Added May 30, 2025
  • MCP Unreal Server
    MCP Unreal Server

    A server implementation that enables remote Python code execution in Unreal Engine environments, fea...

    Added May 30, 2025
  • TripAdvisor Vacation Planner MCP Server
    TripAdvisor Vacation Planner MCP Server

    This MCP server provides access to TripAdvisor data for planning vacations, enabling users to search...

    Added May 30, 2025
  • doc-lib-mcp
    doc-lib-mcp

    A Model Context Protocol server for ingesting, chunking and semantically searching documentation fil...

    Added May 30, 2025
  • Python Codebase Analysis RAG System
    Python Codebase Analysis RAG System

    An MCP server that analyzes Python codebases using AST, stores code elements in a vector database, a...

    Added May 30, 2025