mcp-stama: 為 AI Agent 設計的高性能 Rust MCP Server
mcp-stama 是一款使用 Rust 編寫的高性能 Model Context Protocol (MCP) server,旨在透過單一靜態二進位檔為 AI 編碼 Agent 提供本地上下文。它消除了與 Node.js 或 Python 運行時相關的開銷,將冷啟動時間從數秒降低至 2 毫秒以下,並將記憶體使用量從數百 MB 降低至 10MB 以下。
Performance Benchmarks
mcp-stama 在所有主要資源指標上都顯著優於基於 Node.js 或 Python 的傳統 MCP server。透過利用原生 Rust 實作,它實現了近乎即時的執行速度與極低的系統影響。
| Metric | Legacy MCP Servers (Node / Python) | mcp-stama (Rust) |
|---|---|---|
| Cold Startup Time | 1,500ms – 3,000ms | < 2ms |
| p50 Execution Latency | 150ms – 800ms | 300µs – 5ms |
| Memory Footprint (RSS) | 180 MB – 350 MB | < 10 MB |
| Dependencies | 100+ packages | Zero external runtimes |
| Installation | Requires Node.js / Python setup | Single static binary |
內部針對特定工具的微基準測試進一步證明了這種效率:
| Tool Name | Invocations | p50 Latency | p99 Latency | Memory Footprint (RSS) |
|---|---|---|---|---|
docker_watcher |
100 | 327 µs | 1.66 ms | < 10 MB |
git_snapshot |
100 | 462 µs | 1.36 ms | < 10 MB |
fast_grep |
100 | 5.05 ms | 8.72 ms | < 10 MB |
Built-in High-Performance Tools
mcp-stama 包含數個經過工程設計的專用工具,旨在為 AI Agent 提供深度的本地上下文,而無需啟動沉重的子程序或浪費 Prompt Token。
fast_grep
這款工具提供亞毫秒級的文件搜尋與正規表示式掃描。它利用 ignore::WalkBuilder 來自動遵循 .gitignore 與 .ignore 文件,同時跳過二進位檔與隱藏文件。
git_snapshot
由 gix (gitoxide) 提供動力,這是一個純 Rust 的 Git 檢查器。它能以原生方式獲取 HEAD commits、分支資訊、行差異與文件狀態,無需調用外部的 git 執行檔。
docker_watcher
這款工具使用 bollard 與 sysinfo 提供即時的主機與容器診斷。它讓 AI Agent 能夠洞察正在運行的 Docker 容器、系統記憶體、CPU 核心與映射端口。
Installation and Configuration
mcp-stama 以單一靜態二進位檔形式發行,並包含一個自動配置器以簡化與 AI 編輯器的整合。
Installation
- macOS / Linux:
curl -fsSL https://raw.githubusercontent.com/StamManif/mcp-stama/main/install.sh | sh - Windows (PowerShell):
iwr -useb https://raw.githubusercontent.com/StamManif/mcp-stama/main/install.ps1 | iex - Cargo:
cargo install mcp-stama
Auto-Configuration
用戶可以透過以下標記來自動將 server 注入到編輯器設定中:
- Claude Desktop:
mcp-stama --install-claude - Cursor:
mcp-stama --install-cursor
Manual Configuration
對於手動設定,請將以下內容添加到對應的配置檔案(Cursor 的 ~/.cursor/mcp.json 或 Claude Desktop 的 claude_desktop_config.json):
{
"mcpServers": {
"mcp-stama": {
"command": "mcp-stama",
"args": []
}
}
}
Technical Architecture
mcp-stama 實作了 Pure Stdio JSON-RPC 2.0 介面。為了嚴格遵守 JSON-RPC 框架協議,所有診斷與日誌輸出都會路由至 stderr,確保 stdout 僅專用於協議流量。
請求流程遵循線性路徑: AI Client (Cursor/Claude) $\rightarrow$ StdioTransport $\rightarrow$ JsonRpcRequest/Response $\rightarrow$ ToolRegistry $\rightarrow$ Specific Tool (fast_grep, git_snapshot, or docker_watcher)。
Sources
相關
- 專案
- 專案
- 專案
- 專案
- 專案