Python MCP Sandbox

Integrations

  • Runs Python code in isolated Docker containers for secure execution, enabling safe installation of packages and execution of arbitrary Python code

  • Supports installation and usage of NumPy library in the Python environment as mentioned in the example workflow

  • Supports installation and usage of pandas library for data analysis as mentioned in the example workflow

MCP 샌드박스

mcp 샌드박스 를 자유롭게 사용해 보세요

중국어 문서 | 영어

데모

Python MCP Sandbox는 사용자와 LLM이 안전하게 Python 코드를 실행하고 격리된 Docker 컨테이너에 패키지를 설치할 수 있도록 해주는 대화형 Python 코드 실행 도구입니다.

특징

  • 🐳 Docker Isolation : 격리된 Docker 컨테이너에서 Python 코드를 안전하게 실행합니다.
  • 📦 패키지 관리 : Python 패키지를 쉽게 설치하고 관리하세요
  • 📊 파일 생성 : 파일 생성 및 웹 링크를 통한 파일 액세스 지원

설치

지엑스피1

기본 SSE 엔드포인트는 http://localhost:8000/sse 이며, SSE나 SSE 연결을 지원하는 다른 클라이언트를 통해 MCP Inspector를 통해 상호 작용할 수 있습니다.

사용 가능한 도구

  1. create_sandbox : 새로운 Python Docker 샌드박스를 생성하고 후속 코드 실행 및 패키지 설치를 위해 해당 ID를 반환합니다.
  2. list_sandboxes : 재사용을 위해 기존 샌드박스(Docker 컨테이너)를 모두 나열합니다.
  3. execute_python_code : 지정된 Docker 샌드박스에서 Python 코드를 실행합니다.
  4. install_package_in_sandbox : 지정된 Docker 샌드박스에 Python 패키지를 설치합니다.
  5. check_package_installation_status : Docker 샌드박스에서 패키지가 설치되었는지 또는 설치 상태를 확인합니다.
  6. execute_terminal_command : 지정된 Docker 샌드박스에서 터미널 명령을 실행합니다. 매개변수: sandbox_id (문자열), command (문자열). stdout , stderr , exit_code 반환합니다.
  7. 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 예제 구성

다음은 클로드에 대한 구성 예시입니다.

{ "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 수정하세요.

-
security - not tested
A
license - permissive license
-
quality - not tested

local-only server

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

사용자와 LLM이 안전하게 Python 코드를 실행하고 격리된 Docker 컨테이너에 패키지를 설치할 수 있는 대화형 Python 코드 실행 환경입니다.

  1. Feel free to try on mcp sandbox
    1. Demo
      1. Features
      2. Installation
      3. Project Structure
      4. Example Prompt
      5. MCP Example Config
      6. MCP Example Config for Online Demo

    Related MCP Servers

    • -
      security
      F
      license
      -
      quality
      Provides isolated Docker environments for code execution, enabling users to create and manage containers, execute multi-language code, save and reproduce development environments, ensuring security and isolation.
      Last updated -
      6
      Python
      • Apple
    • A
      security
      A
      license
      A
      quality
      Allows LLMs to execute Python code in a specified Conda environment, enabling access to necessary libraries and dependencies for efficient code execution.
      Last updated -
      1
      29
      JavaScript
      MIT License
    • -
      security
      A
      license
      -
      quality
      Facilitates isolated code execution within Docker containers, enabling secure multi-language script execution and integration with language models like Claude via the Model Context Protocol.
      Last updated -
      Python
      MIT License
      • Linux
      • Apple
    • A
      security
      A
      license
      A
      quality
      A server that provides a persistent Python REPL environment through the MCP protocol, allowing execution of Python code, variable management, and package installation.
      Last updated -
      3
      3
      Python
      MIT License

    View all related MCP servers

    ID: 337zco6046