设备MCP网关
高性能 模型上下文协议(MCP)网关 内置于Rust中。此网关充当多路复用器,允许LLM客户端通过单个统一端点与多个上游MCP服务器(本地Stdio进程和远程HTTP/SSE服务)通信。
特性
- 多路复用: 将多个MCP服务器合并到一个工具列表中。
- 命名空间 : 自动为工具添加前缀(例如。,
time_service::get_time)以防止服务器之间的冲突。 - 运输桥接: 将标准JSON-RPC HTTP请求连接到基于Stdio的子进程。
- 声明性配置: 通过简单的
config.yaml文件。 - 与Axum和Tokio共同打造: 完全异步、安全、闪电般快速。
入门指南
先决条件
安装
- 克隆存储库:
git clone https://github.com/youruser/apparatus-mcp-gateway.git
cd apparatus-mcp-gateway
- 构建项目:
cargo build --release
配置
创建 config.yaml 在项目根目录中:
gateway_port: 3000
mcp_servers:
# Local Python server using uvx
time_service:
type: stdio
command: "uvx"
args: ["mcp-server-time"]
# Local Node.js server
filesystem:
type: stdio
command: "node"
args: ["/path/to/mcp-server-filesystem/index.js", "/allowed/path"]
📖 用法
- 运行网关:
cargo run
- 列出可用工具:
curl -X POST http://localhost:3000/message \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","id":"1","method":"tools/list","params":{}}'
- 调用工具:
curl -X POST http://localhost:3000/message \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": "2",
"method": "tools/call",
"params": {
"name": "time_service::get_current_time",
"arguments": {"timezone": "UTC"}
}
}'
发展
格式代码:
cargo fmt棉绒编码:
cargo clippy