MCP Code Execution

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 MCP Code Execution?

MCP Code Execution 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

Containerized Python execution
Isolated tool execution for agents
Context optimization
elusznik

Maintainer

LicenseGPL 3.0
Languagepython
Versionv1.0.0
UpdatedMay 21, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx mcp-server-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 MCP Code Execution

MCP Server Code Execution Mode runs Python code inside isolated rootless containers (Podman or Docker) so AI assistants can execute arbitrary scripts without exposing the host system. It implements Anthropic's and Cloudflare's ideas for reducing MCP tool-definition context bloat by exposing a single `run_python` tool that proxies any number of downstream MCP servers discovered at runtime. This makes it ideal for agentic workflows where an AI needs to orchestrate many tools without blowing up the context window with hundreds of tool definitions.

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 distributed as a Python package and run via uvx. Install uv first if you do not already have it.

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

Pull the sandbox container image

The server spins up a fresh Python container for each execution. Pull the base image ahead of time to avoid delays on first run.

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

Test the server manually

Run the server directly with uvx to verify it starts correctly before wiring it into 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

Edit your claude_desktop_config.json (or equivalent) to register the server. Set MCP_BRIDGE_RUNTIME to match your container engine.

5

Configure optional environment variables

Tune the sandbox with environment variables. Key options include MCP_BRIDGE_IMAGE (default: python:3.14-slim), MCP_BRIDGE_TIMEOUT (default: 30s), MCP_BRIDGE_MEMORY (default: 512m), and MCP_BRIDGE_STATE_DIR (default: ~/MCPs) which holds IPC sockets for server discovery.

6

Verify sandbox execution

Ask your MCP client to run a simple Python snippet through the server to confirm the container starts and code executes successfully.

MCP Code Execution Examples

Client configuration

Add this block to your claude_desktop_config.json to register the server with Podman as the container runtime.

{
  "mcpServers": {
    "mcp-server-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": "podman",
        "MCP_BRIDGE_TIMEOUT": "60s",
        "MCP_BRIDGE_MEMORY": "512m"
      }
    }
  }
}

Prompts to try

These prompts demonstrate running Python code in an isolated container and using multi-server orchestration through the single run_python tool.

- "Run this Python script in an isolated container and return the output: import platform; print(platform.python_version())"
- "Use the sandbox to list directory contents via the filesystem MCP server, then summarize what you find"
- "Execute a Python data analysis script that reads a CSV, computes summary statistics, and returns the results"
- "Discover which MCP servers are available in the sandbox and tell me their capabilities"

Troubleshooting MCP Code Execution

Container fails to start with a volume mount error

On Docker Desktop, go to Settings → Resources → File Sharing and add the ~/MCPs/ directory (or the path set in MCP_BRIDGE_STATE_DIR). On Podman, the server auto-configures this via podman machine set.

Server not found after running uvx command

Ensure uv is on your PATH by running `which uvx`. If missing, re-run the uv installer and restart your terminal. Also confirm you have Python 3.11+ with `python3 --version`.

Execution times out on longer scripts

Increase the timeout by setting MCP_BRIDGE_TIMEOUT (e.g., '120s') and MCP_BRIDGE_MAX_TIMEOUT in the env block of your MCP config. The maximum cap is controlled by MCP_BRIDGE_MAX_TIMEOUT.

Frequently Asked Questions about MCP Code Execution

What is MCP Code Execution?

MCP Code Execution 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 MCP Code Execution?

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

Which AI clients work with MCP Code Execution?

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

Is MCP Code Execution free to use?

Yes, MCP Code Execution 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": { "mcp-server-code-execution-mode": { "command": "npx", "args": ["-y", "mcp-server-code-execution-mode"] } } }

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

Read the full setup guide →

Ready to use MCP Code Execution?

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