KacaSQL
Strict read-only inspection of MySQL databases: list schemas, tables and views, search tables/columns by keyword, describe tables (columns, types, defaults, PKs, indexes, constraints, FKs, comments), map inbound/outbound relationships, fetch 1–20 sample rows with PII masking and truncation, run validated single SELECT queries with timeout and row caps, and inspect EXPLAIN plans inside a rolled-back read-only transaction.
Strict read-only inspection of PostgreSQL databases: list schemas, tables and views, search tables/columns by keyword, describe tables (columns, types, defaults, PKs, indexes, constraints, FKs, comments), map inbound/outbound relationships, fetch 1–20 sample rows with PII masking and truncation, run validated single SELECT queries with timeout and row caps, and inspect EXPLAIN (FORMAT JSON)/ANALYZE plans inside a rolled-back read-only transaction.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
KacaSQL
See through your database with AI — without ever breaking it.Strict read-only, multi-connection Model Context Protocol (MCP) server for PostgreSQL and MySQL, purpose-built for backend developers.
Kaca means glass in Indonesian: your AI coding assistant can clearly inspect schemas, relationships, indexes, sample data, and query execution plans—while a strict read-only barrier keeps your data untouchable.
Key Features (PostgreSQL & MySQL)
2-Layer Strict Read-Only Enforcement:
AST Validation (
sqlglot): Dialect-aware (postgres&mysql) validation blocking multi-statement SQL, DML/DDL, write-CTEs (WITH ... DELETE),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.).Database Session Guard: Every query runs inside a strict read-only transaction (
BEGIN TRANSACTION READ ONLY+statement_timeouton PostgreSQL;START TRANSACTION READ ONLY+max_execution_timeon MySQL) and always ends inROLLBACK.
Multi-Engine & Multi-Connection by Design: Connect to PostgreSQL and MySQL across
local,staging, andprod-replicain a single server using declarative YAML + lazy connection pooling (psycopgv3 async &aiomysql).Zero Credential Leakage: DSNs are loaded lazily from environment variables and scrubbed from all logs and error responses.
Context-Window & PII Protection: Automatic glob-based PII masking (
*password*,*token*,nik, etc.), configurable hard row caps, and long-cell truncation.9 Focused Backend-Dev Tools + 1 Resource + 2 Prompts: Lean surface area so LLMs pick the right tool every time.
Related MCP server: MCP Data Bridge
Available MCP Primitives
Tools
Tool | Purpose |
| List configured connections (engine, environment, mode, description — never credentials) |
| List schemas with table & view counts |
| List tables/views with estimated row counts, sizes, and comments |
| Search tables & columns across schemas by keyword (e.g. |
| Full technical inspection: columns, types, defaults, PKs, indexes, constraints, FKs, comments |
| Map outbound & inbound foreign keys |
| Fetch 1–20 sample rows with automatic PII masking & truncation |
| Run a validated single |
| Inspect |
Resource & Prompts
Resource:
db://{connection_id}/overview— Database engine version, active extensions/plugins, server timezone, and schemas.Prompts:
debug-slow-query,explore-table-context.
Quick Start
1. Clone and install dependencies with uv
git clone https://github.com/halovina/kacasql.git
cd kacasql
uv sync2. Configure connections
Copy the example config and export your DSN environment variable(s):
cp config/connections.example.yaml connections.yaml
export LOCAL_PG_DSN="postgresql://readonly_user:password@localhost:5432/mydb"3. Connect KacaSQL to Your MCP Client
Tip (macOS / Linux GUI apps): Desktop apps like Antigravity IDE and Claude Desktop often do not inherit
~/.local/bininPATH. Runwhich uvin your terminal and use the full path (for example/Users/<you>/.local/bin/uv) as"command"if"uv"cannot be found.
Option A: Antigravity IDE
Open (or create) your global Antigravity MCP config file:
macOS / Linux:
~/.gemini/config/mcp_config.json
Add the
kacasqlserver under"mcpServers":{ "mcpServers": { "kacasql": { "command": "/Users/<your-user>/.local/bin/uv", "args": ["run", "--directory", "/absolute/path/to/kacasql", "kacasql"], "env": { "KACASQL_CONFIG": "/absolute/path/to/kacasql/connections.yaml", "LOCAL_PG_DSN": "postgresql://readonly_user:password@localhost:5432/mydb" } } } }Verify the connection in Antigravity IDE via Additional Options (
...) > MCP Servers — you should seekacasqlconnected with all 9 tools available.
Option B: Claude Desktop
Open (or create) your Claude Desktop config file:
macOS:
~/Library/Application Support/Claude/claude_desktop_config.jsonWindows:
%APPDATA%\Claude\claude_desktop_config.jsonLinux:
~/.config/Claude/claude_desktop_config.json*(In Claude Desktop, you can also open Settings > Developer > Edit Config.)*
Add the
kacasqlserver under"mcpServers":{ "mcpServers": { "kacasql": { "command": "/Users/<your-user>/.local/bin/uv", "args": ["run", "--directory", "/absolute/path/to/kacasql", "kacasql"], "env": { "KACASQL_CONFIG": "/absolute/path/to/kacasql/connections.yaml", "LOCAL_PG_DSN": "postgresql://readonly_user:password@localhost:5432/mydb" } } } }Quit and reopen Claude Desktop completely (Cmd+Q on macOS) so it loads the new MCP server.
Click the tools icon in the chat input to verify
kacasqltools are active.
Multi-Connection Example (env)
If your connections.yaml defines multiple databases (local_pg, staging_pg, prod_replica_pg), simply pass each referenced dsn_env variable in the "env" block:
"env": {
"KACASQL_CONFIG": "/absolute/path/to/kacasql/connections.yaml",
"LOCAL_PG_DSN": "postgresql://kacasql:kacasql_dev_password@localhost:5439/ecommerce",
"STAGING_PG_DSN": "postgresql://readonly_user:secret@staging-db.internal:5432/app",
"PROD_REPLICA_PG_DSN": "postgresql://readonly_user:secret@prod-replica.internal:5432/app"
}Example Prompts to Try
Once connected, try asking your AI assistant:
"List all configured database connections in KacaSQL."
"Search the schema on
local_pgfor any table with atenant_idcolumn.""Describe the
orderstable and show its inbound & outbound relationships.""Show 5 sample rows from
users— verify that sensitive columns are masked.""Run EXPLAIN ANALYZE on
SELECT * FROM orders WHERE tenant_id = 101and suggest index improvements."
Troubleshooting
spawn uv ENOENT/ command not found: Replace"uv"with the full binary path returned bywhich uv(e.g./Users/<your-user>/.local/bin/uv).Config file not found: Make sure
KACASQL_CONFIGpoints to an absolute path and thatconnections.yamlexists (copy fromconfig/connections.example.yaml).Inspecting logs: KacaSQL emits all logs and JSON audit entries strictly to
stderr(neverstdout). You can test startup manually via:KACASQL_CONFIG=./connections.yaml uv run kacasql --log-level DEBUG
Development & Testing
Unit Tests (no database required)
uv run pytest tests/unit/Integration Tests (Docker PostgreSQL 16 + MySQL 8.4)
docker compose -f docker/docker-compose.yml up -d --wait
KACASQL_TEST_PG_DSN="postgresql://kacasql:kacasql_dev_password@localhost:5439/ecommerce" \
KACASQL_TEST_MYSQL_DSN="mysql://kacasql:kacasql_dev_password@127.0.0.1:3309/ecommerce" \
uv run pytest -vRoadmap
Phase 1 (Done): PostgreSQL Adapter, Strict Read-Only, Multi-Connection, Backend Developer toolset.
Phase 2 (Done): MySQL Adapter (
MySQLAdapterviaaiomysql), MySQL AST guardrails & Docker MySQL 8 integration tests.Phase 3 (Planned): Modular toolsets (
dba,analytics), optional semantic context YAML, opt-in controlled Write/DDL mode (dry_run,max_affected_rows,WHEREguardrails), & Streamable HTTP transport.
License
MIT — see LICENSE.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Review your AI agent's database changes on your schema, with plain-language risk, before they run.
PostgreSQL, MySQL, and SQL Server in one session. 26 read-only MCP tools for AI agents.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceProvides AI assistants with read-only access to inspect database schemas, preview data, and run safe queries across PostgreSQL, MySQL, MongoDB, and SQL Server. It enables AI tools to understand database structures and relationships automatically to generate more accurate code.19 npm7MIT
- AlicenseNot gradedqualityCmaintenanceEnables AI agents to securely discover database schemas and execute read-only SQL queries through guardrailed tools that block mutations and clamp result sizes.1MIT
- AlicenseAqualityCmaintenanceEnables AI assistants to safely explore and query MySQL, MariaDB, PostgreSQL, SQLite and StarRocks databases through read-only tools for schema listing, table description, schema search, row sampling, query execution, and plan explanation. Enforces least-privilege accounts, engine-level read-only sessions with timeouts, parsed SQL guardrails, and column masking so runaway or unsafe queries are refused.8MIT
- AlicenseAqualityBmaintenanceEnables AI assistants to explore PostgreSQL schemas and run safe, read-only queries in plain English. It applies SQL validation, row limits, and read-only sessions to prevent writes and unsafe operations.6MIT