MCP Multi-Language Sandbox
Enables local, Docker-isolated code execution across six programming languages including Python, Rust, and TypeScript. It features pre-warmed container pooling, persistent sessions, and built-in support for machine learning libraries.
README
MCP Multi-Language Sandbox
Execute code securely in 6 programming languages with Docker isolation, designed for Claude Code via Model Context Protocol (MCP).
What is this?
A local MCP server that lets Claude execute code in isolated Docker containers. Think of it as your own private code sandbox - 100% free, 100% local, no cloud dependencies.
Why use this instead of cloud sandboxes?
- Free: No per-execution costs (vs ~$0.10/run on cloud services)
- Fast: 0ms container acquisition with pooling (vs 2-5s cold starts)
- Private: Code never leaves your machine
- Customizable: Add your own languages, packages, security rules
Features
- 6 Languages: Python, TypeScript, JavaScript, Go, Rust, Bash
- Container Pooling: Pre-warmed containers for instant execution
- Package Caching: Install once, reuse forever (SHA256-based)
- ML Runtime: numpy, pandas, sklearn, torch, mlx pre-installed
- Security: Seccomp profiles, capability dropping, audit logging
- Sessions: Persistent state with TTL and auto-cleanup
Quick Start
Prerequisites
- Node.js >= 18.0.0
- Docker Desktop
- Claude Code CLI (optional, for MCP integration)
Installation
# Clone the repository
git clone https://github.com/Pit-CL/mcp-multilang-sandbox.git
cd mcp-multilang-sandbox
# Install dependencies
npm install
# Build
npm run build
# Run tests (optional)
npm run test:mcp
Add to Claude Code
# Add as MCP server
claude mcp add multilang-sandbox node /path/to/mcp-multilang-sandbox/dist/mcp/server.js
# Verify it's connected
claude mcp list
# Should show: multilang-sandbox ✓ Connected
Manual Configuration
Add to your Claude settings (~/.claude.json or VS Code settings):
{
"mcpServers": {
"multilang-sandbox": {
"command": "node",
"args": ["/path/to/mcp-multilang-sandbox/dist/mcp/server.js"],
"env": {
"LOG_LEVEL": "info"
}
}
}
}
Usage
Once configured, Claude can use these tools:
Execute Code
// Python
sandbox_execute({ language: 'python', code: 'print("Hello!")' })
// TypeScript
sandbox_execute({ language: 'typescript', code: 'console.log("Hello!")' })
// With ML libraries (numpy, pandas, sklearn, torch)
sandbox_execute({
language: 'python',
code: 'import numpy as np; print(np.array([1,2,3]))',
ml: true
})
Persistent Sessions
// Create a session
sandbox_session({ action: 'create', name: 'my-project', language: 'python' })
// Execute in session (state persists)
sandbox_execute({ language: 'python', code: 'x = 42', session: 'my-project' })
sandbox_execute({ language: 'python', code: 'print(x)', session: 'my-project' }) // prints 42
// Install packages
sandbox_install({ session: 'my-project', packages: ['pandas', 'requests'] })
// Cleanup
sandbox_session({ action: 'destroy', name: 'my-project' })
File Operations
// Write a file
sandbox_file_ops({ session: 'my-project', operation: 'write', path: 'data.csv', content: 'a,b\n1,2' })
// Read it back
sandbox_file_ops({ session: 'my-project', operation: 'read', path: 'data.csv' })
System Stats
// View pool, cache, and session stats
sandbox_inspect({ target: 'all' })
// Security audit
sandbox_security({ action: 'stats' })
MCP Tools Reference
| Tool | Description |
|---|---|
sandbox_execute |
Execute code in any supported language |
sandbox_session |
Create/list/pause/resume/destroy sessions |
sandbox_install |
Install packages with caching |
sandbox_file_ops |
Read/write/list/delete files in sessions |
sandbox_inspect |
View system stats (pool, cache, sessions) |
sandbox_security |
View audit logs and security events |
Architecture
┌─────────────────────────────────────────────────────────┐
│ Claude / MCP Client │
└───────────────────────────┬─────────────────────────────┘
│ JSON-RPC (stdio)
┌───────────────────────────▼─────────────────────────────┐
│ MCP Sandbox Server │
│ ┌────────────────────────────────────────────────────┐ │
│ │ Tools: execute | session | install | file_ops │ │
│ │ inspect | security │ │
│ ├────────────────────────────────────────────────────┤ │
│ │ Core: ContainerPool | PackageCache | Sessions │ │
│ ├────────────────────────────────────────────────────┤ │
│ │ Security: Seccomp | Capabilities | AuditLogger │ │
│ ├────────────────────────────────────────────────────┤ │
│ │ Runtimes: Python | TS | JS | Go | Rust | Bash │ │
│ └────────────────────────────────────────────────────┘ │
└───────────────────────────┬─────────────────────────────┘
│ Dockerode
┌───────────────────────────▼─────────────────────────────┐
│ Docker Engine │
│ [Container Pool] [Active Sessions] [Image Cache] │
└─────────────────────────────────────────────────────────┘
Security
6 Layers of Protection
- Code Validation - Pattern blocklist (os, subprocess, eval, exec)
- Seccomp Profiles - Syscall filtering per language
- Capability Dropping - CAP_DROP ALL
- Network Isolation - NetworkMode: none
- Resource Limits - Memory, CPU, PIDs, ulimits
- Audit Logging - All operations tracked
Blocked Syscalls
ptrace, mount, umount, kexec_load, init_module, delete_module, reboot, bpf, userfaultfd, and more
Performance
| Metric | Value |
|---|---|
| Pool hit (warm) | 0ms |
| Pool miss (cold) | ~80-100ms |
| Session create | ~85ms |
| Package cache hit | <1ms |
| Python execution | ~60ms |
| Bash execution | ~35ms |
Development
# Watch mode (auto-rebuild)
npm run dev
# Type checking
npm run typecheck
# Run tests
npm run test:all # All tests
npm run test:mcp # MCP tools (19 tests)
npm run test:runtimes # Language runtimes
# Clean build
npm run clean && npm run build
Project Structure
src/
├── mcp/server.ts # MCP server & tool handlers
├── core/
│ ├── ContainerPool.ts # Pre-warmed container pooling
│ ├── PackageCache.ts # SHA256-based package caching
│ └── SessionManager.ts # Persistent sessions with TTL
├── security/
│ ├── seccomp.ts # Syscall filtering profiles
│ └── AuditLogger.ts # Operation audit logging
├── runtimes/
│ ├── PythonRuntime.ts # + PythonMLRuntime for ML
│ ├── TypeScriptRuntime.ts
│ ├── JavaScriptRuntime.ts
│ ├── GoRuntime.ts
│ ├── RustRuntime.ts
│ └── BashRuntime.ts
└── docker/
├── DockerClient.ts # Dockerode wrapper
└── Container.ts # Container abstraction
Contributing
Issues and PRs welcome! This started as a personal project to replace cloud sandboxes with something local and free.
License
MIT
Credits
Built with @modelcontextprotocol/sdk, Dockerode, and Zod.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。