Repository navigation
First stable release: the core API and the 15 core violation codes follow semver (docs/STABILITY.md). Also ships proxy mode, controlled writes, stored procedures and tainted sessions (experimental, outside that contract), the benchmark harness and sqlguardllm mcp --demo. Python, npm, NuGet and the MCP manifest advance together.
Added
Policy.from_databasenow maps the SQLAlchemy dialectpostgresqltopostgres(it raised "unknown dialect").sqlguardllm protect(#216): finds dbhub, Postgres MCP Pro and MCP Toolbox in Claude Desktop, Cursor and VS Code configs, drafts a policy from the database (EN/ES PII column heuristics: hidden or masked, with the reason), lints it and rewrites the entry to run throughsqlguardllm proxy. Dry run by default;--applykeeps a timestamped backup,--undorestores it; passwords are masked in all output. Docs indocs/PROTECT.md(EN/ES);examples/proxy/mcp-toolbox.yaml.langchain-sqlguardllm0.1.0a1 inclients/langchain(alpha, not on PyPI): a guardedsql_query_tool,sqlalchemy_executorandGuardedSQLDatabasefor LangChain 1.x.- Controlled writes (#170, writes), off by default.
Policy.writes(WritePolicy) andGuard.check_write()for single-tableINSERT,UPDATEandDELETE, with row filters ANDed into the write and the violation codeswrite_not_allowed,write_column_not_allowed,missing_whereandtoo_many_rows(EN/ES);check()still rejects every write.WriteRuntime(propose as a dry run, approved apply, undo with before-images, drift check) and a signedLedger, tested on SQLite, PostgreSQL 16 and 18, MySQL 8 and SQL Server 2022. MCP toolspropose_write,apply_writeandundo, registered only when the policy haswritesand a separate write database is given (create_server(write_database=, ledger_path=),sqlguardllm mcp --write-db --ledger); approval is asked through MCP elicitation and fails closed. - Tainted sessions in the MCP server (#171):
untrusted_columns,sensitive_tablesandon_tainted(deny) in the policy. Reading an untrusted column taints the session and queries on sensitive tables are refused withtainted_session(EN/ES); views over sensitive or untrusted data propagate; listed names must exist in the database or the server does not start. By default taint is kept per server-assignedmcp-session-id(bounded to 10,000 sessions); a call without one (stdio, in-process, the stateless protocol) has an unknown session and counts as tainted; stdio passessingle_session=True(themcpcommand does) and an explicitsession_idcallable still wins.explain_queryreportstainted,taint_sourcesandreads_untrusted. A query refused by the taint check is audited once, as a refusal. - Allowlisted stored procedures (#173, procedures):
proceduresin the policy allows T-SQLEXECand PostgreSQLCALLwith named, type-checked parameters and context-bound values; dynamic SQL,sp_executesql, linked servers, positional arguments and extra clauses are refused (procedure_not_allowed,procedure_param_invalid). sqlguardllm proxy: guards an existing database MCP server over stdio. Mapped SQL tools go throughGuard.check()and receive the rewritten SQL; tools that are neither mapped nor inpassthroughare hidden and refused. Checked against dbhub 2.1.0. Docs indocs/PROXY.md(EN/ES), maps inexamples/proxy/(#172).sqlguardllm mcp --demo: a fictional read-only sample database and a built-in policy, with one-click install links for Cursor and VS Code (#180).- Guard benchmark (#174, #182, benchmark):
python -m sqlguardllm.benchruns a versioned corpus (69 attacks, 34 legitimate queries) against sqlguardllm, two baselines or any validator through a JSON-lines adapter; published corpus atdocs/assets/corpus-v1.json. - Playground challenge, "break the firewall" (
playground/challenge/, #181): two beatable baseline levels and two sqlguardllm levels, all in the browser. Bypasses of sqlguardllm are reported privately and credited indocs/HALL_OF_FAME.mdafter the fix. - Compatibility check with the latest release of crewai-tools, agno, mcp-alchemy, langchain-community and pandasai, a weekly workflow and
docs/COMPATIBILITY.mdwith the sqlglot support policy (#166); a guide to embed the core package in a library (docs/embedding.md).