mysql-aiops
Server Configuration
Describes the environment variables required to run the server.
| Name | Required | Description | Default |
|---|---|---|---|
| MYSQL_AIOPS_HOME | No | Directory for audit.db and secrets.enc. Defaults to ~/.mysql-aiops. | |
| MYSQL_RUNAWAY_MAX | No | Maximum number of consecutive calls before the runaway guard circuit breaker trips. Set to 0 to disable. | |
| MYSQL_MAX_TOOL_CALLS | No | Optional hard ceiling on total tool calls. | |
| MYSQL_MAX_TOOL_SECONDS | No | Optional hard ceiling on total tool execution seconds. | |
| MYSQL_AUDIT_APPROVED_BY | No | Operator-supplied identifier recorded in audit rows as the approver/rationale. | |
| MYSQL_AIOPS_MASTER_PASSWORD | Yes | Master password to unlock the encrypted secrets store (~/.mysql-aiops/secrets.enc). Required for non-interactive MCP server operation. |
Instructions
Guidance the server publishes about itself, which clients place ahead of the tool catalog so the model reads it before choosing anything.
Governed MySQL / MariaDB DBA operations: a one-shot server 'overview'; server reads (version+flavor/variables/status/databases/engines); activity (sessions, long-running queries, open transactions, lock waits); query stats (statement-digest top-N, EXPLAIN); index and table health (unused / redundant / fragmentation); replication (replica status, binlog); four flagship analyses — 'slow_query_rca', 'lock_wait_rca', 'replication_lag_rca' and 'fragmentation_analysis'; and guarded writes (kill session/query, optimize/analyze table, create/drop index, SET GLOBAL). Every tool runs through the mysql-aiops governance harness (audit / budget / risk-tier / undo). Do NOT use for OT/industrial edge — see industrial-aiops.
Capabilities
Features and capabilities supported by this server
Protocol revision2025-11-25
| Capability | Details |
|---|---|
| tools | {
"listChanged": false
} |
| prompts | {
"listChanged": false
} |
| resources | {
"subscribe": false,
"listChanged": false
} |
| experimental | {} |
Tools
Functions exposed to the LLM to take actions
| Name | Description |
|---|---|
| list_sessionsA | [READ] Current sessions (processlist) with per-command counts. Flags sleeping sessions (connection-pool leak suspects). Args: include_sleeping: Include sessions in command=Sleep (default True). target: Target name from config; omit for the default. |
| long_running_queriesA | [READ] Active statements running at least Args: min_seconds: Minimum age in seconds (default 60). target: Target name from config; omit for the default. |
| list_transactionsA | [READ] Open InnoDB transactions, oldest first (stuck-transaction hunting). Args: target: Target name from config; omit for the default. |
| lock_waitsA | [READ] InnoDB wait-for edges (blocked session -> blocking session). Reads performance_schema.data_lock_waits on MySQL 8.x, or information_schema.innodb_lock_waits on MariaDB (flavor-branched). Args: target: Target name from config; omit for the default. |
| slow_query_rcaA | [READ] RCA for the worst statement digest, with cause + action. Picks the digest with the greatest total time and maps its numbers (no-index share, lock-time share, examined/sent ratio, tmp-disk spill, calls) — plus an optional EXPLAIN plan — to cited causes and concrete actions. Pass 'statements' for pure/offline analysis, or omit to pull the top digests live from performance_schema. Args: statements: Injected digest rows (as from top_queries); if omitted, the worst statements are pulled live. explain_sql: Optional SQL to EXPLAIN so plan access types feed the RCA. limit: How many statements to pull when not injected (default 20). target: Target name from config; omit for the default. |
| lock_wait_rcaA | [READ] Build the InnoDB wait-for tree, name the root blocker, and parse the last deadlock out of SHOW ENGINE INNODB STATUS. Pass 'pairs' (as from lock_waits) for pure/offline analysis, or omit to pull the current lock-wait graph live. Args: pairs: Injected lock-wait pairs {blockedId, blockingId, ...}; if omitted, pulled live (flavor-branched). include_deadlock: Also parse the LATEST DETECTED DEADLOCK section from SHOW ENGINE INNODB STATUS (default True). target: Target name from config; omit for the default. |
| replication_lag_rcaA | [READ] Map replica thread state / lag / error fields to cause + action. Pass 'status' (as from replica_status) for pure/offline analysis, or omit to pull the live replica status (flavor-branched). Args: status: Injected replica status record; if omitted, pulled live. target: Target name from config; omit for the default. |
| fragmentation_analysisA | [READ] Rank tables by reclaimable data_free into OPTIMIZE TABLE candidates. Pass 'tables' (as from table_fragmentation) for pure/offline analysis, or omit to pull the worst-fragmented tables live. Each recommendation cites its numbers. Args: tables: Injected fragmentation rows; if omitted, pulled live. limit: How many tables to pull when not injected (default 50). target: Target name from config; omit for the default. |
| unused_indexesA | [READ] Secondary indexes with zero I/O events since restart (drop candidates). From performance_schema.table_io_waits_summary_by_index_usage — counters reset on server restart, so confirm over a full business cycle. Args: target: Target name from config; omit for the default. |
| redundant_indexesB | [READ] Indexes whose columns are a leading prefix of another index (dupes). Args: target: Target name from config; omit for the default. |
| index_statsA | [READ] Per-index column lists and cardinality (selectivity screening). Args: target: Target name from config; omit for the default. |
| top_queriesA | [READ] Top statement digests from performance_schema by a whitelisted metric. Args: order_by: One of total_time, mean_time, calls, rows_examined, lock_time, no_index. limit: Number of statements to return (1..200, default 20). target: Target name from config; omit for the default. Returns an envelope: {"statements": [...], "returned": N, "limit": L, "truncated": bool}. When "truncated" is true there is more beyond what was returned — re-run with a higher limit rather than treating this as the complete picture. |
| explain_queryA | [READ] Return the JSON execution plan for The statement is planned, not executed. Args: sql: A single SQL statement to EXPLAIN. target: Target name from config; omit for the default. |
| reset_query_statsA | [WRITE][risk=medium] Reset statement-digest accumulators (irreversible). Truncates performance_schema.events_statements_summary_by_digest; the counters cannot be restored, so no undo is recorded. Pass dry_run=True to preview. Args: dry_run: If True, preview without resetting. target: Target name from config; omit for the default. |
| kill_sessionA | [WRITE][risk=high] Terminate a session (KILL CONNECTION). No safe inverse. Captures the session's user/host/query for the audit trail; a kill cannot be undone, so no undo is offered. Pass dry_run=True to preview. Refuses this tool's own session id — including under dry_run, which must report a refusal rather than preview a call that will be refused. Args: session_id: Session/connection id (from list_sessions). dry_run: If True, preview without killing. target: Target name from config; omit for the default. |
| kill_queryA | [WRITE][risk=high] Cancel a session's running statement (KILL QUERY). No inverse. The session stays connected; only its current statement is aborted. Captures the session's user/host/query for audit. Pass dry_run=True to preview. Refuses this tool's own session id — the statement it would cancel is this very call. Enforced under dry_run too. Args: session_id: Session/connection id (from list_sessions). dry_run: If True, preview without cancelling. target: Target name from config; omit for the default. |
| optimize_tableA | [WRITE][risk=medium] OPTIMIZE TABLE (rebuild, reclaim data_free). Records prior stats. No undo (a rebuild has no inverse); the prior size/fragmentation stats are captured for the audit trail. InnoDB maps this to ALTER TABLE ... FORCE (online DDL, brief locks) — schedule off-peak for hot tables. Pass dry_run=True to preview. Args: table: Table name (optionally schema-qualified, e.g. shop.orders). dry_run: If True, preview without running. target: Target name from config; omit for the default. |
| analyze_tableA | [WRITE][risk=medium] ANALYZE TABLE to refresh index statistics. No undo; captures prior stats for audit. Takes a brief read lock while sampling. Pass dry_run=True to preview. Args: table: Table name (optionally schema-qualified). dry_run: If True, preview without running. target: Target name from config; omit for the default. |
| create_indexA | [WRITE][risk=medium] Create an index. Reversible: undo drops the created index. The created (table, name) is returned so the harness records an undo that
drops exactly this index. Pass dry_run=True to preview. Alternatively pass
Args:
table: Table to index (optionally schema-qualified). Required unless
|
| drop_indexA | [WRITE][risk=high] Drop an index. Reversible: captures its definition first. Before dropping, the exact index definition is rebuilt from SHOW CREATE TABLE so the harness records an undo that recreates it. Pass dry_run=True to preview. Args: table: Table the index belongs to (optionally schema-qualified). name: Index name to drop. dry_run: If True, preview without dropping. target: Target name from config; omit for the default. |
| set_global_variableA | [WRITE][risk=medium] SET GLOBAL a server variable. Reversible: captures prior value. Runtime-only: the change does not survive a restart (persist it in my.cnf — or SET PERSIST on MySQL 8 — yourself); reported but NOT performed automatically. The prior value (from SHOW GLOBAL VARIABLES) is captured so the harness records an undo that sets it back. Pass dry_run=True to preview. Refuses the globals that would lock this tool out of the server (init_connect, max_connections, max_user_connections, read_only, super_read_only, skip_networking, require_secure_transport, and wait_timeout/interactive_timeout below 30s). SET GLOBAL is immediate, so those strand the undo. Enforced under dry_run too. Args: name: The global variable name (e.g. max_connections). value: The new value (as a string). dry_run: If True, preview without changing. target: Target name from config; omit for the default. |
| replica_statusA | [READ] Replica thread state and lag (SHOW REPLICA/SLAVE STATUS, flavor-branched). Empty on a primary/standalone server. MySQL 8.x uses SHOW REPLICA STATUS; MariaDB uses SHOW SLAVE STATUS — the result is normalised either way. Args: target: Target name from config; omit for the default. |
| binlog_statusB | [READ] Binary-log configuration, GTID mode, and connected downstream replicas. Args: target: Target name from config; omit for the default. |
| overviewA | [READ] One-shot server health snapshot. Version + flavor (mysql/mariadb) + uptime, connection headroom vs max_connections, sessions by command, the longest-running query, the most fragmented table, and the replica role — each section captured defensively so one failing probe does not sink the rest. Args: target: Target name from config; omit for the default. |
| server_versionB | [READ] Server version, flavor (mysql/mariadb), uptime and read-only state. Args: target: Target name from config; omit for the default. |
| show_variablesA | [READ] Global variables (SHOW GLOBAL VARIABLES). Args: pattern: Optional substring to filter variable names (e.g. 'innodb_buffer', 'max_connections'). target: Target name from config; omit for the default. |
| show_statusB | [READ] Global status counters (SHOW GLOBAL STATUS). Args: pattern: Optional substring to filter counter names (e.g. 'Threads', 'Innodb_buffer_pool'). target: Target name from config; omit for the default. |
| list_databasesA | [READ] User schemas with table count and data/index size (largest first). Args: target: Target name from config; omit for the default. |
| list_enginesA | [READ] Storage engines and which is the default (SHOW ENGINES). Args: target: Target name from config; omit for the default. |
| connection_statsA | [READ] Connection counters vs max_connections (exhaustion early warning). Args: target: Target name from config; omit for the default. |
| table_sizesA | [READ] Largest tables by data + index size. Args: limit: Number of tables to return, largest first (default 20). target: Target name from config; omit for the default. Returns an envelope: {"tables": [...], "returned": N, "limit": L, "truncated": bool}. When "truncated" is true there is more beyond what was returned — re-run with a higher limit rather than treating this as the complete picture. |
| table_fragmentationA | [READ] data_free per table (space OPTIMIZE TABLE could reclaim), worst first. Args: limit: Number of tables to inspect (default 50). target: Target name from config; omit for the default. Returns an envelope: {"tables": [...], "returned": N, "limit": L, "truncated": bool}. When "truncated" is true there is more beyond what was returned — re-run with a higher limit rather than treating this as the complete picture. |
| table_statusA | [READ] Per-table engine, row format, row estimate and last update time. Flags non-InnoDB tables (no row-level locking / crash recovery). Args: limit: Number of tables to inspect (default 50). target: Target name from config; omit for the default. Returns an envelope: {"tables": [...], "returned": N, "limit": L, "truncated": bool}. When "truncated" is true there is more beyond what was returned — re-run with a higher limit rather than treating this as the complete picture. |
| undo_listA | [READ] List recorded, not-yet-applied undo tokens (most recent first). Each entry names the original tool, the inverse tool that Returns {"undos": [...], "returned": N, "limit": L, "truncated": bool}.
Each entry carries Args: limit: Max rows to return (default 50, capped at 500). target: Unused (undo state is host-local); accepted for CLI uniformity. |
| undo_applyA | [WRITE][risk=medium] Apply a recorded undo by dispatching its inverse tool. The inverse runs through its own governed tool, so its own risk tier and audit row are recorded there. Pass dry_run=True to preview the inverse call without executing it. A token can only be applied once. Args:
undo_id: The undoId from undo_list (or an |
Prompts
Interactive templates invoked by user choice
| Name | Description |
|---|---|
No prompts | |
Resources
Contextual data attached and managed by the client
| Name | Description |
|---|---|
No resources | |
TDQS
Scored across 35 tools
Most tools have clearly distinct purposes: kill_session vs kill_query, table_sizes vs table_fragmentation vs table_status, and the read/analysis pairs (lock_waits vs lock_wait_rca, top_queries vs slow_query_rca) are well separated, with descriptions explicitly cross-referencing each other. The main overlap is the one-shot 'overview' tool, which duplicates subsets of server_version, connection_stats, long_running_queries and table_fragmentation, creating mild redundancy an agent could stumble over.
Nearly all names are snake_case and readable, with a sensible convention of verb_noun for actions (kill_session, create_index, set_global_variable) and noun-phrase for reads (table_sizes, index_stats). Minor deviations exist (undo_list vs undo_apply, the single-word 'overview', and the 'rca' suffix group), but they are consistent within their families.
35 tools is on the heavy side for a single server and sits above the typical 3-15 range; several read probes (server_version, connection_stats, show_status) are partially subsumed by 'overview'. However, the breadth of the MySQL AIOps domain (health, sessions, locks, replication, indexes, fragmentation, queries, plus governed writes) means most tools target a genuinely distinct signal rather than padding.
Coverage is strong and coherent: a full read surface (status, variables, sessions, transactions, lock-wait/slow-query/replication RCA, index and fragmentation analysis, replication/binlog state) plus reversible writes (kill, optimize/analyze, create/drop index, set global variable, reset stats) backed by an undo framework. Gaps are minor for the AIOps scope: no replication-control actions (start/stop/promote replica) and no schema/table DDL beyond index operations.