RC

rocket-connect/mcp-sandbox

开发工具官方

本页由 AI 翻译,技术细节请以原文为准。 查看原文

5 stars 3 forks 质量 50 趋势 13MIT

Turn any JavaScript module into a sandboxed MCP (Model Context Protocol) server with automatic reflection and type inference.

概览

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. - 🔍 - Analyzes JS modules and extracts function signatures - 🛡️ - Executes code in isolated VM contexts with timeouts - 🧠 - Detects parameter types from defaults and naming patterns - 📚 - Extracts documentation from function comments - 📡 - Full JSON-RPC 2.0 and SSE support - 🌐 - Legacy REST endpoints for easy testing - ⚙️ - Full type safety and IntelliSense support Running mcp-sandbox start math-utils.js automatically: 1. 🔍 Reflects the module and discovers functions 2. 📊 Generates type schemas from parameters 3. 🚀 Starts MCP server at http://localhost:3000 4. 💾 Creates mcp-config.

README

以下为原文 README 节选,完整内容请查看原文。

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

# Install globally for CLI usage
npm install -g @mcp-sandbox/cli

# Or use in a project
npm install @mcp-sandbox/core @mcp-sandbox/cli

Basic Usage

# Start MCP server for a JavaScript module
$ mcp-sandbox start ./math-utils.js

🏗️  Initializing MCP Sandbox...
🔍 Reflecting module
📊 Discovered 2 tools:
  - circleArea: Calculate area of a circle
  - fibonacci: Generate Fibonacci sequence
🚀 MCP Sandbox server running at http://localhost:3000
📋 MCP Tools: http://localhost:3000/mcp/tools
⚡ MCP Execute: http://localhost:3000/mcp/execute
🔄 MCP SSE: http://localhost:3000/sse
📡 MCP JSON-RPC: http://localhost:3000/mcp/jsonrpc
⚙️  MCP Config: http://localhost:3000/mcp-config
💡 For MCP Inspector, use: http://localhost:3000/sse

Example Module

/**
 * Calculate the area of a circle
 * @param radius The radius of the circle
 */
function circleArea(radius = 1) {
  return Math.PI * radius * radius;
}

/**
 * Generate fibonacci sequence
 * @param count Number of fibonacci numbers to generate
 */
function fibonacci(count = 10) {
  const seq = [0, 1];
  for (let i = 2; i < count; i++) {
    seq[i] = seq[i - 1] + seq[i - 2];
  }
  return seq.slice(0, count);
}

module.exports = { circleArea, fibonacci };

Running mcp-sandbox start math-utils.js automatically:

  1. 🔍 Reflects the module and discovers functions
  2. 📊 Generates type schemas from parameters
  3. 🚀 Starts MCP server at http://localhost:3000
  4. 💾 Creates mcp-config.json for MCP clients

📡 API Endpoints

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →