AgentSQL MCP server
Commit Nov 9, 2026Acts as a security gateway for AI agents to access PostgreSQL and MySQL databases through SQL auditing, authentication, and data masking.
Also known as cuipengdba/agentsql
- Stars
- 20
- Tools
- —
- Downloads, 30 days
- —
- Latest version
- 0.4.0
- Last commit
- Nov 9, 2026
- License
- Apache-2.0
What is AgentSQL MCP?
AgentSQL acts as a security gateway for AI agents to access PostgreSQL and MySQL databases through SQL auditing, authentication, and data masking.
Summary generated from the project's README
About AgentSQL MCP server
AgentSQL serves as a security gateway designed to protect PostgreSQL and MySQL databases when accessed by AI agents. It functions as an MCP server that provides a controlled layer for SQL auditing, authentication, and data masking. Developers can deploy it as a standalone security gateway for external AI clients or use its built-in web interface for natural language data querying.
Users can integrate the server using stdio, Streamable HTTP, or stateless HTTP protocols. To connect external agents, you must configure an Agent API Key, which ensures that every request is executed within specific authorization boundaries. The system maintains strict security by re-verifying permissions during historical data retrieval and file exports like CSV or XLSX. This setup allows teams to combine internal natural language querying with external agent access while sharing a unified security audit trail.
Written from the project's README. Every use case is checked against a quote from it.
How to install AgentSQL MCP
Formats verified 10 Nov 2026Install AgentSQL MCP in Claude Code
$ claude mcp add --transport http agentsql https://demo.agentsql.cn/mcpInstall AgentSQL MCP in Cursor
~/.cursor/mcp.json
{
"mcpServers": {
"agentsql": {
"url": "https://demo.agentsql.cn/mcp"
}
}
}Install AgentSQL MCP in VS Code
.vscode/mcp.json
{
"servers": {
"agentsql": {
"type": "http",
"url": "https://demo.agentsql.cn/mcp"
}
}
}Install AgentSQL MCP in Codex
~/.codex/config.toml
[mcp_servers.agentsql] url = "https://demo.agentsql.cn/mcp"
Install AgentSQL MCP in Gemini CLI
~/.gemini/settings.json
{
"mcpServers": {
"agentsql": {
"httpUrl": "https://demo.agentsql.cn/mcp"
}
}
}Automated checks
Ran Nov 13, 2026Full report →Not verified yet. A server needs a score of 80, no serious finding, and enough data for us to check. How checks work
- Source repository linked and reachablecuipengdba/agentsql is public and reachablegithub.com/cuipengdba/agentsql ↗Pass
- Package names this repository as its sourceNot checked
- Build provenance (Sigstore attestation)Not checked
- Open source license (OSI)Apache-2.0spdx.org/licenses/Apache-2.0.html ↗Pass
- Commit or release in the last yearLast commit or release 2026-11-09github.com/cuipengdba/agentsql ↗Pass
- OpenSSF ScorecardNot checked
- Package name not close to a popular packageNot checked
- No critical advisory in the package or its dependenciesNot checked
- No hidden instructions to the model0 tool descriptions and the README read; no override phrases, credential paths or hidden charactersPass
- Destructive tools are labelledNot checked
- Remote endpoint answers the MCP handshakeHTTPS endpoint answered 401 (sign-in required)Pass
README
View on GitHubAgentSQL(智盾)
AgentSQL = 独立 AI 问数 Agent + MCP Server 数据库安全网关。 用户可直接在 AgentSQL 自有页面用自然语言问数;其他 AI Agent 可把 AgentSQL 当作独立 MCP Server 使用。两条入口共用当前身份与授权、受控 SQL 执行、结果脱敏和持久审计。AgentSQL 自有问数不依赖 SQLBot;SQLBot 是可经固定版本适配器接入的可选客户端。
官网 · 中文问数界面与功能示意 · v4.12.0 下载与发布边界 · 三种使用方式 · 文档索引
选一种使用方式
| 方式 | 你来做什么 | 从哪里开始 |
|---|---|---|
| 独立问数 | 登录 AgentSQL 自有页面,选择已绑定数据源,提问并核对生成的 SQL、结果和审计 | 问数操作与配置 |
| 独立 MCP 安全网关 | 给外部 AI Agent 配置 Agent API Key,让 MCP 工具在授权范围内查询 | MCP Server 操作 |
| 两者一起 | 员工用 AgentSQL 页面问数,外部 Agent 通过 MCP 查询;分别授权,共用安全审计 | 联合使用 |
AgentSQL 自有页面 → Go 问数 Agent ─────┐
├→ AgentSQL 安全网关 → 当前受权数据库
外部 AI Agent → AgentSQL MCP Server ─┘
v4.12.0 能力与边界
| 能力 | 当前状态 | 关键边界 |
|---|---|---|
| 自有 AI 问数 | 限定路径已验 | 自有 Go/Web 问数;本地模型、运营方登记的 PostgreSQL 网关别名和当前权限,无需 SQLBot 运行 |
| 受权向量预热与问数 | 按当前授权准备结构 | 固定 ONNX 表向量支持后台预热与热索引复用;权限变化后重新核对,模型和数据库的实际环境与耗时见本版发布说明 |
| 历史与文件导出 | 当前授权逐次复核 | 历史重开与 CSV/XLSX 下载都重新校验授权并留审计;权限变化、会话删除或服务故障时拒绝旧内容,页面忽略迟到响应 |
| 私有数据源绑定轮换 | 限定路径已验 | 运维侧先建立新网关绑定并预检受权结构,再以旧绑定 ID 和存储修订比较提交;浏览器不能更换目标或凭据 |
| MCP Server 安全网关 | 可独立使用 | stdio、Streamable HTTP 和独立无状态 HTTP;Agent Key 不等于管理员令牌,每次请求按当前授权执行 |
| 基本助手与 Type 4 页面嵌入 | 限定路径已验 | 单数据源基本游客助手与指定页面嵌入,来源、身份及撤权仍受控 |
| SQLBot 接入 | 可选固定基线 | 已验适配器可把指定 SQLBot 执行路径交给 AgentSQL MCP;不承诺任意部署零改动接入 |
| Type 1 高级助手 | 沿用历史限定范围 | 运营方登记第三方目录并映射到当前受权网关别名;本版未扩大该入口的支持声明 |
| 活动数据权限 | 限定形态已验 | 明确列出的同工作空间用户;内建管理员/普通成员角色限定;非空白名单只作元数据,不豁免行列限制 |
| 更广兼容 | 部分只读载入;其余未验证 | 原版社区管理页列表可加载不等于创建、编辑、导入导出已验;云模型真实推理、任意角色扩展及原版权限库直接迁移仍未验证 |
自然语言结果需要核对生成的 SQL 和业务含义。v4.12.0 未在用户真实业务系统验证,不宣称 100% 兼容或零改动切换;正式发布说明给出精确提交、验收场景、性能数字与限制。固定 25 场景评分合同严格通过 6/25(24%),本版逐项验收列明证据与未测项,未完成合同的场景计零;这不等于 AgentSQL 独立 MCP 安全网关的能力覆盖率。公网 Demo 的问数模型仅作模拟展示。
快速开始
Linux amd64 / arm64 原生包要求 glibc ≥ 2.28 和 PID 1 的 systemd。下载正式包后先按发布说明核对签名和哈希。以下命令安装网关;自有问数需要按三种使用方式安装问数组件并配置本地文本模型与个人数据源绑定。
curl -fsSL https://github.com/cuipengdba/agentsql/releases/download/v4.12.0/install.sh | sudo sh -s -- install --version v4.12.0
Docker 使用多架构正式镜像;一键脚本仅绑定本机回环地址并创建持久卷:
curl -fsSL https://raw.githubusercontent.com/cuipengdba/agentsql/v4.12.0/scripts/quickstart.sh -o quickstart.sh && sh quickstart.sh --version v4.12.0
网关控制台默认 http://127.0.0.1:7780,安装了问数组件后自有页面默认 http://127.0.0.1:8000。安装器生成持久管理员密码;非交互日志不输出,可由 root 在 /etc/agentsql/agentsql.env 查看。远程访问应使用 SSH 本地转发或受控 HTTPS 反向代理,不直接暴露管理端口。离线安装、密钥、备份和升级步骤见部署指南。
按任务查文档
| 任务 | 文档 |
|---|---|
| 三种产品形态与验收步骤 | 三种使用方式 |
| 自有问数模型与个人绑定 | 原生问数配置 |
| MCP 客户端、协议与工具 | MCP 接入指南 |
| 控制台权限、规则、脱敏与审计 | 使用手册 · 安全边界 |
| SQLBot 固定版本适配 | SQLBot 接入 · Type 1 高级助手部署 |
| 数据库适配分级与证据 | 官网兼容矩阵 · 数据库研究与验收 |
| 离线安装、升级、备份与恢复 | 部署指南 · 运维手册 |
数据库“已注册”“连接级”“指定版本受控只读”“指定场景完整防护”是不同等级。官网矩阵保留逐库版本、拓扑与验收边界;连接成功不等于可安全问数,也不等于厂商认证。
社区与项目
历史 Release · CHANGELOG · 路线图 · Issues · Discussions · 贡献指南
当前源码按 Apache-2.0 发布,并附 NOTICE;AgentSQL 名称和标识的商标权不由该许可证授予。未修复漏洞请按 SECURITY.md 私下报告,不在公开 Issue 中提交真实凭据或连接串。
AgentSQL MCP questions
How do I add AgentSQL MCP to Claude Code?
Run claude mcp add --transport http agentsql https://demo.agentsql.cn/mcp in your terminal. Add --scope user to make it available in every project.
How do I add AgentSQL MCP to Cursor?
Open ~/.cursor/mcp.json and add the server under mcpServers, using the Cursor config shown in the install section above.