Hosts the MCP Sandbox repository with examples, documentation, and source code, allowing users to contribute or report issues.
Allows converting any JavaScript module into a sandboxed MCP server with automatic reflection, making JavaScript functions accessible to AI systems with type inference and documentation extraction.
Distributes the MCP Sandbox packages (@mcp-sandbox/cli, @mcp-sandbox/core, @mcp-sandbox/utils) through the npm registry for easy installation and usage.
Provides status badges for the README to display npm version and license information.
Provides full type safety and IntelliSense support for developing MCP servers, with automatic type inference from TypeScript modules.
MCP Sandbox
Turn any JavaScript module into a sandboxed MCP (Model Context Protocol) server with automatic reflection and type inference.
🎯 What is MCP Sandbox?
MCP Sandbox automatically converts JavaScript modules into MCP (Model Context Protocol) compatible servers, making any JavaScript function accessible to AI systems. It uses VM sandboxing for security, automatic type inference, and generates proper MCP configurations.
✨ Features
- 🔍 Automatic Reflection - Analyzes JS modules and extracts function signatures
- 🛡️ Secure Sandboxing - Executes code in isolated VM contexts with timeouts
- 🧠 Smart Type Inference - Detects parameter types from defaults and naming patterns
- 📚 JSDoc Integration - Extracts documentation from function comments
- 📡 MCP Protocol - Full JSON-RPC 2.0 and SSE support
- 🌐 REST API - Legacy REST endpoints for easy testing
- ⚙️ TypeScript - Full type safety and IntelliSense support
🚀 Quick Start
Installation
Basic Usage
Example Module
Running mcp-sandbox start math-utils.js
automatically:
- 🔍 Reflects the module and discovers functions
- 📊 Generates type schemas from parameters
- 🚀 Starts MCP server at
http://localhost:3000
- 💾 Creates
mcp-config.json
for MCP clients
📡 API Endpoints
The server exposes both MCP and REST endpoints:
MCP Protocol (JSON-RPC 2.0)
POST /mcp/jsonrpc
- Main MCP endpointGET /sse
- Server-Sent Events for real-time updates
REST API (for testing)
GET /tools
- List available toolsPOST /execute/:toolName
- Execute a specific toolGET /mcp-config
- Get MCP server configurationGET /health
- Health check
Example Usage
🏗️ Programmatic Usage
📚 Example Modules Included
The repository includes several example modules demonstrating different use cases:
Mathematical Operations (examples/math-utils.js
)
- Circle area calculation
- Fibonacci sequence generation
- Compound interest calculation
- Prime number checking
- Degree/radian conversion
- Factorial calculation
String Manipulation (examples/string-utils.js
)
- Title case conversion
- Random string generation
- Word counting
- Palindrome detection
- String reversal
- Capitalization
Array Operations (examples/array-utils.js
)
- Array shuffling (Fisher-Yates)
- Unique value extraction
- Array chunking
- Set operations (intersection, difference)
- Array flattening
Filesystem Operations (examples/filesystem-utils.js
)
- File reading/writing (async)
- Directory listing and creation
- File searching with patterns
- Disk usage calculation
- File copying and deletion
- Line-by-line file reading
🛠️ Development
🔧 Configuration Options
CLI Options
Programmatic Options
🔒 Security Features
- VM Isolation - Code runs in separate V8 contexts
- Execution Timeouts - Configurable time limits prevent infinite loops
- Memory Limits - Prevent memory exhaustion attacks
- Controlled Requires - Limited module access in sandbox
- Input Validation - Parameter type checking and validation
🎮 Testing with MCP Inspector
- Start your MCP server:
mcp-sandbox start examples/math-utils.js
- Open MCP Inspector
- Set Transport Type to "Streamable HTTP"
- Enter URL:
http://localhost:3000/mcp/jsonrpc
- Connect and test your tools!
📦 Packages
This is a monorepo containing multiple packages:
@mcp-sandbox/cli
- Command-line interface@mcp-sandbox/core
- Core library@mcp-sandbox/utils
- Shared utilities
🤝 Contributing
Contributions are welcome! Please read our Contributing Guide and check out the open issues.
📄 License
MIT License - see LICENSE for details.
🔗 Links
- GitHub Repository: https://github.com/danstarns/mcp-sandbox
- Issues: https://github.com/danstarns/mcp-sandbox/issues
- NPM CLI Package: https://www.npmjs.com/package/@mcp-sandbox/cli
- NPM Core Package: https://www.npmjs.com/package/@mcp-sandbox/core
This server cannot be installed
Automatically converts JavaScript modules into MCP-compatible servers, making any JavaScript function accessible to AI systems through secure sandboxing with automatic type inference.
Related MCP Servers
- AsecurityAlicenseAqualityAn MCP server that generates AI agent tools from Postman collections and requests. This server integrates with the Postman API to convert API endpoints into type-safe code that can be used with various AI frameworks.Last updated -17JavaScriptMIT License
- -securityFlicense-qualityAllows AI models to run JavaScript/TypeScript code through Model Context Protocol tool calls, supporting both one-time script execution and stateful REPL sessions with npm package integration.Last updated -TypeScript
- -securityAlicense-qualityAn MCP server that enables AI assistants to control a web browser through natural language commands, allowing them to navigate websites and extract information via SSE transport.Last updated -505PythonMIT License
- -securityAlicense-qualityAn MCP-compliant server that enables AI systems to interact with mobile and desktop applications through Frida's dynamic instrumentation capabilities, allowing for process management, device control, JavaScript execution, and script injection.Last updated -62PythonMIT License