![]()
MySQLTuner is one of the most widely trusted open-source command-line utilities for auditing and optimizing database servers. Written in Perl, its simplicity, zero external dependency design, and direct, actionable advice have made it a staple in the toolkit of Database Administrators (DBAs), DevOps engineers, and system administrators worldwide.
In the latest release, MySQLTuner v2.9.1, the project takes a massive leap forward by introducing AI-driven database auditing and deep diagnostics for enterprise and high-availability (HA) topologies. This release bridges the gap between traditional command-line diagnostics and modern AI agent workflows by exposing a built-in Model Context Protocol (MCP) server and a structured JSON output mode.
Here is a deep dive into the major new features, architectural changes, and performance diagnostics that shape this landmark release.
1. Bridging the Gap to AI: Structured JSON and the MCP Server
The most significant architectural shift in version 2.9.1 is making MySQLTuner tool-use friendly for Artificial Intelligence and large language models (LLMs). Traditional MySQLTuner output is optimized for human readability in a terminal, which is difficult for AI agents to parse reliably.
To solve this, version 2.9.1 introduces two key features:
- AI-Focused JSON Output (
--agent-json): This new CLI option suppresses human-oriented text formatting and emits structured, machine-readable JSON. Each finding is enriched with metadata, including a unique ID, database topic, impact/risk scores, and crucially, rollback SQL statements. - Model Context Protocol (MCP) Server (
build/mcp_server.py): MySQLTuner now includes a native MCP stdio server. This protocol allows AI agents (like Claude or Custom GPTs) to invoke audits, retrieve cached reports, apply safe SQL recommendations, and perform rollbacks programmatically using a state file.
Sequence Diagram: Agent and MCP Server Interaction
The diagram below illustrates how an AI Agent interacts with the MySQLTuner MCP server to audit a database, apply a performance recommendation, and perform a rollback if needed:

This interaction makes database tuning fully autonomous, enabling AI agents to safely monitor, adjust, and rollback database performance settings with zero human intervention.
2. Deep InnoDB and High-Availability Diagnostics
Beyond AI integration, MySQLTuner v2.9.1 significantly hardens and expands its core diagnostic capabilities, marking several roadmap phases as fully completed:
A. Deep InnoDB Internals (Phase 6 Complete)
DBAs running large-scale workloads can now monitor deep InnoDB metrics directly:
* I/O Pressure & Purge Lag: Checks read-ahead efficiency and purge lag to prevent log space exhaustion.
* Cache Alignment: Audits the change buffer and Adaptive Hash Index (AHI) guidance to prevent lock contention.
* Physical Alignment: Verifies doublewrite buffer, fdatasync, and flush alignment.
* OS Interleaved Tuning: Detects NUMA node interleaving and warns if memory allocation is sub-optimal.
* MariaDB Adjustments: Custom checks for MariaDB temporary tablespaces and deadlock counting via performance_schema.
B. HA InnoDB Cluster Diagnostics (Phase 7 Complete)
MySQLTuner now natively detects and audits High-Availability InnoDB Clusters:
* Analyzes replication_group_members and member_stats from performance_schema.
* Audits replication message cache vs. system RAM.
* Verifies unreachable_majority_timeout and detects MySQL Router configurations.
C. Advanced Replication & GTID Consistency (Phases 8 & 10 Complete)
Modern replica setups benefit from advanced checks:
* GTID Gap Audits: Scans for consistency gaps across the cluster.
* Relay Log Hardening: Audits and recommends settings like replica_skip_verify_binlog_checksum to prevent corruption.
* Dependency Tracking: Inspects parallel workers and write-set dependency tracking configuration.
* Binlog Compression & Cache: Measures binary log cache efficiency and verifies compression ratios.
* Modern Terminology: Prominently transitions all terminology to source/replica (while parenthetically retaining legacy master/slave variable mappings).
D. Galera & Percona XtraDB Cluster (PXC) Checks (Phase 9 Complete)
Galera cluster audits are deeply expanded with version 2.9.1:
* Measures streaming replication performance and certifications/abort statistics.
* Audits gcache sizing (using a new parse_size_bytes helper) and applier concurrency.
* Checks PXC strict mode compliance, flow control, and latency/jitter indicators.
3. Workload Characterization and Log Correlation (Phase 12 Complete)
Audits are now context-aware thanks to a new workload profiling engine (check_workload_traffic):
* Fingerprinting Wait Events: Analyzes database bottlenecks and wait events.
* Table Churn vs. Fragmentation: Tries to identify tables with high write churn that require frequent optimization.
* Auto-Increment Exhaustion: Scans key tables to alert DBAs before primary key auto-increment limits are reached.
* Log Error Parsing: Hardens log_error_verbosity/log_warnings audits and correlates OOM (Out Of Memory) kills, semaphore hangs, file-limit warnings, and corruption patterns to database load stats.
4. Engineering Quality: Linter & E2E HA Testing Harness
To support these complex additions without introducing regressions, version 2.9.1 integrates modern engineering pipelines:
- SQL Linter (
check_sql_linter.pl): A custom static analyzer scans the MySQLTuner codebase for SQL syntax issues, checking keyword casing, parenthesis balance, and preventing dangerous SQL commands. - HA End-to-End Test Harness (
build/test_ha.sh): Orchestrates multi-container Docker environments to automatically build, validate, and tear down Galera, replication, and InnoDB Cluster topologies, running automated checks on MySQLTuner’s diagnostic output. - Slow Query Log Detection Fix: Addresses issue
#517by refining how boolean states like'0'or'OFF'are evaluated, preventing false positives.
Conclusion
MySQLTuner v2.9.1 is a milestone release that transforms a classic CLI utility into an AI-ready automation tool. Whether you are using an AI agent to tune a single database via the MCP server, managing complex Galera or InnoDB Clusters, or auditing deep InnoDB memory pressure, version 2.9.1 provides the tools you need.
Update to v2.9.1 today, deploy the MCP server, and step into the future of AI-driven database operations!