使用说明
MCP网关
MCP网关是一个可流式HTTP代理服务器,它将HTTP/JSON-RPC请求桥接到作为stdio进程运行的多个MCP(模型上下文协议)服务器。
特性
- MCP服务器的HTTP代理(stdio→ 流式HTTP)
- 用于配置管理的Web UI
- 首次请求时自动启动MCP服务器
- 支持工具、资源和提示
- Docker支持
快速开始
使用Docker Compose
# Create your mcp.json configuration
cp sample.mcp.json mcp.json
# Start the server
docker compose up --build
访问web UIhttp://localhost:8080
手动设置
# Build frontend
cd frontend
bun install
bun run build
cd ..
# Run server
go run . --addr :8080 --config mcp.json
配置
创建 mcp.json 根据您的MCP服务器定义:
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "@example/mcp-server"],
"env": {
"API_KEY": "your-api-key"
},
"disabled": false
}
}
}
配置选项
| 字段 | 类型 | 描述 |
|---|---|---|
command |
string | 可执行命令 |
args |
string[] | 命令参数 |
env |
object | 环境变量 |
disabled |
boolean | 禁用服务器 |
API
MCP代理端点
POST /v1/proxy/{server-name}
Content-Type: application/json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/list",
"params": {}
}
支持的方法:
initializetools/listtools/callresources/listresources/readprompts/listprompts/getping
管理API
| 方法 | 端点 | 描述 |
|---|---|---|
| 得到 | /api/config |
获取配置 |
| PUT | /api/config |
保存配置 |
| 职位 | /api/config/reload |
重新加载并重新启动服务器 |
| 得到 | /api/servers |
列出服务器状态 |
| 职位 | /api/servers/{name}/start |
启动服务器 |
| 职位 | /api/servers/{name}/stop |
停止服务器 |
与MCP客户端一起使用
配置您的MCP客户端以使用指向网关的HTTP传输:
http://localhost:8080/v1/proxy/{server-name}
发展
后端
go run . --addr :8080 --config mcp.json
前端
cd frontend
bun install
bun run dev # Starts on port 3000
许可证
麻省理工学院
