# MCP-PostgreSQL-Ops — PostgreSQL DBA MCP (30+ tools) > Give Claude Desktop/Claude Code a PostgreSQL DBA toolbox (30+ tools) for locks, bloat, autovacuum, and stats. Works on PG 12–18; stdio or HTTP transport. ## Install Merge the JSON below into your `.mcp.json`: ## Quick Use ```bash pip install mcp-postgresql-ops mcp-postgresql-ops --help ``` ```json // Claude Desktop example from README { "mcpServers": { "mcp-postgresql-ops": { "command": "uvx", "args": ["--python", "3.12", "mcp-postgresql-ops"], "env": { "POSTGRES_HOST": "127.0.0.1", "POSTGRES_PORT": "15432", "POSTGRES_USER": "postgres", "POSTGRES_PASSWORD": "changeme!@34", "POSTGRES_DB": "ecommerce" } } } } ``` ## Intro MCP-PostgreSQL-Ops exposes a PostgreSQL operations toolkit to MCP clients so your agent can inspect health, diagnose performance, and answer “what’s happening in the DB?” without hand-written SQL. **Best for:** DBA-on-call workflows, incident triage, and agent-assisted database visibility **Works with:** PostgreSQL 12–18; MCP clients (Claude Desktop/Claude Code/Cursor); stdio or HTTP transport **Setup time:** 10–15 minutes ### Key facts (verified) - README claims 30+ DBA tools, including locks/deadlocks, bloat, autovacuum, and schema inspection. - Supports transport `stdio` (default) or `streamable-http` per README options table. - GitHub: 150 stars · 24 forks; pushed 2026-05-11 (GitHub API verified). ## Main A practical pattern is to pair “symptom → evidence → next action”: - Symptom: “queries are slow” → Evidence: locks, bloat, vacuum stats, IO stats → Next action: index/vacuum/tuning. - Keep the MCP server read-only at first (no writes) and rotate DB credentials like any other operational secret. - For teams, prefer a dedicated DB role with least privilege; the agent only needs catalog/stat views for most diagnostics. ### README excerpt (verbatim) # MCP Server for PostgreSQL Operations and Monitoring [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) ![Python](https://img.shields.io/badge/Python-3776AB?style=flat&logo=python&logoColor=white) ![Docker Pulls](https://img.shields.io/docker/pulls/call518/mcp-server-postgresql-ops) ![PostgreSQL](https://img.shields.io/badge/PostgreSQL-4169E1?style=flat&logo=postgresql&logoColor=white) [![BuyMeACoffee](https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-donate-yellow.svg)](https://www.buymeacoffee.com/call518) [![Deploy to PyPI with tag](https://github.com/call518/MCP-PostgreSQL-Ops/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/call518/MCP-PostgreSQL-Ops/actions/workflows/pypi-publish.yml) ![PyPI](https://img.shields.io/pypi/v/MCP-PostgreSQL-Ops?label=pypi%20package) ![PyPI - Downloads](https://img.shields.io/pypi/dm/MCP-PostgreSQL-Ops) --- ## Architecture & Internal (DeepWiki) [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/call518/MCP-PostgreSQL-Ops) --- ## Overview **MCP-PostgreSQL-Ops** is a professional MCP server for PostgreSQL database operations, monitoring, and management. Supports PostgreSQL 12-18 with comprehensive database analysis, performance monitoring, and intelligent maintenance recommendations through natural language queries. Most features work independently, but advanced query analysis capabilities are enhanced when `pg_stat_statements` and (optionally) `pg_stat_monitor` extensions are installed. --- ## Features - ✅ **Zero Configuration**: Works with PostgreSQL 12-18 out-of-the-box with automatic version detection. - ✅ **Natural Language**: Ask questions like "Show me slow queries" or "Analyze table bloat." - ✅ **Production Safe**: Read-only operations, RDS/Aurora compatible with regular user permissions. - ✅ **Extension Enhanced**: Optional `pg_stat_statements` and `pg_stat_monitor` for advanced query analytics. - ✅ **Comprehensive Database Monitoring**: Performance analysis, bloat detection, and maintenance recommendations. - ✅ **Smart Query Analysis**: Slow query identification with `pg_stat_statements` and `pg_stat_monitor` integration. - ✅ **Schema & Relationship Discovery**: Database structure exploration with detailed relationship mapping. - ✅ **VACUUM & Autovacuum Intelligence**: Real-time maintenance monitoring and effectiveness analysis. - ✅ **Multi-Database Operations**: Seamless cross-database analysis and monitoring. ### FAQ **Q: Which PostgreSQL versions are supported?** A: README states PG 12–18 with version-aware tools. **Q: How does it connect to the DB?** A: The README shows configuring host/port/user/password/db via environment variables. **Q: Can it run over HTTP?** A: README options mention `streamable-http` as an alternative transport to stdio. ## Source & Thanks > Source: https://github.com/call518/MCP-PostgreSQL-Ops > License: MIT > GitHub stars: 150 · forks: 24 --- ## 快速使用 ```bash pip install mcp-postgresql-ops mcp-postgresql-ops --help ``` ```json // README 提供的 Claude Desktop 配置示例 { "mcpServers": { "mcp-postgresql-ops": { "command": "uvx", "args": ["--python", "3.12", "mcp-postgresql-ops"], "env": { "POSTGRES_HOST": "127.0.0.1", "POSTGRES_PORT": "15432", "POSTGRES_USER": "postgres", "POSTGRES_PASSWORD": "changeme!@34", "POSTGRES_DB": "ecommerce" } } } } ``` ## 简介 MCP-PostgreSQL-Ops 把一套 PostgreSQL 运维工具以 MCP 形式暴露给客户端,让 Agent 能直接查看健康状态、诊断性能问题并回答“数据库现在发生了什么”。 **最适合:** DBA 值班、故障分诊、让 Agent 帮你看数据库状态 **适配:** PostgreSQL 12–18;MCP 客户端(Claude Desktop/Claude Code/Cursor);stdio 或 HTTP 传输 **配置时间:** 10–15 分钟 ### 关键事实(已验证) - README 描述提供 30+ DBA 工具,覆盖锁/死锁、膨胀、autovacuum、Schema 检查等。 - README 说明支持 `stdio`(默认)与 `streamable-http` 两种传输。 - GitHub:150 stars · 24 forks;最近更新 2026-05-11(GitHub API 验证)。 ## 正文 推荐用“症状 → 证据 → 下一步动作”的排障套路: - 症状:查询变慢 → 证据:锁、膨胀、vacuum 统计、IO 统计 → 动作:索引/清理/参数调优。 - 初期建议以只读方式接入,并像运维密钥一样管理 DB 凭据。 - 团队使用时用最小权限的专用角色;多数诊断只需要系统视图/统计信息权限。 ### README 原文节选(verbatim) # MCP Server for PostgreSQL Operations and Monitoring [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) ![Python](https://img.shields.io/badge/Python-3776AB?style=flat&logo=python&logoColor=white) ![Docker Pulls](https://img.shields.io/docker/pulls/call518/mcp-server-postgresql-ops) ![PostgreSQL](https://img.shields.io/badge/PostgreSQL-4169E1?style=flat&logo=postgresql&logoColor=white) [![BuyMeACoffee](https://raw.githubusercontent.com/pachadotdev/buymeacoffee-badges/main/bmc-donate-yellow.svg)](https://www.buymeacoffee.com/call518) [![Deploy to PyPI with tag](https://github.com/call518/MCP-PostgreSQL-Ops/actions/workflows/pypi-publish.yml/badge.svg)](https://github.com/call518/MCP-PostgreSQL-Ops/actions/workflows/pypi-publish.yml) ![PyPI](https://img.shields.io/pypi/v/MCP-PostgreSQL-Ops?label=pypi%20package) ![PyPI - Downloads](https://img.shields.io/pypi/dm/MCP-PostgreSQL-Ops) --- ## Architecture & Internal (DeepWiki) [![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/call518/MCP-PostgreSQL-Ops) --- ## Overview **MCP-PostgreSQL-Ops** is a professional MCP server for PostgreSQL database operations, monitoring, and management. Supports PostgreSQL 12-18 with comprehensive database analysis, performance monitoring, and intelligent maintenance recommendations through natural language queries. Most features work independently, but advanced query analysis capabilities are enhanced when `pg_stat_statements` and (optionally) `pg_stat_monitor` extensions are installed. --- ## Features - ✅ **Zero Configuration**: Works with PostgreSQL 12-18 out-of-the-box with automatic version detection. - ✅ **Natural Language**: Ask questions like "Show me slow queries" or "Analyze table bloat." - ✅ **Production Safe**: Read-only operations, RDS/Aurora compatible with regular user permissions. - ✅ **Extension Enhanced**: Optional `pg_stat_statements` and `pg_stat_monitor` for advanced query analytics. - ✅ **Comprehensive Database Monitoring**: Performance analysis, bloat detection, and maintenance recommendations. - ✅ **Smart Query Analysis**: Slow query identification with `pg_stat_statements` and `pg_stat_monitor` integration. - ✅ **Schema & Relationship Discovery**: Database structure exploration with detailed relationship mapping. - ✅ **VACUUM & Autovacuum Intelligence**: Real-time maintenance monitoring and effectiveness analysis. - ✅ **Multi-Database Operations**: Seamless cross-database analysis and monitoring. ### FAQ **支持哪些 PostgreSQL 版本?** 答:README 表示支持 PG 12–18,并提供版本自适应工具。 **如何连接数据库?** 答:README 用环境变量配置 host/port/user/password/db。 **能走 HTTP 吗?** 答:README 提到除 stdio 外还可用 `streamable-http` 传输。 ## 来源与感谢 > Source: https://github.com/call518/MCP-PostgreSQL-Ops > License: MIT > GitHub stars: 150 · forks: 24 --- Source: https://tokrepo.com/en/workflows/mcp-postgresql-ops-postgresql-dba-mcp-30-tools Author: MCP Hub