网关操作
企业MCP网关-身份验证、速率限制、跟踪和成本跟踪
GatewayOps是位于AI代理和MCP(模型上下文协议)服务器之间的代理层,提供企业级的可观察性、安全性和成本管理。
特性
- 认证:具有bcrypt、per-key权限的API密钥验证
- 速率限制:Redis滑动窗口算法,按键限制
- 分布式跟踪:跟踪ID传播、跨度跟踪
- 成本跟踪:每次通话定价、使用归因
- 请求日志记录:结构化JSON日志、数据屏蔽
- MCP代理:转发工具、资源和提示
快速开始
先决条件
- Docker和Docker Compose
- 转到1.21+(可选,用于本地开发)
开发设置
# Clone the repository
git clone https://github.com/akz4ol/gatewayops.git
cd gatewayops
# Run the setup script
./scripts/dev-setup.sh
# Or manually:
cp .env.example .env
docker-compose -f deployments/docker-compose.yml up -d
# Run the gateway
make run生成API密钥
go run scripts/generate-key.go dev测试网关
# Health check
curl http://localhost:8080/health
# List MCP tools (requires API key)
curl -X POST http://localhost:8080/v1/mcp/mock/tools/list \
-H "Authorization: Bearer gwo_dev_YOUR_API_KEY" \
-H "Content-Type: application/json"
# Call an MCP tool
curl -X POST http://localhost:8080/v1/mcp/mock/tools/call \
-H "Authorization: Bearer gwo_dev_YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"tool": "read_file", "arguments": {"path": "/test.txt"}}'API终点
健康
GET /health-活体检查GET /ready-准备就绪检查
MCP代理
POST /v1/mcp/{server}/tools/call-调用MCP工具POST /v1/mcp/{server}/tools/list-列出可用工具POST /v1/mcp/{server}/resources/read-阅读资源POST /v1/mcp/{server}/resources/list-列出资源POST /v1/mcp/{server}/prompts/get-获得提示POST /v1/mcp/{server}/prompts/list-列表提示
项目结构
gatewayops/
├── gateway/
│ ├── cmd/gateway/main.go # Entry point
│ └── internal/
│ ├── config/ # Configuration loading
│ ├── server/ # HTTP server
│ ├── router/ # Route definitions
│ ├── middleware/ # Auth, rate limit, logging, trace
│ ├── handler/ # Request handlers
│ ├── auth/ # API key authentication
│ ├── ratelimit/ # Redis rate limiting
│ └── database/ # Database connections
├── migrations/
│ ├── postgres/ # PostgreSQL schemas
│ └── clickhouse/ # ClickHouse schemas
├── deployments/
│ ├── docker-compose.yml # Local development
│ └── docker/ # Dockerfiles
├── scripts/ # Development scripts
└── test/
└── mock-mcp/ # Mock MCP server技术栈
- 语言:转到1.21+
- 路由器:chi
- 数据库:PostgreSQL、ClickHouse、Redis
- 容器化:Docker
配置
环境变量(参见 .env.example):
| 变量 | 默认值 | 描述 |
|---|---|---|
PORT | 8080 | HTTP服务器端口 |
ENV | development | 环境(开发/生产) |
DATABASE_URL | - | PostgreSQL连接字符串 |
REDIS_URL | - | Redis连接字符串 |
CLICKHOUSE_DSN | - | ClickHouse连接字符串 |
RATE_LIMIT_DEFAULT_RPM | 1000 | 默认每分钟请求数 |
相关存储库
| 存储库 | 目的 |
|---|---|
| gatewayops产品 | 产品操作-PRD、架构、API规范 |
| ai saas公司 | 公司架构 |
许可证
专有-保留所有权利
______________________________________________________________________
部分 AI SaaS公司 组织架构。
