mcp-runtime

mcp-runtime

A high-performance MCP execution engine that runs tool code in isolated, resource-constrained sandboxes with context state persistence.

Category
访问服务器

README

<div align="center">

<img src="https://raw.githubusercontent.com/Devopstrio/.github/main/assets/Browser_logo.png" height="90"/>

<h1>mcp-runtime</h1>

<p><strong>High-Performance Model Context Protocol (MCP) Execution Engine & Sandbox Runtime</strong></p>

Build Status Python Version MCP Sandbox Terraform

</div>


Executive Summary

The mcp-runtime repository delivers a high-performance, isolated execution engine and context state lifecycle manager built specifically for the Model Context Protocol (MCP). It provisions ephemeral, resource-constrained sandbox containers to execute untrusted MCP tool code securely without exposing host enterprise infrastructure.

Business Problem

Executing tools invoked by LLMs and autonomous agents presents severe runtime security and stability risks:

  • Resource Exhaustion: Unconstrained tool code can consume excessive CPU or memory, causing noisy-neighbor degradation.
  • Malicious Payload Execution: Untrusted code or shell tools can attempt unauthorized host file system or network access.
  • State Loss: Stateful multi-turn tool conversations require persistent context tracking across ephemeral container executions.

Business Value

  • Zero-Trust Process Isolation: Enforces process sandboxing with strict cgroup memory and CPU limits per tool execution.
  • Sub-Millisecond Execution Overhead: Low-overhead runtime container provisioning for real-time AI assistant responsiveness.
  • Stateful Context Lifecycle Persistence: Automatically persists conversation context state across multi-turn tool calls.

Architecture

Architecture Diagram

High-Level Execution Sequence

graph TD
    Gateway["MCP Gateway / AI Assistant"] --> RuntimeAPI["MCP Runtime Execution API"]
    RuntimeAPI --> Executor["MCP Tool Execution Engine"]
    RuntimeAPI --> SandboxMgr["Process Sandbox Isolation Manager"]
    RuntimeAPI --> ContextMgr["Context State Persistence Manager"]
    SandboxMgr --> Container1["Sandbox Container - Memory Limit 512MB"]
    SandboxMgr --> Container2["Sandbox Container - Memory Limit 1024MB"]

Core Components

  • MCP Tool Execution Engine (src/mcp_runtime/core/executor.py): Core execution pipeline running tool handlers inside isolated sandbox containers.
  • Process Sandbox Isolation Manager (src/mcp_runtime/sandbox/process_sandbox.py): Provisions, monitors, and terminates ephemeral process containers.
  • Context Lifecycle State Manager (src/mcp_runtime/services/context_manager.py): Manages state storage and context restoration for agent sessions.
  • FastAPI Async Transport Layer (src/mcp_runtime/api/routes.py): Asynchronous REST endpoints for tool execution, sandbox management, and state persistence.

Repository Structure

mcp-runtime/
├── .github/              # CI/CD workflows, issue & PR templates, CODEOWNERS
├── architecture/         # Mermaid sequence flow diagrams
├── deployment/           # Kubernetes manifests & Kustomize environment overlays
├── docs/                 # Enterprise architectural, deployment, & operational guides
├── examples/             # Real-world request/response JSON payloads
├── images/               # High-resolution architecture & workflow diagrams
├── src/mcp_runtime/      # Python Runtime source (api, core, sandbox, services)
├── terraform/            # Multi-cloud OpenTofu / Terraform IaC modules
├── tests/                # Unit, integration, and API test suites
├── Dockerfile            # Container build specification
├── docker-compose.yml    # Multi-container local orchestration
├── pyproject.toml        # PEP 621 package configuration
└── README.md             # Accelerator documentation manual

Capabilities

  • Ephemeral Container Sandbox: Dynamic spawning and destruction of process sandboxes.
  • Memory & CPU Throttling: Strict memory caps (default 512MB) and CPU core allocation per container.
  • Context State Persistence: High-speed in-memory state tracking with disk serialization.
  • Health & Liveness Probes: Native Kubernetes probes for container health monitoring.

Technology Stack

  • Core Runtime: Python 3.11+, FastAPI 0.110+, Pydantic v2
  • Infrastructure as Code: OpenTofu 1.8.5 / Terraform 1.6+
  • Containerization: Docker, Docker Compose, Kubernetes 1.28+
  • Quality Assurance: Pytest 8.0+, GitHub Actions CI

Implementation

# Clone repository
git clone https://github.com/Devopstrio/mcp-runtime.git
cd mcp-runtime

# Install in editable mode
pip install -e .[dev]

# Run automated unit and integration tests
pytest -v tests/

Deployment

OpenTofu / Terraform Provisioning

cd terraform
tofu init
tofu plan
tofu apply -auto-approve

Kubernetes Kustomize Deployment

kubectl apply -k deployment/kubernetes/overlays/prod/

API Reference

  • GET /health — Returns runtime health status and version.
  • POST /api/v1/execute — Executes an MCP tool payload inside isolated sandbox.
  • POST /api/v1/sandbox/spawn — Spawns an ephemeral process container.
  • DELETE /api/v1/sandbox/{container_id} — Terminates a running sandbox container.
  • POST /api/v1/context/state — Persists context state for session.

Examples

Security

Refer to SECURITY.md for reporting security vulnerabilities. The runtime enforces process sandboxing and cgroup resource isolation.

Observability

The platform exports structured CloudWatch log groups (/aws/mcp-runtime/mcp-runtime) and metric alarms for sandbox memory exhaustion tracking.

Scalability

Horizontal pod autoscaling (HPA) overlays scale runtime worker replicas dynamically based on active container CPU load.

Multi-cloud Strategy

Infrastructure blueprints support AWS ECS/VPC deployment with modular extensions for Docker and Kubernetes containerd runtimes.

Roadmap

See docs/Roadmap.md for upcoming milestones including gVisor / Firecracker MicroVM integration and dynamic CPU cgroup throttling.

Contribution

See CONTRIBUTING.md and CODE_OF_CONDUCT.md for community standards and contribution workflows.


<div align="center"> © 2026 Devopstrio — Engineering the Autonomous Enterprise. </div>

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选