nethinwei-sql-gatewayBLOCK
Governed SQL gateway for untrusted AI agents. No arbitrary SQL. Policy-enforced, cost-bounded access to relational data.
Overview
From the repository's own README, as read at the audited commit. Badges and raw HTML are left out.
The governed SQL gateway for untrusted AI agents.
面向不可信 AI Agent 的受控 SQL 数据访问网关。通过显式 Entity、关系代数 IR 和 参数化 codegen 访问 PostgreSQL、MySQL 与 OceanBase,不接受任意 SQL,不提供 DDL。
核心差异
- 确定性执行:Agent 只能组合受控工具和白名单 IR;
- 字段与行治理:RBAC、字段 ACL、row policy 和 mask 统一强制;
- 成本可控:EXPLAIN 预筛、结果上限、超时和 session/tenant 预算;
- 默认拒绝:安全能力无法证明时 fail closed;
- 可审计:配置热重载、异步审计和 OpenTelemetry hook。
运行时安全行为以安全模型为准;Provider 验证边界与证据层级 以兼容矩阵为准;威胁、控制与剩余风险见 威胁模型。所有对外声明的证据汇总见 架构、安全边界与证据索引。不以本页摘要为准。
五分钟体验
只需 Docker 与 Docker Compose:
docker compose -f examples/quickstart/compose.yaml up -d --wait curl -fsS http://127.0.0.1:8080/healthz
完整的 MCP Inspector 调用、tenant 隔离、mask 和拒绝场景见 五分钟快速体验。
安装与接入
源码构建要求 Go 1.26.9+ 和一个已验证数据库版本:
git clone https://github.com/nethinwei/sql-mcp-server.git cd sql-mcp-server make build
- Cursor、Claude Desktop 和 VS Code 的 stdio 模板:
examples/clients/(核对结论见 客户端接入核对);
- 完整配置模板:
examples/config.example.yaml; - CLI、启动、热重载、容器部署和升级:运行与运维;
- Web 管理控制台与 Docker Compose 部署:管理控制台;
- 魔搭分发展示:ModelScope 上架与使用。
按角色阅读
首次体验与集成
- 五分钟快速体验:唯一完整 Demo 与 Inspector 示例;
- 配置参考:公开 YAML 配置的唯一事实源;
- Provider 兼容性与
支持版本:当前能力和验证边界。
部署与安全
- 运行与运维:CLI、容器部署、生命周期、监控和升级;
- 管理控制台:配置编辑、发布回滚、管理员权限与 Docker 部署;
- 安全模型:运行时安全行为的唯一事实源;
- 威胁模型:威胁、控制、测试证据与剩余风险;
- SECURITY.md:漏洞披露流程。
开发与维护
- 架构、不变量与术语表;
- 测试与 CI:测试命令、CI、fuzz 和发布前门禁;
- [贡献指南](CONTRIBU
53bec1adf14fOBSERVED · 2026-10-11Connect
Built from this server's own package name, version and transport as found in its source — not copied from anyone's documentation, so it cannot drift against a page we do not control. Replace the environment placeholders with a token scoped to the least it needs.
claude mcp add sql-mcp-server:0.1.13 --env DATABASE_DSN=${DATABASE_DSN} -- docker run -i --rm ghcr.io/nethinwei/sql-mcp-server:0.1.13:None serve /config/config.yaml stdioTrust audit
BLOCKgrade F · trust 57/100 Do not install this without reading the findings. The audit found something that could harm you or your machine.
| Layer | What it checks | Result |
|---|---|---|
| L0 | Provenance & inventory | PASS |
| L1 | Static analysis of the code | FAIL |
| L2 | Instruction surface (what it tells the agent) | PASS |
| L3 | Class-specific surface | PASS |
| L4 | Behavioural (sandbox) | SKIPPED |
What the source does
- Filesystem
- declared (1 observation(s))
- Network
- declared (3 observation(s))
- Shell
- declared (6 observation(s))
- Dependencies
- not all pinned
- Secrets in source
- found
Findings (25)
watch(id, (rev) => (rev ? void yaml.load(rev) : yaml.reset()), { immediate: true })in, err := eval(db, n.Input)
func Eval(db DB, e relalg.Expr) (Result, error) {r, err := eval(db, e)
func eval(db DB, e relalg.Expr) (relation, error) {in, err := eval(db, n.Input)
"DATABASE_DSN": "postgres://reader:[email protected]:5432/app?sslmode=require"
const url = URL.createObjectURL(new Blob(['' + text], { type: `${type};charset=utf-8` }))"DATABASE_DSN": "postgres://reader:[email protected]:5432/app?sslmode=require"
"DATABASE_DSN": "postgres://reader:[email protected]:5432/app?sslmode=require"
{"postgres", "postgres://app:hunter2@db/app"},token: "quickstart-only-token"
token: "protocol-smoke-token"
.golangci.yml
.goreleaser.yaml
dir := "../../fixtures/v4/tasks-v5"
file, err := loadWorkloadTasks("../../fixtures/v4/tasks/tasks.yaml","../../fixtures/v4/tasks-v5/guided-metadata.yaml",
"../../fixtures/v4/tasks-v5/additions.yaml",
"../../fixtures/v4/coverage/dimensions.yaml",
sql-mcp-server serve --store sqlite:/path/config.db --admin --watch # 控制台 http://127.0.0.1:18090/admin/(默认地址以配置为准)
`web/admin` 下 `pnpm dev` 会把 API 代理到 `SMCP_ADMIN_API`(默认 `http://127.0.0.1:18090`)。
curl -fsS http://127.0.0.1:8080/healthz
打开 `http://127.0.0.1:8080/admin/`,用刚创建的账号登录。
- 控制台:<http://127.0.0.1:8080/admin/>,用 `admin` 登录;
Gates applied: no_behavioural_pass.
53bec1adf14ffull audit observations/trust-audit/mcp-server/nethinwei__sql-mcp-server.json · Report an issue / request a re-scanAudit history
Every audit this server has had. A grade with a past is a grade somebody is still checking.
| Date | Source | Verdict | Grade | Score | Change |
|---|---|---|---|---|---|
| 2026-10-11 | 53bec1adf14f | BLOCK | F | 57 | first audit |
Questions
What is the nethinwei-sql-gateway MCP server?
Governed SQL gateway for untrusted AI agents. No arbitrary SQL. Policy-enforced, cost-bounded access to relational data.
Is nethinwei-sql-gateway safe to connect to an agent?
No — not without reading the findings first. The audit graded it F (57/100) and found 7 critical or high issues in the source. Each one is listed on this page with the file and line it is on.
What credentials does nethinwei-sql-gateway need?
It reads DATABASE_DSN from the environment. Give it a token scoped to the least it needs — an agent that can be talked into calling a tool can be talked into calling it with your credentials.
How does nethinwei-sql-gateway run?
It speaks stdio and streamable-http, so it runs as a local process your client starts. It is published on npm as sql-mcp-server-admin at 0.0.0.
How current is this page?
The grade is for one exact copy of the source (53bec1adf14f), read on 2026-10-11. The repository is watched and re-audited when it changes.