Code Execution Mode

v1.0.0Developer Toolsstable

An MCP server that executes Python code in isolated rootless containers with optional MCP server proxying. Implementation of Anthropic's and Cloudflare's ideas for reducing MCP tool definitions context bloat.

agentic-aiagentsanthropicclaudeclaude-code
Share:
332
Stars
0
Downloads
0
Weekly
0/5

What is Code Execution Mode?

Code Execution Mode is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to mcp server that executes python code in isolated rootless containers with optional mcp server proxying. implementation of anthropic's and cloudflare's ideas for reducing mcp tool definitions context b...

An MCP server that executes Python code in isolated rootless containers with optional MCP server proxying. Implementation of Anthropic's and Cloudflare's ideas for reducing MCP tool definitions context bloat.

This server falls under the Developer Tools category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • An MCP server that executes Python code in isolated rootless

Use Cases

Execute Python in isolated containers
MCP context bloat reduction
Anthropic-compatible execution
elusznik

Maintainer

LicenseGPL-3.0
Languagepython
Versionv1.0.0
UpdatedMay 19, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx code-execution-mode

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Code Execution Mode

Code Execution Mode is an MCP server that runs Python inside isolated rootless containers (Podman or Docker), giving AI assistants a safe sandbox for arbitrary code execution. It addresses context window bloat by exposing just one tool — `run_python` — that dynamically proxies any number of downstream MCP servers discovered at runtime, so agents can orchestrate complex multi-tool workflows without loading every tool definition upfront. Built by elusznik as an implementation of Anthropic's and Cloudflare's context-reduction ideas, it is especially useful for agentic pipelines that need secure, reproducible Python execution.

Prerequisites

  • Python 3.11 or higher (3.13+ recommended)
  • Podman or Docker installed and running on macOS or Linux
  • uv package manager (install via: curl -LsSf https://astral.sh/uv/install.sh | sh)
  • An MCP client such as Claude Desktop or Claude Code
  • Docker Desktop users must add ~/MCPs/ to File Sharing under Settings → Resources
1

Install uv package manager

The server is run via uvx, which ships with uv. Install uv if you do not already have it on your system.

curl -LsSf https://astral.sh/uv/install.sh | sh
2

Pull the sandbox container image

Pull the Python slim image that the server uses as its execution sandbox so the first run does not block on a large download.

podman pull python:3.13-slim
# or with Docker:
docker pull python:3.13-slim
3

Run the server to verify it works

Start the server directly from the Git repository using uvx to confirm your environment is correctly configured before adding it to your MCP client.

uvx --from git+https://github.com/elusznik/mcp-server-code-execution-mode mcp-server-code-execution-mode run
4

Add the server to your MCP client configuration

Register the server in claude_desktop_config.json with the appropriate container runtime. The MCP_BRIDGE_STATE_DIR directory is used for IPC socket communication between the host and sandbox.

5

Tune sandbox resource limits

Optionally configure memory, process limits, and timeout via environment variables: MCP_BRIDGE_MEMORY (default 512m), MCP_BRIDGE_PIDS (default 128), MCP_BRIDGE_TIMEOUT (default 30s), and MCP_BRIDGE_MAX_TIMEOUT (default 120s).

Code Execution Mode Examples

Client configuration

Register Code Execution Mode in claude_desktop_config.json. This example uses Docker as the container runtime with a 60-second execution timeout.

{
  "mcpServers": {
    "code-execution-mode": {
      "command": "uvx",
      "args": [
        "--from",
        "git+https://github.com/elusznik/mcp-server-code-execution-mode",
        "mcp-server-code-execution-mode",
        "run"
      ],
      "env": {
        "MCP_BRIDGE_RUNTIME": "docker",
        "MCP_BRIDGE_TIMEOUT": "60s",
        "MCP_BRIDGE_MEMORY": "1g"
      }
    }
  }
}

Prompts to try

These prompts exercise Python execution in the isolated container and multi-server proxying capabilities.

- "Run Python code in the secure sandbox to calculate the first 20 Fibonacci numbers"
- "Execute a script inside the container to fetch JSON from a public API and parse the results"
- "List available MCP servers inside the sandbox, then use one to read a file from my filesystem"
- "Run a Python data pipeline in the isolated environment: load a dataset, filter rows, and return summary statistics"

Troubleshooting Code Execution Mode

Docker Desktop reports a volume sharing error on startup

Open Docker Desktop → Settings → Resources → File Sharing and add ~/MCPs/ (or the path in MCP_BRIDGE_STATE_DIR) to the allowed list, then restart Docker Desktop.

uvx command not found after installation

After running the uv installer, restart your shell or run `source ~/.bashrc` (or ~/.zshrc) so the PATH update takes effect. Verify with `which uvx`.

Code execution times out on data-heavy scripts

Set MCP_BRIDGE_TIMEOUT to a higher value such as '90s' and ensure MCP_BRIDGE_MAX_TIMEOUT is at least as large. Also consider increasing MCP_BRIDGE_MEMORY if the script is memory-intensive.

Frequently Asked Questions about Code Execution Mode

What is Code Execution Mode?

Code Execution Mode is a Model Context Protocol (MCP) server that mcp server that executes python code in isolated rootless containers with optional mcp server proxying. implementation of anthropic's and cloudflare's ideas for reducing mcp tool definitions context bloat. It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Code Execution Mode?

Follow the installation instructions on the Code Execution Mode GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Code Execution Mode?

Code Execution Mode works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Code Execution Mode free to use?

Yes, Code Execution Mode is open source and available under the GPL-3.0 license. You can use it freely in both personal and commercial projects.

Browse More Developer Tools MCP Servers

Explore all developer tools servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "code-execution-mode": { "command": "npx", "args": ["-y", "code-execution-mode"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Code Execution Mode?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides