](https://www.npmjs.com/package/mcp-simple-gateway)
MCP简单网关
MCP简单网关是模型上下文协议(MCP)的代理服务器,允许您通过单个接口聚合和管理多个MCP服务器。
主要特点
- 🚀 聚合多个MCP服务器
- 🔒 基于令牌的身份验证支持
- 📝 灵活的基于JSON的配置
- 🐳 Docker支持
- 🔌 支持SSE、stdio和StreamableHTTP MCP
用法
通过CLI运行
npx mcp-simple-gateway --config config.json通过Docker Compose运行
示例 docker-compose.yml:
services:
mcp-gateway:
platform: linux/amd64 # For Apple Silicon Users
image: ghcr.io/denwakeup/mcp-simple-gateway:latest
volumes:
- ./config.json:/app/config.json
ports:
- '3000:3000'
environment:
- CONFIG_PATH=/app/config.json配置
配置文件示例(config.json):
{
"proxyServer": {
"logLevel": "debug",
"logPretty": true,
"authTokens": ["your-auth-token"],
"cors": {
"origin": true
}
},
"mcpServers": {
"time": {
"command": "uvx",
"args": ["mcp-server-time", "--local-timezone=Europe/Moscow"],
"proxyOptions": {
"authTokens": ["server-specific-token"]
}
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/app/files"]
},
"echo": {
"type": "streamableHttp",
"url": "http://localhost:8080/mcp"
}
}
}配置参数
proxyServer.options:
- logLevel:日志记录级别(调试、信息、警告、错误) - logPretty:日志格式 - authTokens:身份验证令牌数组(用作所有服务器的默认值) - cors:CORS 配置 选项(可选)
mcpServers:MCP服务器配置
- [serverName]: - command:启动服务器的命令(适用于stdio服务器) - args:命令参数(用于stdio服务器) - url:服务器的URL(适用于SSE和StreamableHTTP服务器) - type:服务器类型(stdio和SSE可选,StreamableHTTP必需) - proxyOptions:特定服务器的代理选项 - authTokens:身份验证令牌数组(覆盖 proxyServer.options.authTokens 对于特定服务器)
根据上述配置,访问MCP服务器的URL如下:
http://localhost:3000/time/sse
http://localhost:3000/filesystem/sse
http://localhost:3000/echo/sselocalhost:3000-代理服务器地址和端口(默认)/time/sse,/filesystem/sse,以及/echo/sse-与中的密钥匹配的相应MCP服务器的路径mcpServers配置
路线图
- \[x\] CORS支持
- \[x\] 流式HTTP支持
许可证
麻省理工学院
