Sandboxed Python execution for AI agents. PEP 723 inline deps, multi-version Python, zero pollution.
Copy the AI prompt to install this server into Claude Code, Cursor, or another agent β or use 1-click editor setup below.
We haven't yet run this listing's install command through our automated sandbox check. This isn't a red flag β we're steadily working through the catalog.
π‘ Paste the JSON block into your client's configuration file under mcpServers, then restart the application.
Sandboxed Python execution for AI agents. Scripts run in ephemeral, isolated environments with inline dependencies (PEP 723) -- zero host pollution, zero leftover venvs, zero package conflicts.
Every coding agent can already run Python on your host. The problem is what happens next: packages accumulate, venvs sprawl, and a rogue pip install breaks your system. mcp-python-exec-sandbox eliminates this:
uv# /// script blocksAll setups require:
uvx for running the server without installing it globally.Additional requirements depend on your chosen sandbox backend:
| Setup | Additional requirements | Install |
|---|---|---|
| Native sandbox (Linux) | bubblewrap | sudo apt install bubblewrap |
| Docker sandbox (macOS, any) | Docker Engine | See Docker docs |
| No sandbox | None | -- |
Host Python vs. execution Python: These are independent. Python 3.13+ is needed to run the server process itself. The
--python-versionflag controls which Python version your scripts execute on -- uv downloads the target version automatically. You do not need to install Python 3.14 or 3.15 on your host to run scripts on those versions.
The Docker sandbox image is pulled automatically from GHCR on first use. No manual build required.
Add to .cursor/mcp.json (project-level) or ~/.cursor/mcp.json (global):
Or add to .codex/config.toml:
Any client that supports the MCP stdio transport can use this server:
Use --python-version to target a specific Python version. uv downloads it automatically -- no manual install needed.
This works across all sandbox backends. The Docker sandbox uses uv inside the container to manage Python versions, so the same --python-version flag applies.
execute_pythonExecute a Python script with automatic dependency management.
| Parameter | Type | Default | Description |
|---|---|---|---|
script | str | required | Python source code, may include PEP 723 inline metadata |
dependencies | list[str] | [] | Extra PEP 508 dependency specifiers to merge |
timeout_seconds | int | 30 | Maximum execution time (1--300) |
check_environmentReturns information about the execution environment: Python version, uv version, platform, sandbox status, and configuration.
validate_scriptValidates a script's PEP 723 metadata and dependencies without executing it.
| Parameter | Type | Default | Description |
|---|---|---|---|
script | str | required | Python source code to validate |
dependencies | list[str] | [] | Extra dependency specifiers to validate |
| Backend | Platform | Tool | Notes |
|---|---|---|---|
native | Linux | bubblewrap | Namespace isolation, network allowed |
docker | Any | Docker | Container isolation, resource limits |
none | Any | -- | No sandboxing (not recommended) |
The default backend is native (bubblewrap) on Linux and docker on macOS/other platforms. Specifying --sandbox-backend native on macOS automatically redirects to Docker. If the sandbox tool is unavailable, the server falls back to none with a warning.
The Docker sandbox image is published to GHCR and pulled automatically when the server starts. No manual setup is needed.
To build locally for development:
Unit and integration tests -- fast, run everywhere:
E2E tests -- require uv and network access. These exercise real script execution, package installation, MCP protocol flow, and sandbox enforcement:
The Docker E2E tests (e2e_tests/test_docker_sandbox.py) verify execution, dependency installation, read-only filesystem enforcement, host isolation, and timeout handling through the Docker backend.
Prerequisites:
Then run:
These tests are automatically skipped if Docker is unavailable or the image hasn't been built.
The Linux sandbox tests (e2e_tests/test_sandbox_enforcement.py::test_linux_sandbox_blocks_etc_shadow) use bubblewrap (bwrap) for namespace isolation. They are skipped on macOS because bwrap is Linux-only.
To run them from macOS, use the included devcontainer which provides Ubuntu 24.04 with bwrap pre-installed:
VS Code:
CLI:
No reviews yet β be the first to share how this listing worked for you.
Showcase your server listing on GitHub or your project documentation. Embed this dynamic SVG badge to highlight official listing status and live engagement.
[](https://allmcps.com/mcp/python-exec-sandbox)<a href="https://allmcps.com/mcp/python-exec-sandbox"><img src="https://allmcps.com/api/badge/python-exec-sandbox?style=directory" alt="Python Exec Sandbox on AllMCPs" /></a>