instavm/coderunner

A secure local sandbox to run LLM-generated code using Apple containers

License:Apache-2.0Language:Python71530
anthropicappleapple-containerclaude-codeclaude-skillscontainerizationgemini-clillmllmstudiomcpopenai

Deep Analysis

Secure sandbox MCP server based on Apple containers that allows LLMs to directly execute generated code and process local files.

Recommended

Core Features

Code runs in isolated Apple containers providing VM-level isolation

No cloud upload required, directly process local videos, images, and documents

Supports Claude, OpenAI, Gemini, and multiple AI model integrations

Built-in PDF replacement, image processing, and other preset tools with custom extension support

Technical Implementation

Architecture:MCP Server + Apple Container Sandbox + Skills System, providing isolated code execution and tool management
Execution Flow:

Key Components:
Apple Container
MCP Protocol
Python/Jupyter
Highlights
  • Isolated execution protects host system security, prevents malicious code damage
  • Local processing of sensitive data, completely private without cloud upload
  • Multiple integration options supporting Claude, OpenAI, Gemini, and other tools
  • Flexible skills system with pre-installed common tools and custom extension support
Use Cases
  • Process local multimedia files like videos and images for AI analysis and conversion
  • Document processing tasks like PDF form filling and data extraction
  • Privacy-protected local data analysis and algorithm processing
  • Automation workflows integrating LLM code generation capabilities
Limitations
  • Mac only, requires Apple Silicon (M1/M2/M3/M4)
  • Requires pre-installed Python 3.10+ and dependencies
Tech Stack
PythonApple ContainerMCPJupyterDockerOpenAI/Claude/Gemini API

Start
License

CodeRunner: Run AI Generated Code Locally

CodeRunner is an MCP (Model Context Protocol) server that executes AI-generated code in a sandboxed environment on your Mac using Apple's native containers.

Key use case: Process your local files (videos, images, documents, data) with remote LLMs like Claude or ChatGPT without uploading your files to the cloud. The LLM generates code that runs locally on your machine to analyze, transform, or process your files.

What CodeRunner Enables

Without CodeRunner With CodeRunner
LLM writes code, you run it manually LLM writes and executes code, returns results
Upload files to cloud for AI processing Files stay on your machine, processed locally
Install tools and dependencies yourself Tools available in sandbox, auto-installs others
Copy/paste scripts to run elsewhere Code runs immediately, shows output/files
LLM analyzes text descriptions of files LLM directly processes your actual files
Manage Python environments and packages Pre-configured environment ready to use

Quick Start

Prerequisites: Mac with macOS and Apple Silicon (M1/M2/M3/M4), Python 3.10+

git clone https://github.com/instavm/coderunner.git
cd coderunner
chmod +x install.sh
./install.sh

MCP server will be available at: http://coderunner.local:8222/mcp

Install required packages (use virtualenv and note the python path):

pip install -r examples/requirements.txt

Integration Options

Option 1: Claude Desktop Integration

Configure Claude Desktop to use CodeRunner as an MCP server:

demo1

demo2

demo4

  1. Copy the example configuration:

    cd examples
    cp claude_desktop/claude_desktop_config.example.json claude_desktop/claude_desktop_config.json
    
  2. Edit the configuration file and replace the placeholder paths:

    • Replace /path/to/your/python with your actual Python path (e.g., /usr/bin/python3 or /opt/homebrew/bin/python3)
    • Replace /path/to/coderunner with the actual path to your cloned repository

    Example after editing:

    {
      "mcpServers": {
        "coderunner": {
          "command": "/opt/homebrew/bin/python3",
          "args": ["/Users/yourname/coderunner/examples/claude_desktop/mcpproxy.py"]
        }
      }
    }
    
  3. Update Claude Desktop configuration:

    • Open Claude Desktop
    • Go to Settings β†’ Developer
    • Add the MCP server configuration
    • Restart Claude Desktop
  4. Start using CodeRunner in Claude:
    You can now ask Claude to execute code, and it will run safely in the sandbox!

Option 2: Python OpenAI Agents

Use CodeRunner with OpenAI's Python agents library:

demo3

  1. Set your OpenAI API key:

    export OPENAI_API_KEY="your-openai-api-key-here"
    
  2. Run the client:

    python examples/openai_agents/openai_client.py
    
  3. Start coding:
    Enter prompts like "write python code to generate 100 prime numbers" and watch it execute safely in the sandbox!

Option 3: Gemini-CLI

Gemini CLI is recently launched by Google.

~/.gemini/settings.json
{
  "theme": "Default",
  "selectedAuthType": "oauth-personal",
  "mcpServers": {
    "coderunner": {
      "httpUrl": "http://coderunner.local:8222/mcp"
    }
  }
}

gemini1

gemini2

Option 4: Kiro by Amazon

Kiro is recently launched by Amazon.

~/.kiro/settings/mcp.json
{
  "mcpServers": {
    "coderunner": {
      "command": "/path/to/venv/bin/python",
      "args": [
        "/path/to/coderunner/examples/claude_desktop/mcpproxy.py"
      ],
      "disabled": false,
      "autoApprove": [
        "execute_python_code"
      ]
    }
  }
}

kiro

Option 5: Coderunner-UI (Offline AI Workspace)

Coderunner-UI is our own offline AI workspace tool designed for full privacy and local processing.

coderunner-ui

coderunner-ui

Security

Code runs in an isolated container with VM-level isolation. Your host system and files outside the sandbox remain protected.

From @apple/container:

Each container has the isolation properties of a full VM, using a minimal set of core utilities and dynamic libraries to reduce resource utilization and attack surface.

Skills System

CodeRunner includes a built-in skills system that provides pre-packaged tools for common tasks. Skills are organized into two categories:

Built-in Public Skills

The following skills are included in every CodeRunner installation:

  • pdf-text-replace - Replace text in fillable PDF forms
  • image-crop-rotate - Crop and rotate images

Using Skills

Skills are accessed through MCP tools:

# List all available skills
result = await list_skills()

# Get documentation for a specific skill
info = await get_skill_info("pdf-text-replace")

# Execute a skill's script
code = """
import subprocess
subprocess.run([
    'python',
    '/app/uploads/skills/public/pdf-text-replace/scripts/replace_text_in_pdf.py',
    '/app/uploads/input.pdf',
    'OLD TEXT',
    'NEW TEXT',
    '/app/uploads/output.pdf'
])
"""
result = await execute_python_code(code)

Adding Custom Skills

Users can add their own skills to the ~/.coderunner/assets/skills/user/ directory:

  1. Create a directory for your skill (e.g., my-custom-skill/)
  2. Add a SKILL.md file with documentation
  3. Add your scripts in a scripts/ subdirectory
  4. Skills will be automatically discovered by the list_skills() tool

Skill Structure:

~/.coderunner/assets/skills/user/my-custom-skill/
β”œβ”€β”€ SKILL.md              # Documentation with usage examples
└── scripts/              # Your Python/bash scripts
    └── process.py

Example: Using the PDF Text Replace Skill

# Inside the container, execute:
python /app/uploads/skills/public/pdf-text-replace/scripts/replace_text_in_pdf.py \
    /app/uploads/tax_form.pdf \
    "John Doe" \
    "Jane Smith" \
    /app/uploads/tax_form_updated.pdf

Architecture

CodeRunner consists of:

  • Sandbox Container: Isolated execution environment with Jupyter kernel
  • MCP Server: Handles communication between AI models and the sandbox
  • Skills System: Pre-packaged tools for common tasks (PDF manipulation, image processing, etc.)

Examples

The examples/ directory contains:

  • openai-agents - Example OpenAI agents integration
  • claude-desktop - Example Claude Desktop integration

Contributing

We welcome contributions! Please see CONTRIBUTING.md for guidelines.

License

This project is licensed under the Apache 2.0 License - see the LICENSE file for details.

Highly Recommended
agents

wshobson/agents

wshobson

Intelligent automation and multi-agent orchestration for Claude Code

The most comprehensive Claude Code plugin ecosystem, covering full-stack development scenarios with a three-tier model strategy balancing performance and cost.

25.6k2.8k3 days ago
Highly Recommended
awesome-claude-skills

ComposioHQ/awesome-claude-skills

ComposioHQ

A curated list of awesome Claude Skills, resources, and tools for customizing Claude AI workflows

The most comprehensive Claude Skills resource list; connect-apps is a killer feature.

19.9k2.0k3 days ago
Recommended
oh-my-opencode

code-yeongyu/oh-my-opencode

code-yeongyu

The Best Agent Harness. Meet Sisyphus: The Batteries-Included Agent that codes like you.

Powerful multi-agent coding tool, but note OAuth limitations.

17.5k1.2k3 days ago
Highly Recommended
ui-ux-pro-max-skill

nextlevelbuilder/ui-ux-pro-max-skill

nextlevelbuilder

An AI SKILL that provide design intelligence for building professional UI/UX multiple platforms

Essential for designers; comprehensive UI/UX knowledge base.

15.3k1.5k3 days ago
Recommended
claude-mem

thedotmack/claude-mem

thedotmack

A Claude Code plugin that automatically captures everything Claude does during your coding sessions, compresses it with AI (using Claude's agent-sdk), and injects relevant context back into future sessions.

A practical solution for Claude's memory issues.

14.0k9143 days ago
Highly Recommended
planning-with-files

OthmanAdi/planning-with-files

OthmanAdi

Claude Code skill implementing Manus-style persistent markdown planning β€” the workflow pattern behind the $2B acquisition.

Context engineering best practices; an open-source implementation of Manus mode.

9.3k8113 days ago