SQLStudio 32-Tool Production-Safe Perf Tuning MCP Server
Expanded from 26 to 32 governed tools with a complete 6-tool PROD-safe SQL tuning pipeline: diagnose_prod_bottlenecks -> clone_prod_to_local_twin (0 prod disk, 0 PII) -> seed_tuning_data (100K Zipf) -> optimize_sql_statement (6 AST + ESR) -> verify_sql_in_stage (A/B DEV+TEST) -> request_prod_promotion (HMAC dual-gate + rollback DDL).
Interactive 18-Client Config Snippet Generator
Generates syntax-exact JSON, JSONC, TOML, and YAML managed-block configs across STDIO, Slim 4-Tool, and Bearer-authenticated Streamable HTTP.
Cursor
JSONSurgical write to mcpServers with .sqlstudio.bak backup
mcpServers1{2 "mcpServers": {3 "sqlstudio": {4 "command": "sqlstudio",5 "args": [6 "--mcp"7 ]8 }9 }10}32-Tool Search & Category Explorer
Every tool carries strict AST validation, dense lossless DSL output (~55% fewer tokens), and Zero-Trust + dual-stage risk tiering. Community includes Slim 4-tool STDIO free; Pro/Team unlocks all 32 tools.
use_databaseSwitch Database Target
Switch connection/DB and mint a scoped target_handle.
inspect_schemaInspect Database Schema
Dense lossless DSL (~55% fewer tokens) with #hash dedup and 1-hop FK neighbor matching.
describe_tableDescribe Table
Inspect table columns, FKs, indexes, and optional column stats.
query_sqlExecute SQL Query
Run SQL/Redis with dry_run, pagination, PII masking, and apr-* approval gate.
list_connectionsList Connections
List MCP-visible SQLStudio connections without exposing credentials.
explain_queryExplain Query Plan
Get EXPLAIN / EXPLAIN ANALYZE plan trees, metrics, and optimizer warnings.
audit_database_healthAudit Database Health
Run FK, orphan, PK, and index health audit with honest score caps and fix SQL.
find_join_pathFind Join Path
Find shortest FK join paths (<=4 hops) between two tables.
architect_schema_blueprintArchitect Schema Blueprint
Inspect live schema first, enforce grain/unique_key metadata, and block same-grain duplicates.
review_new_tableReview New Table
Compare proposed table vs live schema to return Merge / Add Column / Allow verdict.
preview_migrationPreview Schema Migration
Emit net diff-only DDL + rollback preview and issue single-use apr-* approval ticket.
validate_sqlValidate SQL
Dry-validate SQL syntax, AST bindings, column policies & Team SQL Rules without running.
upsert_glossary_termUpsert Glossary Term
Upsert, delete, or undo local Business Glossary annotations with audit logging.
get_ddlGet Object DDL
Extract engine-accurate DDL for tables, views, triggers, routines, sequences & enums.
list_objectsList Database Objects
List views, materialized views, triggers, functions, procedures, sequences & enums.
get_object_definitionGet Programmable Definition
Inspect full definition and metadata of a view, trigger, routine, sequence, or enum.
list_sessionsList Active Sessions
List active/idle/blocked/slow database sessions with summary counters.
lock_waitsInspect Lock Waits
Inspect lock wait graphs and blocking chains across sessions.
kill_sessionTerminate Session
Cancel query or terminate backend session (requires Zero-Trust human approval).
top_queriesTop Slow Queries
Fetch top slow or resource-heavy queries from database performance telemetry.
advise_indexesAdvise Indexes
Analyze SELECT predicates, sequential scans & optional HypoPG to suggest CREATE INDEX.
write_migration_fileWrite Migration File
Write timestamped up/down SQL migration files in sandboxed dir (Flyway/Goose/Prisma).
compare_schemasCompare Schemas
Compare schemas and small reference table rows across two connections without writes.
generate_mock_dataGenerate Mock Data
Generate FK-ordered deterministic mock INSERT SQL (preview by default; gated execution).
export_query_resultExport Query Result
Run read-only SQL with PII + column policies and export CSV/JSON/JSONL/Markdown/SQL.
run_saved_queryRun Saved Query
Execute saved workspace SQL inheriting parameter binding, PII shield & approval gates.
diagnose_prod_bottlenecksDiagnose PROD Bottlenecks
Strict read-only PROD scan for slow SQL (pg_stat_statements / performance_schema), Seq Scans, dead tuples & Root Blocker trees.
clone_prod_to_local_twinClone PROD to Local Twin
Zero-prod-disk clone of DDL, FKs & indexes (0 PII rows) into local SQLite/DuckDB or loopback PG/MySQL with linked_prod_id.
seed_tuning_dataSeed Tuning Dataset
Generates up to 100K-row Zipf/skewed datasets in local DEV/TEST twins with auto ANALYZE; physically blocked on PROD.
optimize_sql_statementOptimize SQL & Advise ESR Index
6-rule AST SQL rewrite (SARGable dates, NOT EXISTS, keyset cursors) plus ESR+INCLUDE covering index & rollback DDL.
verify_sql_in_stageVerify SQL in DEV / TEST Stage
Runs Before/After EXPLAIN ANALYZE A/B benchmarks on linked DEV/TEST stages and records HMAC-SHA256 verification proofs.
request_prod_promotionRequest PROD Promotion
Verifies DEV ✓ + TEST ✓ HMAC ledger proofs & 15-min single-use human approval grant with rollback DDL before touching PROD.
Zero-Truncation Schema & Result Encoding
inspect_schema encodes *=PK, !=NOT NULL, ?=NULL, ->FK, and idx() without dropping a single column. Supports #hash if_none_match dedup, 1-hop FK neighbor matching, and null_cols:/const_cols: factoring.
#hash: 9f4c12a8 | tables: 3 users(~1240r): id* i64, email! str, created_at! ts | idx(email!) orders(~8910r): id* i64, user_id! i64->users.id, total_fen! i64 | idx(user_id) payments(~8905r) [1-hop]: id* i64, order_id! i64->orders.id, status! str
## [TABLE] orders (~8910 rows) | Column | Type | Nullable | Key | | ------ | ---- | -------- | --- | | id | BIGINT | NO | PK | | user_id | BIGINT | NO | FK -> users.id | | total_fen | BIGINT | NO | ... |
Interactive ui://sqlstudio/* MCP Apps Showcase
MCP Apps-capable hosts render SQLStudio result grids, FK ERD graphs, EXPLAIN plan trees, and Zero-Trust approval cards inline over ui://sqlstudio/* resources.
Bound tools: query_sql · run_saved_query · list_sessions · lock_waits · top_queries
| order_id | customer_email (masked) | phone (masked) | gmv_fen | refund_reason |
|---|---|---|---|---|
| ord_90142 | a***e@acme.dev | 138****4419 | 429000 | NULL |
| ord_90143 | l***n@fintech.cn | 186****9201 | 1850000 | NULL |
| ord_90144 | k***g@studio.sg | +65****8812 | 690000 | duplicate_charge |
Live MCP Resources (sqlstudio://) & Guided Prompts
Exposes both static & templated URI resources plus guided workflows across MCP 2025-11-25 & 2025-03-26.
sqlstudio://connectionsapplication/jsonMetadata of MCP-visible connections with credentials stripped.
sqlstudio://schema/activetext/markdownDense schema snapshot for the active target connection.
sqlstudio://audit/activetext/markdownFK coverage, orphan checks, and index health audit findings.
sqlstudio://guide/dense-protocoltext/markdownReference for compact DSL markers, if_none_match & apr-* gates.
sqlstudio://rulesapplication/jsonTeam SQL Rules book, enforcement mode & column policies.
sqlstudio://glossary/activeapplication/jsonPer-connection Business Glossary terms & table/column anchors.
sqlstudio://{connection}/{database}/ddl/{object}application/sqlTemplate URI for canonical DDL of tables, views, triggers & enums.
sqlstudio://results/{id}{?offset,limit}application/jsonPaginated ResultSnapshotCache reader (?offset,limit).
sqlstudio://exports/{filename} & migrations/{rel_path}text/plainSandboxed reader for export_dir files & generated migrations.
Zero-Trust Execution Governance & Precision PII Shield
Models never receive plaintext DB passwords or raw PII—yet analytical aggregates like sum(gmv_fen) remain 100% uncorrupted.
Environment-Aware prod_write_policy & staging_write_policy
RO connections lock at both AST and session layers. Staging defaults to approve_ddl (allowing routine DML while gating DDL); Production defaults to approve_all_writes or strict force_read_only.
Single-Use SQL-Fingerprinted apr-* Approval Tickets
Destructive commands (DROP, TRUNCATE, unqualified writes, GRANT/REVOKE, Redis FLUSH*, kill_session) mint SHA-256 fingerprinted apr-* tickets with 600s TTL—consumed on single execution.
Diff-Only preview_migration & CREATE TABLE Gate
query_sql rejects ad-hoc CREATE TABLE without a verified preview_migration apr-* ticket. DDL follows strict UNIQUE -> FK ON DELETE -> CHECK -> INDEX ordering.
Multi-Client Target Leases & Column Deny/Mask Policies
McpClientLease isolates concurrent AI hosts via scoped target_handles, combined with per-connection mcp_visible visibility, disabled_tools, and column deny/mask policies.
Interactive Environment Policy Matrix
Switch target environment group to inspect effective policy gates:
- SELECT / EXPLAIN
- Allowed (PII Shield + max_rows enforced)
- INSERT / UPDATE / DELETE
- Requires apr-* approval ticket (or Denied in force_read_only)
- CREATE / ALTER / DROP / TRUNCATE
- Requires HMAC-SHA256 DEV ✓ + TEST ✓ ledger proofs + 15m manual grant (with rollback DDL)
Redacts phones, emails, national IDs/SSNs, cards, JWTs & Bearer tokens while preserving numeric aggregates like sum(gmv_fen).
| Field / Column | Category | MCP Output Payload |
|---|---|---|
| sum(gmv_fen) | METRIC_WORDS (Exempt) | 18945000000 |
| mobile_phone | phone | 138****5678 |
| user_email | a***e@fintech.io | |
| national_id | id_card | 1101**********123X |
| card_pan | bank_card | 6222********0091 |
| auth_header | token | Bearer ***[MASKED_TOKEN]*** |
deny:users.password_hash · mask:orders.shipping_phoneAudit log: JSONL retention 90d