Repository navigation
Releases
Releases · halovina/kacasql
Release v1.1.0: Production Guardrails & Performance Protection
🛡️ KacaSQL v1.1.0 — Production Guardrails & Performance Protection
Safe enough to point directly at production read-replicas without risking resource exhaustion or accidental data leaks.
v1.1.0 upgrades KacaSQL from strict read-only query enforcement into a production-ready database MCP server with multi-layer guardrails across both PostgreSQL and MySQL.
✨ What's New
1. Execution Resource Caps & Streaming Payload Truncation
- Millisecond Timeouts (
timeout_ms): Enforced directly at the database session level (SET LOCAL statement_timeouton PostgreSQL,SET SESSION max_execution_timeon MySQL). - Hard Payload Byte Cap (
max_payload_bytes, default51200/ 50 KB): Prevents LLM context-window blowups on wide result sets via streaming row assembly. - Structured
_metaTruncation Hints: Whenever results are capped bymax_rowsormax_payload_bytes, KacaSQL appends actionable_metahints so AI agents know whether to narrow columns, tightenWHEREfilters, or lowerLIMIT.
2. Granular Access Control (allowed_schemas & blocked_tables)
- 2-Layer Enforcement: Applied consistently across all discovery/inspection tools (
list_schemas,list_tables,search_schema,describe_table,get_table_relationships,get_table_sample),db://{connection_id}/overview, andsqlglotAST table/schema checks. - Supports exact table names, schema-qualified names (
private.billing_tokens), and glob patterns (audit_*,private.*) while safely ignoring local CTE aliases.
3. Full PII Protection (Column-Name + Value-Level Regex)
- Column-Name Masking: Global
masked_columnsmerged with per-connectioncustom_pii_columns. - Value-Level PII Redaction: Built-in ReDoS-safe presets (
credit_card,jwt,id_nik,id_npwp,email) plus user-definedcustom_pii_value_patterns(validated fail-fast at config load) to redact sensitive values leaked inside free-text orJSONBcolumns.
4. EXPLAIN-First Full Table Scan Blocker (block_full_table_scan)
- Environment-Aware Safe Default: Automatically enabled (
true) whenenvironment: prodandfalseforlocal/dev/staging(always explicitly overridable). - PostgreSQL: Detects
Seq ScanandParallel Seq Scan(accounting forWorkers Planned) abovescan_row_threshold(default100,000), with a limit-aware exception so simple peeks likeSELECT * FROM orders LIMIT 5(without filters/sorts) are not falsely blocked. - MySQL: Detects
ALLandindexfull scans exceedingscan_row_threshold. - Returns a compact
offending_scanssummary + rewrite hint so the AI can self-correct using indexed columns.
5. Privacy-First Local JSONL Audit Trail
- Opt-in persistent JSONL log via
defaults.audit_log_pathorKACASQL_AUDIT_LOG(e.g.,~/.kacasql/audit.jsonl). - Default SQL Literal Redaction (
audit_redact_sql_literals: true): Replaces string & numeric literals with placeholders viasqlglotAST (preventing audit logs from becoming a shadow PII store) and recordssql_hash(SHA-256). - Enforces
0600file permissions on POSIX, size-capped rotation (audit_max_bytes, default 10 MB), and fail-safe writes.
6. Declarative guardrails: YAML Block & CLI --version
- Clean
guardrails:configuration block (100% backward-compatible withv1.0flat fields; strictlydsn_env-only). - Added
kacasql --versionCLI flag.
📦 Quick Upgrade (uvx)
Update your MCP client config (~/.gemini/config/mcp_config.json or Claude Desktop) to @v1.1.0:
{
"mcpServers": {
"kacasql": {
"command": "uvx",
"args": [
"--from",
"git+https://github.com/halovina/kacasql.git@v1.1.0",
"kacasql"
],
"env": {
"KACASQL_CONFIG": "/path/to/connections.yaml",
"KACASQL_AUDIT_LOG": "~/.kacasql/audit.jsonl",
"PROD_REPLICA_PG_DSN": "postgresql://readonly_user:password@prod-replica:5432/app"
}
}
}
}✅ Verification
- 112 tests passed (
103unit tests +9live Docker PostgreSQL 16 & MySQL 8.4 integration & multi-scenario stress tests). - Verified under 80 concurrent mixed adversarial/valid/timeout/payload-cap calls and 100-query burst pool saturation (
223.5 QPS, 0 pool errors, 0 credential/PII leaks).
Full Changelog: v1.0.1...v1.1.0
v1.0.0 — Initial Public Release (PostgreSQL & MySQL Strict Read-Only MCP Server)
See through your database with AI — without ever breaking it.
KacaSQL v1.0.0 is the initial public release of a strict read-only, multi-connection Model Context Protocol (MCP) server for PostgreSQL and MySQL, purpose-built for backend developers.
Highlights
- 2-Layer Strict Read-Only Guardrails
- Layer 1 — AST Validation (
sqlglot): Dialect-aware (postgres&mysql) query validation blocking multi-statement SQL, DML/DDL, write-CTEs (WITH ... DELETE/INSERT/UPDATE),SELECT INTO/INTO OUTFILE,LOAD DATA INFILE,FOR UPDATE, and dangerous DB functions (pg_read_file,set_config,dblink*,LOAD_FILE,GET_LOCK,BENCHMARK, etc.). - Layer 2 — Database Session Guard: Every query executes inside a strict read-only transaction with statement timeout (
BEGIN TRANSACTION READ ONLY+statement_timeouton PostgreSQL;START TRANSACTION READ ONLY+max_execution_timeon MySQL) and always ends inROLLBACK.
- Layer 1 — AST Validation (
- Multi-Engine & Multi-Connection Support
- Connect to multiple PostgreSQL (
psycopgv3 async pool) and MySQL (aiomysql) databases acrosslocal,staging, andprod-replicavia declarative YAML (connections.yaml) with lazy connection pooling.
- Connect to multiple PostgreSQL (
- Zero Credential Leakage & PII Protection
- DSNs are loaded lazily from environment variables and scrubbed from all logs and error responses.
- Automatic glob-based PII masking (
*password*,*secret*,*token*,api_key*,credit_card*,nik, plus per-connection overrides), configurable hard row caps, and long-cell truncation.
- Focused MCP Surface Area
- 9 Tools:
list_connections,list_schemas,list_tables,search_schema,describe_table,get_table_relationships,get_table_sample,execute_read_query,explain_query. - 1 Resource:
db://{connection_id}/overview. - 2 Prompts:
debug-slow-query,explore-table-context.
- 9 Tools:
- Verified & CI-Ready
- Supports Python 3.11, 3.12, and 3.13 with
uv. - Full unit test suite + Docker PostgreSQL 16 & MySQL 8.4 integration tests.
- Supports Python 3.11, 3.12, and 3.13 with
Quick Start
See the README for Antigravity IDE and Claude Desktop MCP setup instructions.