
Sqlsure
io.github.sqlsurePublished by GitHub account sqlsurev0.1.1Updated Oct 24, 2026
Semantic SQL inspector: catches double-counting, wrong joins, PII exposure before execution.
Overview
A local MCP server that checks AI-written SQL against declared semantic rules before execution, flagging double-counting, bad joins and PII exposure.
- What you can do
- Inspect SQL text against a semantic model built from dbt tests, PK/FK declarations, database introspection or hand-written JSON, returning violations with machine-actionable fixes so an agent can draft, check, fix and re-check before running a query. Detect fan-out and chasm joins, non-additive or semi-additive measures, undeclared or missing join keys, cross joins, re-weighted averages and sensitive PHI/PII columns. Report honest uncertainty, saying a query cannot be verified rather than approving it. Audit a whole dbt repository and produce a report.
- When to use it
- Use it when an assistant generates SQL for analytics and you want a deterministic pre-execution check for silently wrong numbers or exposed sensitive columns, especially in teams that already declare grain and relationships in dbt or PK/FK metadata.
- Requirements
- Runs locally over stdio as a Python package installed with pip; needs Python and a semantic model file passed at startup, built from dbt manifest or schema files, PK/FK declarations, database catalog introspection or hand-written JSON. No accounts, API keys or network access.
Installation
In SourceWeft
- Open Sqlsure in the dashboard and add it to a workspace.
- 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
sqlsure
[CI] [PyPI] [License: Apache-2.0] [Python]
AI writes your SQL. sqlsure makes sure it's right.
A query can be perfectly valid, run without error, and return a number that's silently wrong — revenue double-counted by a join, an average summed, a patient identifier exposed. Databases don't catch this. Linters don't catch this. LLMs reviewing their own SQL don't catch this.
sqlsure does — deterministically, in 0.1 ms, before the query runs.
Proof, not promises: we ran sqlsure over the gold answers of the two benchmarks every text-to-SQL model is graded on. 2,568 expert-written queries, 45 flags, zero false alarms — including a BIRD dev gold answer that is provably wrong by 8× from the exact bug class sqlsure targets, and a schema defect now filed upstream.
How it works
sqlsure judges SQL against facts your team already declared — dbt unique
tests become grain, relationships tests become join cardinality, one-line
meta tags mark what's safe to sum. No new language to learn, no model to
maintain by hand. Rules are dictionary lookups, not LLM calls: same input,
same verdict, every time, offline.
Every rejection carries a machine-actionable fix, so AI agents
self-repair: draft → check → fix → check → execute. In our benchmark,
applying the fix verbatim produced a passing query 10/10 times.
Quick start
Or clone and run the 30-second demo:
Three doors, one engine
1. CI gate — blocks the merge when a PR double-counts:
2. MCP server — your AI agent must pass inspection before executing:
See docs/MCP.md for tool reference and agent-loop patterns.
3. Library — embed check() inside any text-to-SQL product or agent
framework. A drop-in SemanticGate wraps
Vanna/WrenAI-style generators; a
semantic eval metric scores NL2SQL output
where execution-accuracy is blind.
Also available as an Agent Skill — a single SKILL.md your agent loads directly; no server process needed.
The rules (v0.1)
When sqlsure can't verify something, it says "can't verify" — never "looks fine." Honest uncertainty is a feature.
Trust properties
- Deterministic — same SQL + same rulebook = same verdict, always; rules are dictionary lookups, auditable line by line
- Offline — zero network calls; your SQL never leaves your machine
- No data access — parses query text; never connects to a database
- No telemetry — nothing collected, ever (SECURITY.md)
- Supply chain — releases ship exclusively via PyPI Trusted Publishing (OIDC) from tagged commits with public CI runs; two runtime deps
Where the rulebook comes from
-
dbt (works today):
manifest.jsonorschema.yml— the tests teams already wrote become enforceable semantics, zero config -
Plain PK/FK declarations (works today — powered the benchmark audits)
-
The live database itself (works today): no semantic layer at all?
sqlsure.introspectbuilds the rulebook from the catalog — SQLite PRAGMAs orinformation_schemaPK/FK (postgres/mysql). Introspecting BIRD's own database files recovered 2 foreign keys missing from the benchmark's published schema (bird-bench/mini_dev#37) -
Hand-written JSON — model.example.json
-
OSI and WrenAI MDL (working loaders in integrations/): OSI demonstrated on the spec's published examples; WrenAI MDL demonstrated on WrenAI's own shipped example manifest —
primaryKey→ grain, relationshipjoinType+condition→ join edges, cube measures → additivity -
Cube, Snowflake Semantic Views — adapters on the roadmap; the engine only ever sees one
SemanticModel
Validated on
- 16/16 rule tests, 100% recall / 0% false positives on the paired benchmark (docs/METRICS.md)
- Real production repos (Mattermost's warehouse, Fivetran packages, dbt's jaffle shop) — docs/TEST-REPORTS.md
- Spider + BIRD gold queries — the zero-noise external audit above
Learn more
- docs/EVIDENCE.md — what it does for you, every claim linked to a rerunnable measurement
- docs/ARCHITECTURE.md — how it physically works, ELI5 → god level, with real intermediate outputs
- docs/FOR-DUMMIES.md — every concept from zero
- docs/INTEGRATIONS.md — GitHub Action, pre-commit, MCP, Snowflake UDF / Cortex Agent tool, query-history audit
- docs/MCP.md — MCP server documentation
- CONTRIBUTING.md — adding rules and loaders
Apache-2.0 · sqlsure.ai
mcp-name: io.github.sqlsure/sqlsure
Source: README.md at commit d1b98e7
Tools
0Version history
1- v0.1.1LatestSep 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