MySQL AIops

io.github.AIops-tools由 GitHub 帳號 AIops-tools 發布v0.13.0更新於 Oct 30, 2026

Governed MySQL/MariaDB DBA ops: slow-query, lock-wait, replication & fragmentation RCA; 35 tools.

已驗證STDIO僅桌面資料庫雲端與基礎設施

概覽

AI 產生的概覽

針對 MySQL/MariaDB 的受治理 DBA 維運伺服器,提供 35 個具稽核的工具,用於診斷、根因分析與受控寫入。

可以做什麼
  • 檢視伺服器狀態:版本、變數、狀態、資料庫、儲存引擎、連線統計
  • 檢查活動:工作階段、長時間查詢、交易、鎖定等待
  • 分析查詢與索引:最耗時的語句摘要、EXPLAIN 執行計畫、未使用與重複索引
  • 檢查資料表與複寫:資料表大小、碎片、資料表狀態、副本與 binlog 狀態
  • 執行旗艦根因分析:慢查詢、鎖定等待與死結、複寫延遲、資料表碎片
  • 執行受控寫入:終止工作階段或查詢、建立或刪除索引、最佳化或分析資料表、設定全域變數、重設查詢統計,以及列出或套用復原記錄
適用情境
適合讓助理診斷 MySQL 8.x 或 MariaDB 10.6+ 的效能問題,例如慢查詢、鎖定競爭、複寫延遲與資料表膨脹,並在具稽核記錄、盡可能可復原的前提下執行維護操作。不適用於 PostgreSQL、應用程式 schema 遷移或 ORM 管理。
執行需求
以 PyPI 套件 mysql-aiops 透過 stdio 在本機執行,通常使用 uvx 或 uv tool install。需要可連線的 MySQL/MariaDB 帳號,並以 init 精靈設定目標;帳號密碼以加密方式儲存,透過 MYSQL_AIOPS_MASTER_PASSWORD 或互動式提示解鎖。top_queries 與 slow_query_rca 需要開啟 performance_schema,讀取帳號需具備 PROCESS、REPLICATION CLIENT 以及對 performance_schema 的 SELECT 權限。選用變數:MYSQL_AIOPS_HOME、MYSQL_AUDIT_APPROVED_BY、MYSQL_RUNAWAY_MAX、MYSQL_MAX_TOOL_CALLS、MYSQL_MAX_TOOL_SECONDS。
安裝前請注意
寫入類工具可以終止工作階段或查詢、刪除索引、執行 OPTIMIZE/ANALYZE TABLE、修改全域變數與重設查詢統計;其中多項不可逆,只會留下記錄而無法復原。沒有唯讀開關或核准關卡,應以限制所連帳號的權限來控制風險。主密碼用於解鎖加密憑證庫,匯出到環境變數會暴露給子程序與 shell 歷史紀錄。每次呼叫都會寫入本機稽核資料庫,且本專案與 Oracle 及 MariaDB 基金會並無關聯。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 MySQL AIops,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

MySQL AIops

Audit availability: Real writes require a committed pending audit row and stop before contacting the platform if storage is unavailable. Reads and previews may continue with a warning; new audit rows store outcome summaries rather than full responses.

Disclaimer: Community-maintained open-source project. Not affiliated with, endorsed by, or sponsored by Oracle Corporation or the MariaDB Foundation. "MySQL" is a trademark of Oracle Corporation; "MariaDB" is a trademark of MariaDB plc; all product/trademark names belong to their respective owners. MIT licensed.

Governed AI-ops for MySQL 8.x and MariaDB 10.6+ DBA operations — connecting to a server with PyMySQL and reading information_schema / performance_schema — with a built-in governance harness: unified audit log, token/runaway budget guard, undo-token recording, and descriptive risk-tier labels. The server flavor (mysql vs mariadb) is detected from version() and flavor-dependent statements branch automatically (SHOW REPLICA STATUS vs SHOW SLAVE STATUS).

What it does

Four flagship signature analyses, plus the guarded reads and writes around them:

  • Slow-query RCA — take the worst events_statements_summary_by_digest entry (plus an optional EXPLAIN FORMAT=JSON plan) and map its numbers — no-index share (SUM_NO_INDEX_USED), lock-time share, rows-examined/sent ratio, tmp-disk spill, call count, plan access types — to a cited cause and a concrete action. Every finding carries its measured number, not a black-box verdict.
  • InnoDB lock-wait & deadlock chain RCA — build the wait-for tree from performance_schema.data_lock_waits (MariaDB: information_schema.innodb_lock_waits), name the root blocker (blocks others, waits on none), and parse the last deadlock out of SHOW ENGINE INNODB STATUS.
  • Replication lag RCA — map the replica's IO/SQL thread state, Seconds_Behind_Source and error fields to a cited cause + action (stopped IO thread, failed applier statement, lagging applier, intentional SQL_Delay).
  • Table fragmentation analysis — rank tables by reclaimable data_free from information_schema.tables into cited OPTIMIZE TABLE candidates.

What works

  • CLI (mysql-aiops ...): init, overview, server, activity, query, index, table, repl, analyze, remediate, secret, doctor, mcp.
  • MCP server (mysql-aiops mcp or mysql-aiops-mcp): 35 tools (26 read, 9 write), every one wrapped with the bundled @governed_tool harness.
  • Encrypted credentials: the account password lives in an encrypted store ~/.mysql-aiops/secrets.enc (Fernet + scrypt) — never plaintext on disk. Unlock with a master password from MYSQL_AIOPS_MASTER_PASSWORD (MCP/CI) or an interactive prompt (CLI).
  • Reversibility: mutating writes fetch the real before-state first and record a faithful inverse — create_index↔drop_index; drop_index captures the index definition out of SHOW CREATE TABLE so undo recreates it exactly; set_global_variable captures the prior value from SHOW GLOBAL VARIABLES so undo sets it back. Irreversible ops (kill_session, kill_query, optimize_table, analyze_table, reset_query_stats) record prior state for audit but declare no undo.
  • Safety: every state-changing CLI op supports --dry-run and requires double confirmation; every write MCP tool takes a dry_run preview. All identifiers that cannot be parameterised (schema/table/index/column/variable names) are validated against a strict charset and backtick-quoted; all values are bound query parameters.

What this tool does, and does not, decide

It delivers MySQL / MariaDB DBA operations — reads and writes — accurately and efficiently, and records every one of them. It does not decide whether a write is allowed to happen. That is the agent's judgement, or the permission of the account you connect it with: point it at a MySQL/MariaDB account granted only SELECT / PROCESS / REPLICATION CLIENT and no write privileges (no INSERT/UPDATE/DELETE/DDL), and the writes fail at the server — the place that actually owns the permission.

So there is no read-only switch, no policy file, no approval gate to configure. The one thing the tool guarantees is that nothing is silent: every call, over MCP and over the CLI alike, lands an audit row in ~/.mysql-aiops/audit.db, and destructive writes still capture their before-state and record an inverse where one exists.

Each tool declares a risk_level, carried into the audit row as a descriptive tier (none/confirm/review) — so a reviewer can see at a glance that a row was a high-risk delete. It is a label, not a gate.

Running a smaller / local model? See agent-guardrails.md — it lists the guardrails this tool now enforces for you (so you don't spend prompt budget restating them) and gives a ready-made system prompt for what's left.

Capability matrix (35 MCP tools)

DomainToolsCountR/W
Overviewoverview1read
Serverserver_version, show_variables, show_status, list_databases, list_engines, connection_stats6read
Activitylist_sessions, long_running_queries, list_transactions, lock_waits4read
Queriestop_queries, explain_query2read
Indexesunused_indexes, redundant_indexes, index_stats3read
Tablestable_sizes, table_fragmentation, table_status3read
Replicationreplica_status, binlog_status2read
Analysis (flagship)slow_query_rca, lock_wait_rca, replication_lag_rca, fragmentation_analysis4read
Writeskill_session, kill_query, drop_index3write (high)
optimize_table, analyze_table, create_index, set_global_variable, reset_query_stats5write (medium)
Undoundo_list, undo_apply2read / write

The flagship analyses accept injected records for pure/offline analysis, or pull live from a configured target. top_queries/slow_query_rca require performance_schema=ON; the read account should have PROCESS, REPLICATION CLIENT and SELECT on performance_schema.

Support scope

PlatformStatus
MySQL 8.0 / 8.4targeted (SHOW REPLICA STATUS, performance_schema.data_lock_waits)
MariaDB 10.6+ / 11.xtargeted (SHOW SLAVE STATUS, information_schema.innodb_lock_waits)
MySQL 5.7 and oldernot targeted (EOL; pre-8.0 digest/lock views untested)
Cloud-managed MySQL (RDS/Aurora/Cloud SQL flavors)wire-compatible reads should work; managed restrictions (KILL, SET GLOBAL) apply — untested

Quick start

As a Claude Code plugin

One install gives an agent both the skill and the MCP server:

/plugin marketplace add AIops-tools/marketplace/plugin install mysql-aiops@aiops-tools

The MCP server is fetched with uv and pinned to the package version this plugin declares, so an audit row can be traced back to the code that wrote it. Credentials are still configured with mysql-aiops init — see below.

As an OpenClaw plugin

The same bundle is published on ClawHub, where one install delivers the skill and its MCP server together:

bash
openclaw plugins install clawhub:@zw008/mysql-aiopsopenclaw skills info mysql-aiops          # expect: Visible to model: yes

Restart the OpenClaw gateway afterwards so it loads the plugin. The MCP server is fetched with uv, pinned to this exact release, so uvx has to be on PATH — without it the skill still installs but reports Visible to model: no. Credentials are configured exactly as below.

As a CLI or standalone MCP server

bash
uv tool install mysql-aiops             # or: pipx install mysql-aiopsmysql-aiops init                        # wizard: add a target + store the password (encrypted)mysql-aiops doctor                      # verify config, secrets, connectivity, flavor, perf-schemamysql-aiops overview                    # one-shot server health snapshotmysql-aiops analyze slow-query          # RCA the worst statement digestmysql-aiops analyze fragmentation       # OPTIMIZE TABLE candidates

Run as an MCP server (stdio):

bash
export MYSQL_AIOPS_MASTER_PASSWORD=...  # unlock secrets non-interactivelymysql-aiops-mcp

Where that password then lives: an exported variable is readable by every process this shell starts and is recorded by shell history. On a shared or long-lived host, prefer the interactive prompt, or inject it from a secret manager for the life of the one command that needs it.

Claude Desktop / MCP client config:

json
{  "mcpServers": {    "mysql-aiops": {      "command": "uvx",      "args": ["--from", "mysql-aiops", "mysql-aiops-mcp"],      "env": { "MYSQL_AIOPS_MASTER_PASSWORD": "your-master-password" }    }  }}

Env-block caveat: the env block above is the only environment the MCP server sees — GUI-launched clients do not inherit your shell profile. Put MYSQL_AIOPS_MASTER_PASSWORD (and MYSQL_AIOPS_HOME / MYSQL_AUDIT_APPROVED_BY if you use them) there, or the server cannot unlock the secret store.

Governance

Every MCP tool passes through the bundled @governed_tool harness:

  • Audit — every call (params, outcome summary, status, duration, risk tier, and any operator-supplied approver/rationale) is logged to ~/.mysql-aiops/audit.db (relocatable via MYSQL_AIOPS_HOME). The CLI writes the same row the MCP path does — there is no unaudited entry point.
  • Runaway guard — a safety backstop, not an authorization gate: the same call hammered in a tight loop trips a circuit breaker. Disable with MYSQL_RUNAWAY_MAX=0; optional hard ceilings via MYSQL_MAX_TOOL_CALLS / MYSQL_MAX_TOOL_SECONDS.
  • Undo recording — reversible writes record an inverse descriptor built from the fetched before-state.
  • Risk tier — a descriptive label on the audit row derived from risk_level; it gates nothing.

Scope

This is the MySQL / MariaDB DBA-ops member of the AIops-tools family (governed AI-ops with audit + budget + undo + risk tiers). Do NOT use it for PostgreSQL — use postgres-aiops. Do NOT use it for OT / industrial edge — see the separate industrial-aiops line — nor for application-schema migrations or ORM management.

Missing a capability?

Coverage is intentionally a curated subset of MySQL's catalogs and maintenance surface. Missing a view, a metric, or a maintenance command? Open an issue or PR — contributions welcome. 缺功能提 issue/PR 欢迎留言。

Verification status

Live-verified against MySQL 8.4.10 and MariaDB 11.8.8 (2026-07-19/20). Connectivity, the reads, analyze slow-query on genuine full scans, and the full governance loop (real create_index → audit row → undo actually dropping it) were exercised against a real server. That run found and fixed a real bug the mock suite could not see: SUM() aggregates come back as Decimal, which is not JSON serializable.

The MariaDB branch is now verified too, including analyze lock-waits against real row contention (it correctly identified the root blocker and the measured wait). Replication against a real replica remains unverified.

docs/VERIFICATION.md records exactly what was checked and what is still open. mysql-aiops doctor is the fastest live check (connectivity, flavor, performance_schema, replica role).

來源:README.md,提交 07f0977

工具

0
SourceWeft 曾在隔離沙箱中以無憑證方式啟動該軟體包一次,以列出其工具,但未能完成:伺服器未能啟動。

版本歷史

5
  1. v0.13.0最新Oct 30, 2026
  2. v0.12.0Oct 15, 2026
  3. v0.11.0Oct 15, 2026
  4. v0.10.4Sep 17, 2026
  5. v0.10.3Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分