← Back to Leaderboard
Sjmmana

jmmana/sqlguardllm

An AST-based SQL firewall for policy-controlled LLM queries and read-only MCP

Engineering Health (Methodology)
A · 81/100
Maintenance Activity
● Updated today
Latest Release
v1.1.0
Commercial License Check
Apache-2.0 · Commercial Friendly

Automated SPDX check for reference only — not legal advice. Disclaimer

Maintenance35/35
Fork Adoption6/25
Release Cadence20/20
License Clarity20/20
DockerMCPCLIAPI
Total Stars
★ 21
24h Growth
+1
7d Growth
+12
Forks
1

GitHub Star History

Tracked from daily D1 telemetry snapshots. Hover any data point for exact daily star counts.

jmmana/sqlguardllm Star History (2026-11-25 - 2026-12-04) DAILY STAR HISTORY (10-DAY D1 TELEMETRY) +20 in 9d · avg +2/day 25 13 0 2026-11-25: ★ 12026-11-26: ★ 92026-11-27: ★ 92026-11-28: ★ 92026-11-29: ★ 92026-11-30: ★ 162026-12-01: ★ 192026-12-02: ★ 202026-12-03: ★ 202026-12-04: ★ 21 ★ 21 11-25 11-29 12-04

Evidence-Backed Technical Brief

AI Deep Review

Architecture & Core Mechanics

SQLGuardLLM puts a Python policy engine between model-generated SQL and the database. It uses sqlglot to parse the input for a configured dialect, checks the entire syntax tree for a single read-only query under the default policy, and enforces table and column restrictions and dialect-specific function denials. Parse failures and missing filter context fail closed. An accepted query is regenerated from the rewritten tree; the original input is not the execution artifact.

For each reference to a filtered table, the engine substitutes an alias-preserving derived table and inserts escaped literals from trusted user context. That puts the row restriction at the table reference rather than attaching it only to the outer query, which matters for joins, subqueries, and CTEs. The guard then applies or tightens the result limit in the target dialect. The same engine is exposed through the Python API, CLI, HTTP service, and MCP; conformance tests compare decisions across Python, HTTP, Node.js, and .NET.

Key Capabilities & Differentiators

The read-only policy can reject wildcard access to tables with hidden columns, apply null, redact, hash, or partial masking, and enforce aggregate-only access. Join and subquery limits and optional EXPLAIN cost checks govern query shape and estimated cost separately from output size. JSONL and OpenTelemetry are available for audit. Dialect coverage spans 30+ dialects, but the named CI execution targets are PostgreSQL 16 and 18, MySQL 8, and SQL Server 2022.

The project benchmark accepted 0 of 69 attack cases and rejected 0 of 34 legitimate queries. On those same inputs, keyword filtering accepted 59 attack cases and rejected 3 legitimate queries; checking for a leading SELECT accepted 56 and rejected 1. Those numbers describe the test set, not a security proof. The experimental tier adds proxying for mapped MCP SQL tools, approved writes with a signed ledger and conditional undo, allowlisted stored procedures, and session-level restrictions after reading configured untrusted columns.

Trade-offs & Limitations

AST validation is more precise than keyword filtering and requires less hand-maintained matching logic, but it shifts work to schema-aware policy design and dialect testing. A 30+ dialect parsing surface is not equivalent to database-backed verification on every engine. Test representative queries against the deployed database, including joins and aggregations, and choose limits that preserve the answers users need. An output row cap limits returned data, not the amount of data scanned or the work needed to compute the result.

Keep least-privilege credentials, database grants, and native row-level security where available. They cover access paths that never pass through this guard. A shared HTTP service centralizes policy rollout but adds a network dependency; embedding avoids that hop but makes consistent rollout across applications your responsibility. Treat experimental writes as a separate trust boundary: they require a separate write credential and an approval-capable MCP client, and the ledger holds row data that must be protected.

Hardware & Deployment Guide

Python 3.10+ can run the guard in process. Node.js 18+ and .NET 8 or 10 can run the embedded engine on supported platforms without a separate Python installation or service, or call sqlguardllm serve to centralize policy. For a sandbox evaluation, uv run --extra mcp sqlguardllm mcp --demo runs from a checkout using fictional data without an external database or policy file. A real deployment needs a policy matched to its schema, trusted identity context for row filters, and a restricted database connection for execution.

No Docker image is published. The supplied Dockerfile builds the HTTP service on python:3.12-slim, installs the serve extra, runs as UID 10001, exposes port 8787, checks /v1/health, and defaults to /policy/policy.yaml. v1.0.0 stabilizes the core API and 15 core violation codes; for MCP, the stable tool is query. Shadow mode is not included in v1.0.0, and the stability commitment does not extend to the experimental features.

Execution boundary: sqlglot parses the full statement; accepted SQL is regenerated from the validated and rewritten tree.
Tenant scoping: filtered table references become alias-preserving derived tables, using values from trusted session context.
Data exposure: policy can hide or mask columns, require aggregation, and lower the output row cap in the target dialect.
Test coverage: the project benchmark reports 0 of 69 attack cases accepted and 0 of 34 legitimate queries rejected; CI also exercises four named database versions.
Integration surfaces: Python runs in process, Node.js and .NET can use the embedded engine or HTTP, and MCP exposes a stable read-only query tool.
Stability boundary: v1.0.0 covers the core API and 15 core violation codes; proxying, writes, stored procedures, and tainted sessions remain experimental.
Best For

Text-to-SQL or MCP data tools that need a policy check before execution, especially when tenant filters and column restrictions must be applied consistently over a restricted database account.

Skip If

You cannot route every generated query through the guard, need a substitute for database authorization, or require stable support for proxying, writes, or stored procedures.

Reviewed on 2026-12-03 · Grounded in GitHub README, root file tree & releases · Newer release v1.1.0 (2026-12-03) shipped after this reviewMethodology

Quick Start & Installation

DockerMCPCLIAPI
pip install sqlguardllm

Comparison vs. Top Coding, Skills & MCP Alternatives

Full comparison →
RepositoryStars7d TrendStackLicenseCore Positioning
sqlguardllm ★21+12PythonApache-2.0An AST-based SQL firewall for policy-controlled LLM queries and read-only MCP
mcp-for-blender37.1k+1.1kPythonGPL-3.0A local MCP bridge for inspecting and editing live Blender scenes with AI
chrome-devtools-mcp60.4k+760TypeScriptApache-2.0Chrome DevTools via MCP and CLI for live browser debugging and performance analy
context765.8k+333TypeScriptMITA hosted documentation index with MCP and CLI access for coding agents

AI Context Briefing (for Claude / Cursor / Windsurf)

Standardized architecture summary & quickstart commands ready to paste into coding agents.

Raw .md ↗
curl -sL https://repoforai.com/repo/jmmana/sqlguardllm.md

Embed Star History Chart & Badges in README.md

Full-history Star History SVGs and velocity cards on GitHub Camo: drop-in replacement for OSSInsight and Star History widgets.

jmmana/sqlguardllm Star History on RepoForAI

Active README embeds unlock Hot-Tier 6h Telemetry Refresh automatically (zero pay-to-rank).

Frequently Asked Questions about sqlguardllm

Where does SQLGuardLLM sit in the query path?

With the Python API or HTTP validator, execute only the rewritten SQL returned after a successful check. Supply user and tenant context from an authenticated session, not from model output. If you want the tool to handle execution, use the read-only MCP query tool with a restricted database credential.

Does it need a GPU, and how should I size it?

The guard parses and rewrites SQL on the CPU; it does not run model inference and needs no GPU or VRAM. No latency or memory figures are available. Size for query complexity and concurrency, and measure any database-side EXPLAIN checks separately from parsing and rewriting.

Can I self-host it commercially, and what compliance work remains?

Apache-2.0 permits commercial use and self-hosting. If you redistribute the software, comply with the license's notice requirements. Licensing does not settle data-handling obligations: review what is retained in audit output and, if experimental writes are enabled, protect the row data held in the ledger.

Why use this instead of native database controls or a keyword filter?

Use database grants and native row-level security as the enforcement baseline: they still apply when a query reaches the database by another route. SQLGuardLLM adds a pre-execution check for model-generated SQL, with policy decisions, rewrites, and row caps. Compared with a keyword filter, it can distinguish a SQL keyword in a literal from an operation in the syntax tree.

Upstream README & Documentation

This profile focuses on independent engineering analysis and live telemetry. Read the full upstream README, changelog, and examples directly on GitHub.

Maintaining jmmana/sqlguardllm? Pin to Homepage + competitor /alternatives pages with a custom Cloud/Demo CTA.Feature jmmana/sqlguardllm on Homepage & Alternatives ($19)
WEEKLY BREAKOUT DIGEST

Top 10 Breakout Open-Source AI Repos, Every Thursday

Signal-only digest of fast-growing AI repos, SPDX license alerts, and architecture picks. Zero spam.

Zero spam · 1-click unsubscribe · Privacy Policy

Saved in your browser · Export Markdown RFC tables or jump into /vs compare