MCP 2025-11-25 & 2025-03-26 · 6 PROD-Safe Tuning Tools · v0.6.5

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).

32
Full Governed Tools
4
Slim STDIO Tools
18
AI Clients Supported
~55%
DSL Token Savings
4
Interactive MCP Apps
18 AI Clients · Surgical Config Upsert + .sqlstudio.bak

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

JSON

Surgical write to mcpServers with .sqlstudio.bak backup

~/.cursor/mcp.json
Key:mcpServers
JSON · STDIO · Full 32 Tools
1{
2 "mcpServers": {
3 "sqlstudio": {
4 "command": "sqlstudio",
5 "args": [
6 "--mcp"
7 ]
8 }
9 }
10}
1-Click CLI Install & VerificationSupports project-scoped config
install-project supports Claude Code (.mcp.json), Cursor, VS Code, Codex & Gemini CLIUniversal mcpServers JSON also works with Cherry Studio, JetBrains AI & Warp
Full 32-Tool Surface (incl. 6 Tuning) & Slim 4-Tool Profile

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_database
SLIM 4Core

Switch Database Target

Switch connection/DB and mint a scoped target_handle.

Schema / Scopeddense-dsl
inspect_schema
SLIM 4Schema

Inspect Database Schema

Dense lossless DSL (~55% fewer tokens) with #hash dedup and 1-hop FK neighbor matching.

describe_table
SLIM 4Schema

Describe Table

Inspect table columns, FKs, indexes, and optional column stats.

Read-Onlydense-dsl
query_sql
SLIM 4Query

Execute SQL Query

Run SQL/Redis with dry_run, pagination, PII masking, and apr-* approval gate.

list_connections
Core

List Connections

List MCP-visible SQLStudio connections without exposing credentials.

Read-Onlydense-dsl
explain_query
Query

Explain Query Plan

Get EXPLAIN / EXPLAIN ANALYZE plan trees, metrics, and optimizer warnings.

audit_database_health
Audit

Audit Database Health

Run FK, orphan, PK, and index health audit with honest score caps and fix SQL.

Read-Onlydense-dsl
find_join_path
Schema

Find Join Path

Find shortest FK join paths (<=4 hops) between two tables.

architect_schema_blueprint
Schema

Architect Schema Blueprint

Inspect live schema first, enforce grain/unique_key metadata, and block same-grain duplicates.

review_new_table
Audit

Review New Table

Compare proposed table vs live schema to return Merge / Add Column / Allow verdict.

Read-Onlydense-dsl
preview_migration
Schema

Preview Schema Migration

Emit net diff-only DDL + rollback preview and issue single-use apr-* approval ticket.

validate_sql
Audit

Validate SQL

Dry-validate SQL syntax, AST bindings, column policies & Team SQL Rules without running.

Read-Onlydense-dsl
upsert_glossary_term
Admin

Upsert Glossary Term

Upsert, delete, or undo local Business Glossary annotations with audit logging.

Schema / Scopeddense-dsl
get_ddl
Schema

Get Object DDL

Extract engine-accurate DDL for tables, views, triggers, routines, sequences & enums.

Read-Onlydense-dsl
list_objects
Schema

List Database Objects

List views, materialized views, triggers, functions, procedures, sequences & enums.

Read-Onlydense-dsl
get_object_definition
Schema

Get Programmable Definition

Inspect full definition and metadata of a view, trigger, routine, sequence, or enum.

Read-Onlydense-dsl
list_sessions
Admin

List Active Sessions

List active/idle/blocked/slow database sessions with summary counters.

lock_waits
Admin

Inspect Lock Waits

Inspect lock wait graphs and blocking chains across sessions.

kill_session
Admin

Terminate Session

Cancel query or terminate backend session (requires Zero-Trust human approval).

top_queries
Audit

Top Slow Queries

Fetch top slow or resource-heavy queries from database performance telemetry.

advise_indexes
Audit

Advise Indexes

Analyze SELECT predicates, sequential scans & optional HypoPG to suggest CREATE INDEX.

write_migration_file
Export

Write Migration File

Write timestamped up/down SQL migration files in sandboxed dir (Flyway/Goose/Prisma).

Schema / Scopeddense-dsl
compare_schemas
Audit

Compare Schemas

Compare schemas and small reference table rows across two connections without writes.

Read-Onlydense-dsl
generate_mock_data
Export

Generate Mock Data

Generate FK-ordered deterministic mock INSERT SQL (preview by default; gated execution).

export_query_result
Export

Export Query Result

Run read-only SQL with PII + column policies and export CSV/JSON/JSONL/Markdown/SQL.

Schema / Scopeddense-dsl
run_saved_query
Query

Run Saved Query

Execute saved workspace SQL inheriting parameter binding, PII shield & approval gates.

diagnose_prod_bottlenecks
Tuning (6)

Diagnose PROD Bottlenecks

Strict read-only PROD scan for slow SQL (pg_stat_statements / performance_schema), Seq Scans, dead tuples & Root Blocker trees.

Perf Tuning · Twin/Safeui://explain-plan
clone_prod_to_local_twin
Tuning (6)

Clone 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.

Perf Tuning · Twin/Safedense-dsl
seed_tuning_data
Tuning (6)

Seed Tuning Dataset

Generates up to 100K-row Zipf/skewed datasets in local DEV/TEST twins with auto ANALYZE; physically blocked on PROD.

Perf Tuning · Twin/Safedense-dsl
optimize_sql_statement
Tuning (6)

Optimize SQL & Advise ESR Index

6-rule AST SQL rewrite (SARGable dates, NOT EXISTS, keyset cursors) plus ESR+INCLUDE covering index & rollback DDL.

Perf Tuning · Twin/Safeui://explain-plan
verify_sql_in_stage
Tuning (6)

Verify SQL in DEV / TEST Stage

Runs Before/After EXPLAIN ANALYZE A/B benchmarks on linked DEV/TEST stages and records HMAC-SHA256 verification proofs.

Perf Tuning · Twin/Safeui://explain-plan
request_prod_promotion
Tuning (6)

Request PROD Promotion

Verifies DEV ✓ + TEST ✓ HMAC ledger proofs & 15-min single-use human approval grant with rollback DDL before touching PROD.

Lossless Dense DSL · ~55% Fewer Tokens

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.

compact DSL (~55% savings)184 tokens
#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
Standard Markdown Table412 tokens
## [TABLE] orders (~8910 rows)
| Column | Type | Nullable | Key |
| ------ | ---- | -------- | --- |
| id | BIGINT | NO | PK |
| user_id | BIGINT | NO | FK -> users.id |
| total_fen | BIGINT | NO | ... |
text/html;profile=mcp-app · CSP-Strict Interactive Views

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.

ui://sqlstudio/result-table · query_sql, run_saved_query, list_sessions, lock_waits, top_queriesGPUI Native
ui://sqlstudio/result-tabletext/html;profile=mcp-app

Bound tools: query_sql · run_saved_query · list_sessions · lock_waits · top_queries

default-src none · Inline Sandbox
res_88c1e2rows=4 / total=1,248const_cols: currency="USD"
PII Shield: 2 columns masked · sum(gmv_fen) intact
order_idcustomer_email (masked)phone (masked)gmv_fenrefund_reason
ord_90142a***e@acme.dev138****4419429000NULL
ord_90143l***n@fintech.cn186****92011850000NULL
ord_90144k***g@studio.sg+65****8812690000duplicate_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/json

Metadata of MCP-visible connections with credentials stripped.

sqlstudio://schema/activetext/markdown

Dense schema snapshot for the active target connection.

sqlstudio://audit/activetext/markdown

FK coverage, orphan checks, and index health audit findings.

sqlstudio://guide/dense-protocoltext/markdown

Reference for compact DSL markers, if_none_match & apr-* gates.

sqlstudio://rulesapplication/json

Team SQL Rules book, enforcement mode & column policies.

sqlstudio://glossary/activeapplication/json

Per-connection Business Glossary terms & table/column anchors.

sqlstudio://{connection}/{database}/ddl/{object}application/sql

Template URI for canonical DDL of tables, views, triggers & enums.

sqlstudio://results/{id}{?offset,limit}application/json

Paginated ResultSnapshotCache reader (?offset,limit).

sqlstudio://exports/{filename} & migrations/{rel_path}text/plain

Sandboxed reader for export_dir files & generated migrations.

ZERO-TRUST GOVERNANCE & OUTBOUND PII SHIELD

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.

Read Governance & CLI Docs
Policy Gate

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.

TTL 600s

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

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.

Lease Sync

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:

prod_write_policy = "approve_all_writes"
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)
Outbound PII Shield · mask_text_for_ai()

Redacts phones, emails, national IDs/SSNs, cards, JWTs & Bearer tokens while preserving numeric aggregates like sum(gmv_fen).

Field / ColumnCategoryMCP Output Payload
sum(gmv_fen)METRIC_WORDS (Exempt)18945000000
mobile_phonephone138****5678
user_emailemaila***e@fintech.io
national_idid_card1101**********123X
card_panbank_card6222********0091
auth_headertokenBearer ***[MASKED_TOKEN]***
Column policies: deny:users.password_hash · mask:orders.shipping_phoneAudit log: JSONL retention 90d
Community includes Slim 4-tool STDIO free · 7-day no-card Pro trial

Connect your AI agent to 12 database engines with Zero-Trust guardrails