M
MCP Forwarder
by @dabaicai001
mcp 转发配置服务
Created 10/20/2025
Updated about 2 months ago
README
Repository documentation and setup instructions
MCP Forwarder
一个基于JSON-RPC 2.0的Model Context Protocol (MCP) 服务转发工具,通过SQLite数据库存储服务链接和函数信息。
功能特性
- ✅ JSON-RPC 2.0协议支持
- ✅ SQLite数据库存储服务信息
- ✅ 自动服务注册和工具发现
- ✅ 请求转发和负载均衡
- ✅ RESTful API管理接口
架构设计
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ MCP Client │────│ MCP Forwarder │────│ External MCP │
│ │ │ │ │ Services │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
┌───────────────┐
│ SQLite DB │
│ - Services │
│ - Tools │
└───────────────┘
快速开始
1. 安装依赖
go mod tidy
2. 启动服务器
go run cmd/server/main.go
3. 注册外部MCP服务
curl -X POST http://localhost:8080/register \
-H "Content-Type: application/json" \
-d '{
"name": "bazi-service",
"url": "http://localhost:3000/mcp",
"description": "八字mcp 服务"
}'
4. 发送JSON-RPC请求
curl -X POST http://localhost:8080/jsonrpc \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "tools/call/example-tool",
"params": {
"input": "test"
},
"id": 1
}'
API接口
JSON-RPC端点
POST /jsonrpc- 处理JSON-RPC 2.0请求
管理接口
POST /register- 注册新的MCP服务GET /services- 列出所有已注册的服务GET /health- 健康检查
数据库结构
mcp_services 表
id- 主键name- 服务名称url- 服务URLdescription- 服务描述is_active- 是否激活created_at- 创建时间updated_at- 更新时间
mcp_tools 表
id- 主键service_id- 外键,关联服务name- 工具名称description- 工具描述input_schema- 输入参数schemacreated_at- 创建时间
开发
项目结构
├── cmd/server/main.go # 服务器入口
├── client/ # JSON-RPC客户端
├── database/ # 数据库操作
├── forwarder/ # 转发器核心
├── models/ # 数据模型
└── config/ # 配置文件
构建
# 构建可执行文件
go build -o mcp-forwarder cmd/server/main.go
# 运行
./mcp-forwarder
许可证
MIT License
Quick Setup
Installation guide for this server
Installation Command (package not published)
git clone https://github.com/dabaicai001/mcp-forwarder
Manual Installation: Please check the README for detailed setup instructions and any additional dependencies required.
Cursor configuration (mcp.json)
{
"mcpServers": {
"dabaicai001-mcp-forwarder": {
"command": "git",
"args": [
"clone",
"https://github.com/dabaicai001/mcp-forwarder"
]
}
}
}