スロークエリの根本原因分析、膨張(bloat)分析、ブロッキングロックチェーンの調査など、統制されたPostgreSQL DBA操作を提供します。
別名 AIops-tools/Postgres-AIops, postgres-aiops
- スター
- 0
- ツール
- —
- ダウンロード数(30日間)
- 724
- 最新バージョン
- 0.13.0
- 最終コミット
- 2026年10月30日
- ライセンス
- MIT
Postgres AIops MCPとは
スロークエリの根本原因分析、膨張(bloat)分析、ブロッキングロックチェーンの調査など、統制されたPostgreSQL DBA操作を提供します。
プロジェクトのREADMEから生成された概要
Postgres AIops MCP server について
Postgres AIopsは、PostgreSQL環境向けに統制されたデータベース管理機能を提供します。AIクライアントを通じて根本原因分析やメンテナンス作業を行う必要があるDBAや開発者向けに設計されています。このMCP serverは、psycopg 3を使用して対象のインスタンスに接続し、システムカタログやpg_statビューとやり取りします。統合監査ログ、ランナウェイ予算ガード、およびすべての操作に対するリスクティアラベルを提供する組み込みのガバナンスハーネスを備えています。
ユーザーは、スロークエリの根本原因分析、膨張(bloat)およびvacuum分析、ブロッキングロックチェーンの調査などの複雑な診断タスクを実行できます。このツールは、25個の読み取り専用ツールと10個の書き込みツールを含む、計35個のMCPツールを提供します。安全性を確保するため、create_indexやdrop_indexのような変更を伴う書き込みは、取り消し操作(undo)ができるように実行前の状態を記録します。認証情報はFernetとscryptを使用した暗号化ストアに安全に保管され、アクセスにはマスターパスワードが必要です。このシステムは、CLIでの使用とMCP serverモードの両方をサポートしており、Claude Codeなどのクライアントとの統合が可能です。
できること
- 1低速なデータベースクエリの分析pg_stat_statementsのデータを使用して、パフォーマンスの低いクエリの具体的な原因と必要なアクションを特定します。
- 2データベースのロック競合の調査wait-forツリー内の根本的なブロッキング要因を特定し、ブロッキングロックチェーンを解決します。
- 3テーブルの膨張とvacuumの管理デッドタプル比率に基づいて、vacuumの実行やautovacuumのチューニングに関する推奨事項をランク付けして取得します。
プロジェクトの README から作成されています。すべてのユースケースは、その引用と照らし合わせて確認されています。
Postgres AIops MCPのインストール方法
フォーマット検証日 2026年11月10日Cursor に追加Gooseに追加Claude CodeにPostgres AIops MCPをインストール
$ claude mcp add postgres-aiops -- uvx postgres-aiopsCursorにPostgres AIops MCPをインストール
~/.cursor/mcp.json
{
"mcpServers": {
"postgres-aiops": {
"command": "uvx",
"args": [
"postgres-aiops"
]
}
}
}VS CodeにPostgres AIops MCPをインストール
.vscode/mcp.json
{
"servers": {
"postgres-aiops": {
"type": "stdio",
"command": "uvx",
"args": [
"postgres-aiops"
]
}
}
}VS Code CLIにPostgres AIops MCPをインストール
$ code --add-mcp '{"name":"postgres-aiops","type":"stdio","command":"uvx","args":["postgres-aiops"]}'Claude DesktopにPostgres AIops MCPをインストール
claude_desktop_config.json
{
"mcpServers": {
"postgres-aiops": {
"command": "uvx",
"args": [
"postgres-aiops"
]
}
}
}CodexにPostgres AIops MCPをインストール
$ codex mcp add postgres-aiops -- uvx postgres-aiopsCodex config.tomlにPostgres AIops MCPをインストール
~/.codex/config.toml
[mcp_servers.postgres-aiops] command = "uvx" args = ["postgres-aiops"]
Gemini CLIにPostgres AIops MCPをインストール
$ gemini mcp add -s user postgres-aiops uvx -- postgres-aiopsGemini settings.jsonにPostgres AIops MCPをインストール
~/.gemini/settings.json
{
"mcpServers": {
"postgres-aiops": {
"command": "uvx",
"args": [
"postgres-aiops"
]
}
}
}設定
POSTGRES_AIOPS_MASTER_PASSWORD
| 名前 | 説明 | 種類 |
|---|---|---|
| POSTGRES_AIOPS_MASTER_PASSWORD | — |
自動チェック
実行日 2026年11月14日完全なレポート →自動チェックに合格しました。これはセキュリティ監査ではありません。コードを読み、サーバーに必要最小限のアクセス権を与えてください。 チェックの仕組み
- ソースリポジトリがリンクされており、アクセス可能aiops-tools/postgres-aiops is public and reachablegithub.com/aiops-tools/postgres-aiops ↗合格
- パッケージがこのリポジトリをソースとして指定未チェック
- ビルドの来歴 (Sigstore 証明)Sigstore attestation for postgres-aiopspypi.org/project/postgres-aiops/ ↗合格
- オープンソースライセンス (OSI)MITspdx.org/licenses/MIT.html ↗合格
- 過去1年以内にコミットまたはリリースありLast commit or release 2026-10-30github.com/aiops-tools/postgres-aiops ↗合格
- OpenSSF Scorecard未チェック
- パッケージ名が有名なパッケージに酷似していないNo popular package one edit away from postgres-aiops合格
- パッケージおよびその依存関係に重大な勧告なし40 resolved dependencies checked; no critical advisoryosv.dev ↗合格
- モデルへの隠れた指示がない0 tool descriptions and the README read; no override phrases, credential paths or hidden characters合格
- 破壊的なツールがラベル付けされている未チェック
- リモートエンドポイントが MCP ハンドシェイクに応答未チェック
README
GitHubで見るPostgres AIops
Audit availability: Real writes require a committed
pendingaudit 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 the PostgreSQL Global Development Group or any vendor. "PostgreSQL" and the elephant logo are trademarks of the PostgreSQL Community Association; all product/trademark names belong to their respective owners. MIT licensed.
Governed AI-ops for PostgreSQL DBA operations — connecting to a server with
psycopg 3 and reading the system catalogs and pg_stat_* views — with a
built-in governance harness: unified audit log, token/runaway
budget guard, undo-token recording, and descriptive risk-tier labels.
Beyond the mock test suite, the reads, a governed write, and its undo have been
exercised against a live PostgreSQL 16.14 instance — see docs/VERIFICATION.md.
What it does
Three flagship signature analyses, plus the guarded reads and writes around them:
- Slow-query RCA — take the worst
pg_stat_statementsentry (plus an optionalEXPLAINplan) and map its numbers — mean time, cache-hit ratio, temp spill, call count, plan node types — to a cited cause and a concrete action. Every finding carries its measured number, not a black-box verdict. - Bloat & vacuum analysis — combine per-table dead-tuple ratio and autovacuum recency into a ranked, cited recommendation (VACUUM / tune autovacuum).
- Blocking lock-chain RCA — build the wait-for tree from
pg_blocking_pids, name the root blocker (blocks others, waits on none), and give the action; a cycle is flagged as a likely deadlock.
What works
- CLI (
postgres-aiops ...):init,overview,server,activity,query,index,table,repl,analyze,remediate,secret,doctor,mcp. - MCP server (
postgres-aiops mcporpostgres-aiops-mcp): 35 tools (25 read, 10 write), every one wrapped with the bundled@governed_toolharness. - Encrypted credentials: the role password lives in an encrypted store
~/.postgres-aiops/secrets.enc(Fernet + scrypt) — never plaintext on disk. Unlock with a master password fromPOSTGRES_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_indexcapturespg_get_indexdefso undo recreates it exactly;update_settingcaptures the prior value so undo sets it back. Irreversible ops (terminate_backend,cancel_query,run_vacuum,run_analyze,reindex,reset_query_stats) record prior stats for audit but declare no undo. - Safety: every state-changing CLI op supports
--dry-runand requires double confirmation; every write MCP tool takes adry_runpreview. All identifiers that cannot be parameterised (table/index/GUC names) are validated and quoted; all values are bound query parameters.
Capability matrix (35 MCP tools)
| Domain | Tools | Count | R/W |
|---|---|---|---|
| Overview | overview |
1 | read |
| Server | server_version, show_settings, list_extensions, list_databases, list_roles |
5 | read |
| Activity | list_activity, long_running_queries, list_locks |
3 | read |
| Queries | top_queries, explain_query |
2 | read |
| Indexes | unused_indexes, missing_index_hints, index_bloat, invalid_indexes |
4 | read |
| Tables | table_sizes, table_bloat, autovacuum_status |
3 | read |
| Replication | replication_status, replication_slots, wal_status |
3 | read |
| Analysis (flagship) | slow_query_rca, bloat_and_vacuum_analysis, blocking_lock_chain_rca |
3 | read |
| Writes | terminate_backend, cancel_query, drop_index |
3 | write (high) |
run_vacuum, run_analyze, create_index, reindex, update_setting, reset_query_stats |
6 | write (medium) | |
| Undo | undo_list |
1 | read |
undo_apply |
1 | write (medium) |
The flagship analyses accept injected records for pure/offline analysis, or pull
live from a configured target. top_queries/slow_query_rca require the
pg_stat_statements extension; the read role should have pg_monitor.
What this tool does, and does not, decide
It delivers PostgreSQL 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: connect with a PostgreSQL role that has no write privileges (a read-only role, or one without 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 ~/.postgres-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.
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 postgres-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 postgres-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:
openclaw plugins install clawhub:@zw008/postgres-aiops
openclaw skills info postgres-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
uv tool install postgres-aiops # or: pipx install postgres-aiops
postgres-aiops init # wizard: add a target + store the password (encrypted)
postgres-aiops doctor # verify config, secrets, connectivity
postgres-aiops overview # one-shot cluster health snapshot
postgres-aiops analyze slow-query # RCA the worst pg_stat_statements entry
postgres-aiops table bloat # dead-tuple bloat proxy per table
Run as an MCP server (stdio):
export POSTGRES_AIOPS_MASTER_PASSWORD=... # unlock secrets non-interactively
postgres-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.
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
~/.postgres-aiops/audit.db(relocatable viaPOSTGRES_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
POSTGRES_RUNAWAY_MAX=0; optional hard ceilings viaPOSTGRES_MAX_TOOL_CALLS/POSTGRES_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 PostgreSQL DBA-ops member of the AIops-tools family (governed
AI-ops with audit + budget + undo + risk tiers). Do NOT use it for OT /
industrial edge (Modbus, OPC-UA, PROFINET) — see the separate industrial-aiops
line — nor for application-schema migrations or ORM management.
Missing a capability?
Coverage is intentionally a curated subset of PostgreSQL's catalogs and maintenance surface. Missing a view, a metric, or a maintenance command? Open an issue or PR — contributions welcome.
Status
The mock test suite is complemented by a live run: the catalog / pg_stat_*
reads, the bloat_and_vacuum_analysis RCA, and the create_index / drop_index
governed write path (audit + undo, with drop_index capturing
pg_get_indexdef first) were exercised against a live PostgreSQL 16.14 instance running in
Docker. docs/VERIFICATION.md records exactly what was
and was not covered. postgres-aiops doctor is the fastest live check.
Postgres AIops MCPのよくある質問
Postgres AIops MCPをClaude Codeに追加するには
ターミナルでclaude mcp add postgres-aiops -- uvx postgres-aiopsを実行します。すべてのプロジェクトで利用するには--scope userを追加します。
Postgres AIops MCPをCursorに追加するには
~/.cursor/mcp.jsonを開き、上記のインストールセクションに示すCursor設定を使ってmcpServersの下にサーバーを追加します。
データベースの認証情報はどのように保存されますか?
認証情報はFernetとscryptを使用して ~/.postgres-aiops/secrets.enc に暗号化されたファイルとして保存されるため、ディスク上に平文で保持されることはありません。
すべての操作の監査ログは提供されますか?
はい、MCPまたはCLI経由で行われたすべての呼び出しは、 ~/.postgres-aiops/audit.db にある統合監査ログに記録されます。
ツールの暴走呼び出しを防ぐ方法はありますか?
はい、組み込みのランナウェイガードがサーキットブレーカーとして機能し、同じ呼び出しが短いループ内で繰り返し実行された場合に停止します。