coderunner

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

165
6
<div align="center">

Start
License

</div>

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 CodeRunnerWith CodeRunner
LLM writes code, you run it manuallyLLM writes and executes code, returns results
Upload files to cloud for AI processingFiles stay on your machine, processed locally
Install tools and dependencies yourselfTools available in sandbox, auto-installs others
Copy/paste scripts to run elsewhereCode runs immediately, shows output/files
LLM analyzes text descriptions of filesLLM directly processes your actual files
Manage Python environments and packagesPre-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/BandarLabs/coderunner.git
cd coderunner
chmod +x install.sh
sudo ./install.sh

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

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

pip install -r examples/requirements.txt

Integration Options

Option 1: Claude Desktop Integration

demo1

<details> <summary>Configure Claude Desktop to use CodeRunner as an MCP server:</summary>

demo2

demo4

  1. Copy the example configuration:
cd examples
cp claude_desktop/claude_desktop_config.example.json claude_desktop/claude_desktop_config.json
  1. 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"]
}
}
}
  1. Update Claude Desktop configuration:
  • Open Claude Desktop
  • Go to Settings → Developer
  • Add the MCP server configuration
  • Restart Claude Desktop
  1. Start using CodeRunner in Claude:
    You can now ask Claude to execute code, and it will run safely in the sandbox!</details>

Option 2: Python OpenAI Agents

<details> <summary>Use CodeRunner with OpenAI's Python agents library:</summary>

demo3

  1. Set your OpenAI API key:
export OPENAI_API_KEY="your-openai-api-key-here"
  1. Run the client:
python examples/openai_agents/openai_client.py
  1. Start coding:
    Enter prompts like "write python code to generate 100 prime numbers" and watch it execute safely in the sandbox!</details>

Option 3: Gemini-CLI

Gemini CLI is recently launched by Google.

<details> <summary>~/.gemini/settings.json</summary>
{
 "theme": "Default",
 "selectedAuthType": "oauth-personal",
 "mcpServers": {
 "coderunner": {
 "url": "http://coderunner.local:8222/sse"
 }
 }
}

gemini1

gemini2

</details>

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.

Architecture

CodeRunner consists of:

  • Sandbox Container: Isolated execution environment with Jupyter kernel
  • MCP Server: Handles communication between AI models and the sandbox

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.

Repository

BA
BandarLabs

BandarLabs/coderunner

Created

June 23, 2025

Updated

July 7, 2025

Language

Python

Category

AI