🦀 生锈的工具MCP代理
使用Rust编写的高性能模型上下文协议(MCP)代理服务器,通过RESTneneneba API提供对多个MCP服务器(本地和远程)的统一访问。
______________________________________________________________________
目录
______________________________________________________________________
关于
Rusted-Tools是一个MCP代理服务器,允许您通过单个REST API管理多个模型上下文协议服务器。它支持本地服务器(Node.js、Docker、基于stdio)和具有透明转发的远程HTTP/SSE端点。
主要特点
- 🚀 多服务器管理 -同时运行多个MCP服务器
- 🔧 本地和远程支持 -基于stdio和HTTP/SSE端点
- 🌐 REST API -用于工具发现和执行的简单HTTP接口
- 🛡️ 工具筛选 -本地服务器的允许列表/阻止列表
- ⚡ 高性能 -使用Rust、Tokio和Axum构建
- 🔀 透明代理 -无需协议转换即可转发远程服务器
状态
生产就绪:
- ✅ 本地MCP服务器管理(基于stdio)
- ✅ 远程MCP服务器支持(HTTP/SSE反向代理)
- ✅ 本地端点的原生MCP HTTP/SSE协议
- ✅ 通过REST API发现和执行工具
- ✅ Docker和Node.js服务器支持
进行中:
- ⚠️ 认证
- ⚠️ 指标收集
______________________________________________________________________
入门指南
先决条件
- 锈蚀1.92+(rustup.rs)
- Docker(可选,适用于基于Docker的服务器)
- Node.js(可选,适用于Node.js服务器)
安装
酿造
添加点击:
brew tap mikart143/tap安装:
brew install rusted-toolsGithub发布
从下载最新版本
手动构建
git clone https://github.com/mikart143/rusted-tools
cd rusted-tools
cargo build --release二进制位置: ./target/release/rusted-tools
快速开始
创建 config.toml:
[http]
host = "127.0.0.1"
port = 3000
# Local MCP server
[[endpoints]]
name = "memory"
type = "local"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-memory"]
auto_start = true
# Remote MCP server
[[endpoints]]
name = "remote-api"
type = "remote"
url = "https://learn.microsoft.com/api/mcp"启动代理:
./target/release/rusted-tools --config config.toml测试一下:
# List servers
curl http://localhost:3000/servers | jq .
# List tools
curl http://localhost:3000/mcp/memory/tools | jq .
# Call a tool
curl -X POST http://localhost:3000/mcp/memory/tools/call \
-H "Content-Type: application/json" \
-d '{"name":"create_entities","arguments":{"entities":[{"name":"Test","entityType":"Demo","observations":["Hello"]}]}}' | jq .______________________________________________________________________
如何使用
REST API端点
管理层:
| 方法 | 端点 | 描述 |
|---|---|---|
| 得到 | /health | 健康检查 |
| 得到 | /info | 服务器元数据 |
| 得到 | /servers | 列出所有已配置的服务器 |
| 得到 | /servers/{name}/status | 获取服务器的状态 |
| 职位 | /servers/{name}/start | 启动服务器 |
| 职位 | /servers/{name}/stop | 停止服务器 |
| 职位 | /servers/{name}/restart | 重新启动服务器 |
MCP工具:
| 方法 | 端点 | 描述 |
|---|---|---|
| 得到 | /mcp/{path}/tools | 列出可用工具 |
| 职位 | /mcp/{path}/tools/call | 执行工具 |
配置
服务器设置:
[http]
host = "127.0.0.1"
port = 3000
[logging]
level = "info" # trace, debug, info, warn, error
format = "pretty" # pretty or json
[mcp]
request_timeout_secs = 30
restart_delay_ms = 500本地MCP服务器:
[[endpoints]]
name = "my-server"
type = "local"
command = "npx"
args = ["-y", "@modelcontextprotocol/server-memory"]
auto_start = true
# Optional tool filtering
[endpoints.tools]
include = ["create_*", "read_*"]
exclude = ["dangerous_*"]远程MCP服务器:
[[endpoints]]
name = "remote-api"
type = "remote"
url = "https://api.example.com/mcp"基于Docker的服务器:
[[endpoints]]
name = "fetch"
type = "local"
command = "docker"
args = ["run", "--rm", "-i", "mcp/fetch"]看 config.toml.example 和 examples/ 更多配置示例。
CLI选项
rusted-tools --config
[OPTIONS]
Options:
--config
Configuration file path (required)
--log-level Log level: trace, debug, info, warn, error
--log-format Output format: pretty or json客户端集成
代理支持多种集成方法:
- 原生MCP HTTP/SSE协议 -直接连接到
/mcp/{endpoint_name}(例如。,http://localhost:3000/mcp/memory)
- 适用于LM Studio、VS Code和任何支持HTTP/SSE的MCP客户端 - 本地端点完全支持本地MCP协议
- REST API -呼叫
/mcp/{endpoint_name}/tools基于JSON的工具交互的端点
- 更适合脚本、扩展和自定义集成
- 服务器管理 -通过以下方式启动/停止端点
/servers/{name}/start和/servers/{name}/stop
______________________________________________________________________
建筑
概述
graph TD
A["Clients"]
B["Rusted-Tools Proxy
(Rust + Tokio + Axum)"]
C["REST API Layer"]
D["Routing Layer"]
E["Endpoint Layer"]
E1["Local Endpoint
(stdio ↔ SSE)"]
E2["Remote Endpoint
(HTTP/SSE Proxy)"]
F["MCP Servers"]
A --> B
B --> C
C --> D
D --> E
E --> E1
E --> E2
E1 --> F
E2 --> F关键组件
| 组件 | 目的 |
|---|---|
| 端点管理器 | 所有服务器的生命周期管理(启动、停止、重新启动) |
| PathRouter | 使用无锁DashMap将请求路径映射到端点 |
| 本地端点 | 生成子流程,桥接stdio↔ HTTP/SSE,过滤工具 |
| 远程端点 | HTTP/SSE的反向代理-透明地转发请求 |
| MCP客户端 | 封装rmcp SDK用于协议通信 |
| 工具筛选器 | 包含/排除本地服务器工具的模式 |
并发
- DashMap 用于无锁并发集合(端点注册表、路径路由)
- 弧形\> 用于共享资源访问
- 东京 所有I/O操作的异步运行时
- 取消令牌 用于优雅关机
技术栈
- rmcp -MCP SDK(协议、传输)
- 阿克苏姆 -HTTP框架
- 东京 -异步运行时
- dashmap -并发哈希映射
- axum反向代理 -透明HTTP/SSE转发
______________________________________________________________________
贡献
欢迎投稿!分叉仓库,创建功能分支,添加测试,并提交PR。运行 cargo test && cargo clippy && cargo fmt 在承诺之前。
______________________________________________________________________
许可证
MIT许可证-请参阅 许可证
______________________________________________________________________
参考文献
- 模型上下文协议规范
- MCP Rust SDK
- 代理商.md -代理集成指南
______________________________________________________________________
版本: 0.1.0
