SQL MCP Server

io.github.nethinweiPublished by GitHub account nethinweiv0.1.21Updated Oct 28, 2026

Controlled SQL access gateway with policy, cost limits, tenant isolation, and safe tools.

VerifiedSTDIODesktop onlyDatabasesSecurity & Monitoring

Overview

AI-generated overview

Governed SQL gateway MCP server that lets an assistant query PostgreSQL, MySQL and OceanBase through controlled tools, policies and cost limits instead of…

What you can do
  • Query PostgreSQL, MySQL and OceanBase through explicit entities and whitelisted relational-algebra operations rather than free-form SQL
  • Enforce field and row governance, including RBAC, column ACLs, row policies and masking, on every access
  • Apply cost controls such as EXPLAIN pre-screening, result caps, timeouts and session or tenant budgets
  • Isolate tenants and fail closed when a safety property cannot be proven
  • Optionally expose a separate execute_sql escape hatch, off by default and only for explicitly granted users
  • Run with audit logging, config hot reload and OpenTelemetry hooks
When to use it
Use it when an assistant needs database access but the operator wants deterministic, policy-bound queries instead of raw SQL, for example multi-tenant or regulated data where field masking, row policies and cost limits matter.
Requirements
Runs locally over stdio, typically via the published Docker image or a Go 1.26.10+ source build. Needs a supported database (PostgreSQL, MySQL or OceanBase) and a database DSN supplied through the DATABASE_DSN environment variable, plus a YAML configuration file. Docker Compose is suggested for the quickstart.
Before you install
The DATABASE_DSN secret grants database access, so scope it to a least-privilege account. The optional execute_sql tool allows real SQL and, per the README, writes are rejected on failure but the tool is a trusted-operator escape hatch; keep it disabled unless needed. Tenant isolation, masking and denial behavior depend on correct configuration, and the README states its summary page is not authoritative for security behavior.

Installation

In SourceWeft

  1. Open SQL MCP Server in the dashboard and add it to a workspace.
  2. Enable the server for the chats that should use its tools.

Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.

Other MCP clients

Follow the launch instructions in the repository.

README

SQL MCP Server

The governed SQL gateway for untrusted AI agents.

面向不可信 AI Agent 的受控 SQL 数据访问网关。通过显式 Entity、关系代数 IR 和 参数化 codegen 访问 PostgreSQL、MySQL 与 OceanBase,受治理面不接受任意 SQL,不提供 DDL。可信操作者另有独立的 SQL 逃生通道 execute_sql:默认关闭,只对被显式授予 sql:execute@<数据源> 的用户可见,走单独声明的连接,受硬上限与写入失败即拒绝的 审计约束(见安全模型)。

核心差异

  • 确定性执行:Agent 只能组合受控工具和白名单 IR;
  • 字段与行治理:RBAC、字段 ACL、row policy 和 mask 统一强制;
  • 成本可控:EXPLAIN 预筛、结果上限、超时和 session/tenant 预算;
  • 默认拒绝:安全能力无法证明时 fail closed;
  • 可审计:配置热重载、异步审计和 OpenTelemetry hook。

运行时安全行为以安全模型为准;Provider 验证边界与证据层级 以兼容矩阵为准;威胁、控制与剩余风险见 威胁模型。所有对外声明的证据汇总见 架构、安全边界与证据索引。不以本页摘要为准。

五分钟体验

只需 Docker 与 Docker Compose:

sh
docker compose -f examples/quickstart/compose.yaml up -d --waitcurl -fsS http://127.0.0.1:8080/healthz

完整的 MCP Inspector 调用、tenant 隔离、mask 和拒绝场景见 五分钟快速体验。

安装与接入

源码构建要求 Go 1.26.10+ 和一个已验证数据库版本:

sh
git clone https://github.com/nethinwei/sql-mcp-server.gitcd sql-mcp-servermake build

按角色阅读

首次体验与集成

部署与安全

开发与维护

版本与规划

许可

MIT

Source: README.md at commit 9a82b38

Tools

0
SourceWeft started this package once in an isolated sandbox, without credentials, to list its tools. That failed: the package type cannot run in the sandbox.

Version history

11
  1. v0.1.21LatestOct 21, 2026
  2. v0.1.20Oct 19, 2026
  3. v0.1.19Oct 17, 2026
  4. v0.1.17Oct 16, 2026
  5. v0.1.16Oct 16, 2026
  6. v0.1.15Oct 15, 2026
  7. v0.1.14Oct 11, 2026
  8. v0.1.13Oct 11, 2026
  9. v0.1.12Oct 9, 2026
  10. v0.1.11Oct 8, 2026
  11. v0.1.10Sep 16, 2026

Score

50% of the applicable checks met

How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.

  • Reached in the last 30 days25 pts

    Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.

  • Auth declared10 pts

    Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.

  • Tools listed15 pts

    Answer tools/list without a credential, or ship a package that starts in a sandbox without one.

  • DescriptionRequired15 pts
  • Logo10 pts
  • Documentation15 pts
  • License10 pts