CentralMind Gateway: Create API or MCP Server in Minutes

CentralMind Gateway: Create API or MCP Server in Minutes

site icon
2025.04.12 249
GoAPI 生成数据库连接AI 代理支持开发效率数据库
CentralMind Gateway 是一个快速创建 API 或 MCP 服务器的工具,能够通过简单的配置将数据库暴露给 AI 代理或通过 OpenAPI 3.1 协议访问。它支持多种数据库,自动生成优化的 API 结构,并提供丰富的安全性和性能优化功能。
View on GitHub

Overview

基本能力

产品定位

CentralMind Gateway 是一个用于快速创建 API 或 MCP 服务器的工具,旨在为 AI 代理和 LLM 驱动的应用程序提供快速、安全的数据访问。

核心功能

  • 自动 API 生成 – 基于表结构和采样数据自动生成 API
  • 🗄️ 结构化数据库支持 – 支持 PostgreSQL、MySQL、ClickHouse、Snowflake、MSSQL、BigQuery、Oracle Database、SQLite、ElasticSearch
  • 🌍 多协议支持 – 提供 REST 或 MCP 服务器(包括 SSE 模式)
  • 📜 API 文档 – 自动生成 Swagger 文档和 OpenAPI 3.1.0 规范
  • 🔒 PII 保护 – 通过正则插件或 Microsoft Presidio 插件实现敏感数据脱敏
  • 灵活配置 – 通过 YAML 配置和插件系统轻松扩展
  • 🐳 多种部署选项 – 支持二进制、Docker 容器和 Helm 图表
  • 🤖 多 AI 提供商支持 – 支持 OpenAI、Anthropic、Amazon Bedrock、Google Gemini、Google VertexAI
  • 📦 本地和内部部署 – 支持自托管 LLM
  • 🔑 行级安全 (RLS) – 使用 Lua 脚本实现细粒度数据访问控制
  • 🔐 认证选项 – 支持 API 密钥和 OAuth
  • 👀 全面监控 – 集成 OpenTelemetry (OTel) 进行请求跟踪和审计
  • 🏎️ 性能优化 – 实现基于时间和 LRU 缓存的策略

适用场景

  • 公司部署 AI 代理进行客户支持、分析等场景
  • 需要模型访问数据但不想直接暴露 SQL 访问的场景
  • 需要快速生成和部署 API 的场景

使用教程

使用依赖

  • 安装 Docker(如需使用 Docker 运行)
  • 安装 Go(如需从源码构建)

安装教程

  1. 使用 Docker 运行:
docker run --platform linux/amd64 -p 9090:9090 \
  ghcr.io/centralmind/gateway:v0.2.6 start \
  --connection-string "postgres://db-user:db-password@db-host/db-name?sslmode=require"
  1. 从源码构建:
git clone https://github.com/centralmind/gateway.git
cd gateway
go mod download
go build .

调试方式

  1. 运行 API:
./gateway start --config gateway.yaml rest
  1. 检查日志输出:
INFO Gateway server started successfully!         
INFO MCP SSE server for AI agents is running at: http://localhost:9090/sse 
INFO REST API with Swagger UI is available at: http://localhost:9090/ 
  1. 访问 Swagger UI: 打开浏览器访问 http://localhost:9090/

工具列表

  • gateway:主程序,用于启动和管理 API 服务器
  • Docker 镜像:预构建的容器镜像,简化部署
  • Helm 图表:用于 Kubernetes 部署

常见问题解答

  • 如何生成 API 配置? 使用 discover 命令并指定 AI 提供商和数据库连接字符串
  • 如何保护敏感数据? 使用内置的 PII 保护插件
  • 如何监控 API 使用情况? 集成 OpenTelemetry 进行请求跟踪和审计

许可证

该项目遵循 Apache-2.0 开源许可条款,请参阅 Apache-2.0 了解完整条款。