Go MCP Server 项目初始化:工具注册架构 + 编译运行通过

- Tool 接口 + Registry 注册中心,工具模块化插拔
- system 工具:health / info
- database 工具:db_query / db_tables / db_table_info / db_explain(四层 SQL 安全)
- docker 工具:docker_ps / docker_logs / docker_inspect(白名单 + 大小限制)
- middleware:auth(JWT+APIKey)/ ratelimit(令牌桶)/ audit(slog 结构化)
- stdio / SSE 双传输模式,Viper 多环境配置
- Dockerfile 多阶段构建(golang:alpine → scratch),~15MB 镜像
- docker-compose.yml 一键部署 + 安全加固(read_only / no-new-privileges / cap_drop)
- go build ./... / go vet ./... / go test ./... 全部通过

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
yangzhaohan
2026-07-06 10:26:52 +08:00
parent 68ca67a98b
commit fb2c3a6cae
26 changed files with 1854 additions and 1 deletions
+24
View File
@@ -0,0 +1,24 @@
env: prod
server:
transport: sse
addr: ":8080"
databases:
main_db:
driver: postgres
dsn: postgres://ops_readonly:${DB_PASSWORD}@db-prod.internal:5432/ops?sslmode=require
docker:
enabled: true
host: unix:///var/run/docker.sock
container_pattern: "^(app-|web-|api-|worker-).*"
auth:
enabled: true
jwt_secret: ${JWT_SECRET}
rate_limit:
enabled: true
rate: 10
burst: 20