PluginBench
MCP Server
Maintained
Apache-2.0

io.github.sqlsure/sqlsure MCP Server

io.github.sqlsure/sqlsure

Semantic SQL inspector that catches double-counting, wrong joins, and PII exposure before query execution.

What is the io.github.sqlsure/sqlsure MCP server?

The sqlsure MCP server is a semantic SQL inspector that validates queries against declared data semantics (from dbt, databases, or JSON) to catch silent errors like double-counted revenue, incorrect joins, and PII exposure before execution. It runs deterministically in ~0.1ms offline, with zero false positives on 2,568 expert-written queries, and provides machine-actionable fixes for AI agents to self-repair.

sqlsure validates SQL queries against semantic rules derived from your data layer (dbt tests, database schemas, or custom declarations) to catch logical errors that databases and linters miss. It detects fanout joins that double-count measures, chasm joins, non-additive aggregations, undeclared relationships, and sensitive column exposure—all without accessing data or making network calls. Perfect for AI-assisted SQL generation, CI gates, and ensuring query correctness before execution.

How to install io.github.sqlsure/sqlsure

Copy-paste configuration for popular MCP clients.

transport: stdio
Config generated by PluginBench — verify against the source before use.
Claude Desktop
~/Library/Application Support/Claude/claude_desktop_config.json
{
  "mcpServers": {
    "sqlsure": {
      "command": "python",
      "args": [
        "sqlsure",
        "-m",
        "sqlsure.mcp_server",
        "--model"
      ]
    }
  }
}
Cursor
~/.cursor/mcp.json
{
  "mcpServers": {
    "sqlsure": {
      "command": "python",
      "args": [
        "sqlsure",
        "-m",
        "sqlsure.mcp_server",
        "--model"
      ]
    }
  }
}
Windsurf
~/.codeium/windsurf/mcp_config.json
{
  "mcpServers": {
    "sqlsure": {
      "command": "python",
      "args": [
        "sqlsure",
        "-m",
        "sqlsure.mcp_server",
        "--model"
      ]
    }
  }
}
VS Code
.vscode/mcp.json
{
  "servers": {
    "sqlsure": {
      "type": "stdio",
      "command": "python",
      "args": [
        "sqlsure",
        "-m",
        "sqlsure.mcp_server",
        "--model"
      ]
    }
  }
}
Claude Code
claude mcp add sqlsure -- python sqlsure -m sqlsure.mcp_server --model

Tools & capabilities

Tools this server exposes to the agent.

  • checkValidates SQL against a semantic model and returns violations with machine-actionable fixes
  • scanAudits a dbt repository for semantic violations across all queries
  • introspectBuilds a semantic model from a live database (SQLite, PostgreSQL, MySQL) by extracting primary keys and foreign keys from the catalog

Use cases

  • Prevent AI-generated SQL from silently double-counting revenue or other measures through incorrect joins
  • Block queries that expose PII/PHI columns before they execute
  • Validate dbt-generated queries and catch semantic errors in CI/CD pipelines
  • Audit existing SQL repositories for logical correctness without executing them
  • Enable self-healing AI agents that draft, check, fix, and re-check SQL automatically

io.github.sqlsure/sqlsure MCP server FAQ

What does sqlsure catch that databases don't?

Logical errors that are syntactically valid and execute without error: double-counted measures from fanout joins, non-additive aggregations (averaging an average), chasm joins, undeclared relationships, and PII exposure. Databases only catch syntax errors; sqlsure catches semantic ones.

Is sqlsure free?

Yes, sqlsure is open-source under Apache-2.0 license and available on PyPI. No subscription or API key required.

How do I use sqlsure as an MCP server in Claude or Cursor?

Install via `pip install sqlsure`, then add it to your MCP configuration with `claude mcp add sqlsure -- python -m sqlsure.mcp_server --model /abs/path/model.json`. See docs/MCP.md for tool reference and agent patterns.

What semantic information does sqlsure need?

sqlsure works with dbt manifests/schema.yml (unique and relationship tests), plain PK/FK declarations in JSON, introspected database catalogs (SQLite/PostgreSQL/MySQL), or hand-written model.json files. No new language to learn.

Does sqlsure access my data or make network calls?

No. sqlsure parses SQL text only, never connects to databases, makes no network calls, and collects no telemetry. Your SQL never leaves your machine.

Can AI agents use sqlsure to self-repair queries?

Yes. Every violation includes a machine-actionable fix; in benchmarks, applying the fix verbatim produced passing queries 10/10 times, enabling draft → check → fix → check → execute loops.

README (reference)

Source of truth, from the repository.

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

pip install sqlsure
from sqlsure import SemanticModel, check
violations = check(sql, model)   # [] means semantically safe

Or clone and run the 30-second demo:

python check.py                   # 5 wrong queries rejected, 1 approved — with fixes
python -m sqlsure.scan path/to/dbt-repo --report report.md   # audit any dbt repo

Three doors, one engine

1. CI gate — blocks the merge when a PR double-counts:

python -m sqlsure.cli --model model.json query.sql   # exit 1 on violations

2. MCP server — your AI agent must pass inspection before executing:

claude mcp add sqlsure -- python -m sqlsure.mcp_server --model /abs/path/model.json

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)

RuleSeverityCatches
FANOUTerrorSUM/COUNT of additive measure after one-to-many join
CHASMerrortwo+ fan-out joins multiplying each other
ADDITIVITYerrorSUM of a non-additive measure (rates, averages)
SEMI_ADDITIVEerrorbalances/censuses summed across their snapshot dimension
JOIN_KEYerrorjoin on columns matching no declared relationship
CROSS_JOINerrorjoin with no predicate
WEIGHTED_AVGwarningAVG silently re-weighted by fan-out
UNDECLARED_JOINwarningjoin with no declared relationship (unverifiable ≠ safe)
SENSITIVE_COLUMNpolicyPHI/PII column exposed in query output

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.json or schema.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.introspect builds the rulebook from the catalog — SQLite PRAGMAs or information_schema PK/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)

    from sqlsure.introspect import model_from_sqlite
    model = model_from_sqlite("app.db")   # PK -> grain, FK -> join edges
    
  • Hand-written JSONmodel.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, relationship joinType + 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

Apache-2.0 · sqlsure.ai

<!-- mcp-name: io.github.sqlsure/sqlsure -->

mcp-name: io.github.sqlsure/sqlsure

Related MCP servers

Control a real Chrome browser to complete any task: fill forms, extract data, book flights.

110k
Python
MIT
View repository →

Real-time global intelligence: markets, conflicts, country risk, energy, and infrastructure monitoring via 39 MCP tools.

83k
TypeScript
AGPL-3.0
View repository →

Netdata

Active

Real-time infrastructure monitoring with per-second metrics, ML-powered anomaly detection, and zero-configuration setup.

80k
Go
GPL-3.0
View repository →

Trending hip-hop artist momentum scores across four cultural dimensions.

79k
TypeScript
MIT
View repository →

AI orchestration platform with 100+ agents, swarm coordination, and self-learning memory for enterprise development.

68k
TypeScript
MIT
View repository →

Web scraping with stealth HTTP, real browsers, and Cloudflare bypass capabilities.

67k
Python
BSD-3-Clause
View repository →