Skip to main content

Secure, polyglot code execution engine for AI agents with MCP support

Project description

sandboxmcp

Secure, polyglot code execution engine for AI agents with MCP support

Part of the MCP AI Suite.

Features

  • Polyglot execution -- run Python, JavaScript (Node), and shell in isolated environments
  • Process backend for zero-dependency local execution with resource limits
  • Docker hardened mode -- fully isolated containers with memory limits, CPU quotas, and network control
  • Code validation with auto-fix for common issues and dangerous-pattern rejection
  • Secret vault -- in-memory or environment-based credential injection without exposing secrets to agent output
  • Network egress control -- global allowlist of permitted domains, default deny-all
  • Host access guard -- optional controlled access to host commands with allow/block lists and auto-approve mode
  • Web tools -- web search, page fetching, and browser rendering (lazily delegated to websearchmcp; requires the optional browser extra)
  • Full audit logging via SQLite -- every execution, approval, and security event recorded

Installation

pip install mcpaisuite-sandboxmcp
# Optional extras:
pip install "mcpaisuite-sandboxmcp[docker]"        # Docker backend support
pip install "mcpaisuite-sandboxmcp[browser]"       # Web tools (web_search / fetch_webpage / browser_fetch via websearchmcp)
pip install "mcpaisuite-sandboxmcp[workspacemcp]"  # workspacemcp suite integration
pip install "mcpaisuite-sandboxmcp[planningmcp]"   # planningmcp suite integration
pip install "mcpaisuite-sandboxmcp[dev]"           # Development tools
pip install "mcpaisuite-sandboxmcp[all]"           # Docker + browser + suite integrations

The web tools (web_search, fetch_webpage, browser_fetch) are lazily imported from websearchmcp at call time and require the browser extra (or all). Without it, those tools raise an import error while the rest of sandboxmcp works normally.

Quick Start

from sandboxmcp import SandboxFactory, ExecutionRequest, Language

sandbox = SandboxFactory.default()
result = await sandbox.execute(ExecutionRequest(
    code='print("Hello from sandbox!")',
    language=Language.python,
))
print(result.stdout)  # "Hello from sandbox!"

MCP Server

sandboxmcp serve

Configuration

Variable Default Description
SANDBOXMCP_BACKEND process Execution backend: process or docker
SANDBOXMCP_MAX_CONCURRENT 4 Max concurrent executions
SANDBOXMCP_NETWORK false Enable network access
SANDBOXMCP_HOST_ACCESS false Enable host command execution
SANDBOXMCP_HOST_AUTO_APPROVE false Auto-approve host commands
SANDBOXMCP_VAULT memory Vault backend: memory or env
SANDBOXMCP_AUDIT sqlite Audit backend: memory or sqlite
SANDBOXMCP_MAX_RAM_MB 512 Max RAM per execution (MB)
SANDBOXMCP_TIMEOUT 60 Execution timeout (seconds)

Docker Hardened Mode

For maximum isolation, use the Docker backend:

sandbox = SandboxFactory.create(
    default_backend="docker",
    image="python:3.12-slim",
    memory_limit="256m",
    network_mode="none",
)

This runs each execution in a disposable container with enforced memory limits, CPU quotas, and no network access.

API Reference

SandboxPipeline

The central orchestrator for code execution with full security pipeline.

await sandbox.execute(request: ExecutionRequest) -> SandboxResult
await sandbox.create_session(language, namespace) -> Session
await sandbox.execute_in_session(session_id, code) -> SandboxResult
await sandbox.list_sessions() -> list[Session]

SandboxFactory

SandboxFactory.default()                 # Process backend, in-memory vault, no network
SandboxFactory.from_env()                # Build from environment variables
SandboxFactory.from_yaml("config.yaml")  # Build from YAML config
SandboxFactory.create(default_backend="docker", enable_network=True, ...)

Architecture

SandboxPipeline orchestrates a security pipeline: incoming code passes through CodeValidator (syntax check, dangerous-pattern scan, auto-fix), then to the execution backend (Process or Docker), with NetworkGuard controlling egress and InMemoryVault injecting secrets. An AsyncJobQueue manages concurrency, and all events are recorded by the audit logger.

Testing

pip install -e ".[dev]"
pytest tests/ -v

License

AGPL-3.0 — see LICENSE.

Open source for individuals and open-source projects. For commercial use in closed-source products, a commercial license is available — contact contact@mcpaisuite.com.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpaisuite_sandboxmcp-1.0.5.tar.gz (96.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpaisuite_sandboxmcp-1.0.5-py3-none-any.whl (78.5 kB view details)

Uploaded Python 3

File details

Details for the file mcpaisuite_sandboxmcp-1.0.5.tar.gz.

File metadata

  • Download URL: mcpaisuite_sandboxmcp-1.0.5.tar.gz
  • Upload date:
  • Size: 96.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for mcpaisuite_sandboxmcp-1.0.5.tar.gz
Algorithm Hash digest
SHA256 75f040addd782dfc416aff722a3b2d7a130fd862788f3fec51b096aec0ca8ea6
MD5 cb95103fb8b6083d163b1daa4c8ddbf5
BLAKE2b-256 1c5d3cf90a1609ca92a8a8aa01ab7272cd85921ab3bdc3569e782a6dfc7fec67

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcpaisuite_sandboxmcp-1.0.5.tar.gz:

Publisher: release.yml on gashel01/sandboxmcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file mcpaisuite_sandboxmcp-1.0.5-py3-none-any.whl.

File metadata

File hashes

Hashes for mcpaisuite_sandboxmcp-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 9cdf683ff3a665faba78854375b08d3106a7e64c90da56be9c2b3c1060c112d8
MD5 17ca8f5eac35f0eac28474f82cf9774b
BLAKE2b-256 5c0093f15a67ce8adba4b63506dbc76faf5529ed33c402503856a09fbe469c23

See more details on using hashes here.

Provenance

The following attestation bundles were made for mcpaisuite_sandboxmcp-1.0.5-py3-none-any.whl:

Publisher: release.yml on gashel01/sandboxmcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page