Skip to main content
Glama
jonasslv

Python MCP Sandbox Tool

by jonasslv

Python MCP Sandbox Tool

This tool provides a secure sandbox environment for executing Python scripts via the MCP (Model Communication Protocol). It runs scripts in isolated Docker containers with security constraints.

Features

  • Secure Sandboxing: Runs Python scripts in isolated Docker containers

  • Resource Limits:

    • Memory limit: 4096MB

    • CPU Cores: 4

    • Timeout: 120 seconds

  • Package Allowlist: Only some curated packages are allowed

  • Read-Only Filesystem: Container filesystem is read-only

  • Artifact Support: Returns artifacts created during execution

Related MCP server: py-sandbox

Usage

The tool expects a JSON request with a script field containing the Python code to execute.

Example request:

{
  "script": "print('Hello from sandbox!')\nprint('This is a test script')"
}

Installation

pip install -r requirements.txt

Running

python mcp_sandbox_tool.py

Response Format

The tool returns a JSON response with:

  • status: "success" or "error"

  • stdout: Standard output from the script

  • stderr: Standard error from the script

  • return_code: Exit code of the script

  • artifacts: Files created during execution (if any)

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables code execution in isolated Docker containers with persistent IPython, Node.js, or R kernels, supporting file import/export and cross-session transfers via MCP tools.
    6
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables AI agents to execute arbitrary Python code securely in a sandboxed environment with resource limits and security constraints via MCP protocol.
    MIT
  • A
    license
    A
    quality
    C
    maintenance
    Run Python, JavaScript, or shell snippets in secure, resource-limited Docker containers with no network access, exposed as MCP tools.
    2
    Apache 2.0