DBA-Architect
Provides tools for MySQL database administration: auditing SQL migrations, optimizing composite B-Tree indexes via ESR rules, diagnosing EXPLAIN plans, planning zero-downtime migrations, analyzing transactions and locking, recommending partitioning and archiving, and calculating capacity and configuration.
Provides tools for PostgreSQL database administration: auditing SQL migrations, optimizing composite B-Tree indexes via ESR rules, diagnosing EXPLAIN plans, planning zero-downtime migrations, analyzing transactions and locking, recommending partitioning and archiving, and calculating capacity and configuration.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@DBA-Architect audit my last migration for locking issues and score its health"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
๐๏ธ DBA-Architect
Principal Database Administrator (DBA) & Data Architecture AI Skill Agent + MCP Server
Autonomously audit SQL migrations, optimize composite B-Tree indexes via ESR rules, eliminate N+1 queries, diagnose EXPLAIN plans, execute zero-downtime migrations, and prevent transaction deadlocks for PostgreSQL & MySQL.
๐ Overview
DBA-Architect bridges the gap between software development and deep database performance engineering. Modern AI assistants often guess or generate naive SQL recommendations; DBA-Architect replaces guesswork with 8 deterministic AST & heuristic engines built upon battle-tested database administration playbooks.
Whether you are authoring a DDL migration in Prisma, tuning an e-commerce order checkout transaction, or scaling a 50M-row table, DBA-Architect delivers deterministic audits, Mermaid visual execution plans, and non-blocking production runbooks directly to your AI Agent IDE.
Core Pillars
๐ก๏ธ Zero-Guesswork Deterministic Engine: Built-in AST parsers (
pgsql-ast-parser,node-sql-parser) enforcing 30+ strict DBA rules with a deterministic Schema Health Score (0โ100).๐ Universal AI Agent Ecosystem: First-class adapters for Google Antigravity, Cursor, Anthropic Claude Code, Windsurf, GitHub Copilot, Cline / Roo Code, Continue.dev, and Kiro AI IDE.
โก ESR Index Engineering: Implements the Equality, Sort, Range composite indexing algorithm, detects non-sargable predicates, and eliminates redundant left-prefix indexes.
๐ Zero-Downtime Migration Runbooks: Converts blocking
ALTER TABLEstatements into phased Expand & Contract workflows (CONCURRENTLY,NOT VALIDโVALIDATE,ALGORITHM=INPLACE).๐ Concurrency & Deadlock Prevention: Detects lost update race conditions in financial paths, enforces pessimistic row-locking (
SELECT ... FOR UPDATE), and flags dangerous external HTTP/network I/O inside transaction blocks.
Related MCP server: Postgres MCP Pro
๐๏ธ Architecture
graph TB
subgraph ClientLayer ["1. Multi-Agent AI IDE Layer (Universal Adapters)"]
A1["Google Antigravity<br/>(@dba-architect)"]
A2["Cursor<br/>(.cursor/rules/dba-architect.mdc)"]
A3["Claude Code<br/>(CLAUDE.md)"]
A4["Windsurf<br/>(.windsurfrules)"]
A5["GitHub Copilot<br/>(.github/copilot-instructions.md)"]
A6["Cline / Roo Code<br/>(.clinerules)"]
A7["Universal MCP Clients<br/>(Continue, Desktop, Kiro)"]
A8["CLI Runner<br/>(npx dba-architect init)"]
end
subgraph ServerLayer ["2. Deterministic MCP Server (dba-architect)"]
M1["JSON-RPC 2.0 Stdio Transport"]
M2["AST Parsers: pgsql-ast-parser & node-sql-parser"]
M3["Codebase Scanner & N+1 Loop Extractor"]
M4["Capacity & B-Tree Footprint Calculator"]
end
subgraph ToolsSuite ["3. 8 Deterministic DBA Tools"]
T1["analyze_migration"]
T2["recommend_indexes_for_queries"]
T3["scan_project_queries"]
T4["analyze_explain_plan"]
T5["plan_zero_downtime_migration"]
T6["analyze_transaction_and_locking"]
T7["recommend_partitioning_and_archiving"]
T8["calculate_db_capacity_and_config"]
end
ClientLayer --> ServerLayer
ServerLayer --> ToolsSuite๐ ๏ธ 8 Deterministic MCP Tools & Rules Matrix
DBA-Architect exposes 8 specialized tools adhering to the Model Context Protocol (MCP):
# | MCP Tool Name | Functionality & Key Triggers | Primary Rules Enforced |
1 |
| Audits SQL DDL, migration files, or migration directories. Computes deterministic Health Score (0โ100). |
|
2 |
| Synthesizes optimal composite/covering B-Tree indexes via ESR rules and flags non-sargable query predicates. |
|
3 |
| Traverses Go, PHP/Laravel, TypeScript/Prisma/Drizzle, and Python codebases to detect N+1 loops and synthesize table indexes. |
|
4 |
| Parses PostgreSQL/MySQL |
|
5 |
| Formulates zero-downtime Expand & Contract runbooks with dual-writing, backfilling, and contract phases. |
|
6 |
| Audits SQL & ORM transaction blocks to prevent lost updates, deadlocks, and external HTTP calls inside transactions. |
|
7 |
| Designs declarative table partitioning ( |
|
8 |
| Estimates tuple header overhead, table & index GB storage, working-set RAM fit, and tunes |
|
๐ Installation & Setup
You can use DBA-Architect through any of the following methods depending on your development workflow:
๐ Method A: MCP Server Setup (Recommended for AI IDEs)
Configure your AI IDE to fetch and execute the MCP server directly via npx:
1. Google Antigravity & Gemini CLI
Add to your project's mcp_config.json or global config:
{
"mcpServers": {
"dba-architect": {
"command": "npx",
"args": ["-y", "github:hanifalkauni/dba-architect"]
}
}
}2. Claude Desktop & Claude Code
Add to claude_desktop_config.json:
{
"mcpServers": {
"dba-architect": {
"command": "npx",
"args": ["-y", "github:hanifalkauni/dba-architect"]
}
}
}3. Cursor & Continue.dev
In Cursor (Features โ MCP Servers) or Continue (config.json):
{
"name": "dba-architect",
"command": "npx",
"args": ["-y", "github:hanifalkauni/dba-architect"]
}Note for Local Development: If running from a local clone, replace
"command": "npx"with"command": "node"and"args": ["/path/to/dba-architect/dist/index.js"].
๐ฆ Method B: Universal Skills CLI (skills.sh)
Install DBA-Architect with a single command into Cursor, Claude Code, Windsurf, Copilot, or Gemini CLI:
npx skills add hanifalkauni/dba-architectโก Method C: One-Command Adapter Injection via CLI
Run this command inside any target repository to automatically generate and configure adapters for all supported IDEs:
npx -y github:hanifalkauni/dba-architect init๐ป Method D: Manual Adapter Installation per AI IDE
Copy the adapter to your workspace skill directory:
mkdir -p .agents/skills/dba-architect
cp adapters/antigravity/SKILL.md .agents/skills/dba-architect/SKILL.md(Or install globally at ~/.gemini/config/skills/dba-architect/SKILL.md)
Copy rules to your Cursor rules directory:
mkdir -p .cursor/rules
cp adapters/cursor/dba-architect.mdc .cursor/rules/dba-architect.mdcCopy instructions to your project root:
cp adapters/claude/CLAUDE.md ./CLAUDE.mdCopy rules to your project root:
cp adapters/windsurf/.windsurfrules ./.windsurfrulesCopy instructions to your GitHub repository directory:
mkdir -p .github
cp adapters/copilot/copilot-instructions.md .github/copilot-instructions.mdCopy steering and MCP configuration:
mkdir -p .kiro/steering
cp adapters/kiro/dba-architect.md .kiro/steering/dba-architect.md
cp adapters/kiro/config.json .kiro/config.json๐ Repository Structure
dba-architect/
โโโ adapters/ # Multi-Agent IDE Adapter Suite
โ โโโ antigravity/SKILL.md # Google Antigravity / Gemini CLI Skill
โ โโโ claude/CLAUDE.md # Anthropic Claude Code & Desktop
โ โโโ cline/.clinerules # Cline / Roo Code Rules
โ โโโ continue/ # Continue.dev Rules & MCP Configuration
โ โโโ copilot/copilot-instructions.md # GitHub Copilot Custom Instructions
โ โโโ cursor/dba-architect.mdc # Cursor MDC Rules (Globs & Frontmatter)
โ โโโ kiro/ # Kiro AI IDE Steering & MCP Configuration
โ โโโ windsurf/.windsurfrules # Windsurf Cascade Rules
โโโ src/ # Core Engine Source Code
โ โโโ adapters.ts # CLI Adapter Installer Engine
โ โโโ index.ts # Unified Entrypoint (CLI Runner + MCP Stdio)
โ โโโ server.ts # MCP Server Implementation & Schema Registry
โ โโโ constants/ # Deterministic DBA Rules & Heuristics Catalog
โ โโโ parsers/ # SQL AST & DDL Parsers (PG & MySQL)
โ โโโ tools/ # 8 Deterministic Tool Handlers
โ โโโ types/ # TypeScript Interfaces & Zod Schemas
โ โโโ utils/ # Safe File Walker & Heuristics Utilities
โโโ tests/ # Comprehensive Test Suite (Vitest)
โ โโโ dba-architect.test.ts # 18 Unit & Integration Tests (100% Passing)
โโโ dba-architect.config.json # Default Configuration Template
โโโ schema.json # JSON Schema for Configuration Validation
โโโ SKILL.md # Canonical Universal Agent Skill Playbook
โโโ package.json # Node.js Package Manifest & Dependencies
โโโ tsconfig.json # TypeScript Compiler Configuration
โโโ LICENSE # MIT Open-Source License๐งช Testing & Verification
Run the test suite using Vitest to verify all 8 tools and adapter installations:
# Run unit & integration tests
npm test
# Run tests in watch mode
npm run test:watch
# Compile TypeScript
npm run buildโ FAQ & Troubleshooting
B-Tree indexes can only traverse a single range predicate efficiently. If a range condition is placed before equality or sort conditions, the database engine must scan all rows matching the range and filter the rest in memory or perform a separate sort step (External merge Disk). The ESR rule ensures optimal index selectivity and eliminates unnecessary sorting.
In PostgreSQL, standard CREATE INDEX acquires a SHARE lock that blocks writes (INSERT/UPDATE/DELETE). DBA-Architect automatically converts these to CREATE INDEX CONCURRENTLY and splits foreign key additions into ADD CONSTRAINT ... NOT VALID followed by VALIDATE CONSTRAINT to avoid long-running exclusive locks. In MySQL, it generates ALGORITHM=INPLACE, LOCK=NONE.
MySQL InnoDB physically orders table rows on disk based on the Clustered Primary Key. Inserting non-sequential random UUIDv4 strings forces arbitrary page insertions, triggering high rates of B-Tree page splits (50% fragmentation) and massive random I/O. DBA-Architect enforces sequential UUIDv7 or BIGINT AUTO_INCREMENT.
The command is fully idempotent. It safely overwrites adapter files to match the latest template version while preserving any custom changes if your project already contains customized rules.
๐ก๏ธ Security Policy & Guardrails
DBA-Architect operates strictly under static, read-only analysis principles:
Zero Production Execution: DBA-Architect does not connect to live production databases or execute destructive DDL directly. It outputs verified DDL scripts and runbooks for human review.
Sensitive File Protection: Built-in file traversal guardrails automatically reject access to
.env, private keys (.pem,.key), certificates, and.gitfiles.Data Privacy & Masking: Query scanners automatically mask literals and personal identifiers (
PII) before analyzing query structures.
๐ License
This project is licensed under the MIT License. See the LICENSE file for details.
SPDX-License-Identifier: MIT
Available Tools
8 toolsanalyze_explain_planB
Parse PostgreSQL or MySQL EXPLAIN / EXPLAIN (ANALYZE, BUFFERS) output (Text or JSON) to identify execution bottlenecks (Seq Scan, External Disk Sort, Heap Fetches, Row Misestimations) and generate a Mermaid plan flowchart.
Inputs: dialect (required), explain_output (required), sql_query, existing_schema_ddl.
analyze_migrationB
Audit SQL DDL statements, migration files, or migration directory against DBA best-practice rules (data types, unindexed FKs, locking DDL hazards, 1NF, alignment padding) for PostgreSQL or MySQL.
Inputs: dialect (required), migration_source (required), strictness, engine_version.
analyze_transaction_and_lockingB
Audit SQL or application transaction blocks to detect Lost Update race conditions (missing FOR UPDATE), external HTTP/network calls inside open transactions, and deadlock risks.
Inputs: source (required), dialect (required).
calculate_db_capacity_and_configB
Estimate physical row size, heap/clustered table footprint, and B-Tree index memory requirements for N million rows, and generate tuned postgresql.conf or my.cnf parameters.
Inputs: dialect (required), schema_ddl, server_hardware, estimated_rows_per_table.
plan_zero_downtime_migrationB
Transform blocking or hazardous DDL statements into a safe Multi-Phase Expand & Contract zero-downtime migration runbook for large production tables.
Inputs: dialect (required), ddl_statements (required), engine_version, estimated_table_rows.
recommend_indexes_for_queriesB
Analyze raw SQL queries (including JOINs, CTEs, subqueries) using the ESR (Equality, Sort, Range) rule to recommend composite, covering, partial, and expression indexes, detect non-sargable predicates, and find redundant left-prefix indexes.
Inputs: dialect (required), queries (required), cardinality_hints, existing_schema_ddl, +1 more.
recommend_partitioning_and_archivingC
Design declarative table partitioning (RANGE, LIST, HASH), validate composite Primary Key constraints (PART-PK-001), and generate zero-bloat partition detach/drop retention runbooks.
Inputs: dialect (required), table_ddl (required), estimated_total_rows (required), retention_months, +2 more.
scan_project_queriesB
Statically scan a codebase directory to extract raw SQL and ORM/Query Builder patterns (Go, PHP/Laravel, TS/Prisma, Python), detect N+1 query loops, mask PII literals, and synthesize a holistic consolidated index plan per table.
Inputs: dialect (required), project_root_path (required), focus_tables, exclude_globs, +4 more.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogโฆ
TDQS
Scored across 8 tools
Most tools target clearly distinct artifacts: partitioning design, capacity math, DDL audit, index recommendation from raw SQL, codebase scanning, EXPLAIN parsing, zero-downtime transforms, and transaction auditing. The only close pairs are analyze_migration vs plan_zero_downtime_migration (audit vs transform) and recommend_indexes_for_queries vs scan_project_queries (input is raw SQL vs a codebase directory) โ descriptions do disambiguate these, but an agent could still momentarily hesitate.
Every tool follows snake_case verb_noun structure (recommend_*, calculate_*, analyze_*, scan_*, plan_*), with action verbs leading the name consistently. Some names are long compound phrases but the convention is uniform throughout.
Eight tools is well within a healthy range and each covers a distinct, non-trivial DBA capability (partitioning, sizing, migration audit, indexing, codebase scan, EXPLAIN, zero-downtime, locking). No redundant or filler tools are present.
The surface covers the performance-and-schema-architecture lifecycle thoroughly โ from query/index analysis through migration safety to partitioning and capacity planning. Notable gaps exist in operational areas like backup/restore, replication, vacuum/bloat monitoring, and role/permission management, though these may fall outside the server's stated design-audit scope.
Maintenance
Related MCP Connectors
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Review your AI agent's database changes on your schema, with plain-language risk, before they run.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Guard AI agents' PostgreSQL/MySQL access via MCP: SQL audit, auth, masking, write approval
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to interact with PostgreSQL databases through schema intelligence, query execution, and DBA tooling including index analysis and health monitoring. Features configurable access levels and audit logging for secure database operations.432 npmMIT
- AlicenseAqualityDmaintenanceEnables AI agents to analyze, optimize, and safely interact with PostgreSQL databases, including health checks, index recommendations, query planning, and SQL execution with read-only and production protection modes.15MIT
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to monitor and operate PostgreSQL databases through natural language queries, covering performance analysis, bloat detection, lock/deadlock monitoring, autovacuum and schema inspection, and maintenance recommendations with read-only, extension-optional workflows across PostgreSQL 12โ18.-
- FlicenseNot gradedqualityAmaintenanceEnables AI assistants to perform PostgreSQL operations and monitoring through natural language, including performance analysis, bloat detection, lock/deadlock monitoring, autovacuum inspection, schema discovery, and maintenance recommendations with production-safe read-only tools across PostgreSQL 12โ18.-