mcp-postgres-analytics

mcp-postgres-analytics

Read-only PostgreSQL analytics MCP server — query plans, slow queries, index usage, table bloat, vacuum status. No DDL/DML/writes. Curated by Archimedes Market with a verified Trust Report.

Category
Visit Server

README

Archimedes Trust Report — VERIFIED 92/100

Verified asset on Archimedes Market. View the full 4-dimension Trust Report (security · quality · license · complexity) and the curated catalog on the asset page.


MCP PostgreSQL Analytics

Read-only PostgreSQL analytics agent exposed as an MCP server. Designed to drop into a production database safely — no DDL, no DML, no writes ever.

Eight tools cover the observability surface most teams reach for during incident response and capacity planning:

  • query_planEXPLAIN (ANALYZE, BUFFERS, VERBOSE) against a query string, with annotated cost hot spots
  • slow_queries — top N queries by mean time / total time / call count from pg_stat_statements
  • index_usage — index hit ratio, dead indexes, missing-index hints from pg_stat_user_indexes
  • table_bloat — bloat estimation per table using the pgstattuple-equivalent heuristic
  • vacuum_status — last vacuum / autovacuum / analyze per table, with wraparound risk flagged
  • connection_stats — active sessions, idle-in-transaction, longest-running transactions
  • lock_waits — blocked queries with the blocker chain resolved
  • size_summary — database/schema/table/index size, sorted

Safety guarantees

The MCP server connects as a role with pg_read_all_stats and CONNECT only. The connection string in MCP_POSTGRES_DSN is validated at startup to refuse any role that has CREATE, INSERT, UPDATE, DELETE, TRUNCATE, ALTER, or DROP privileges on any schema. Refusal exits with a clear error rather than running with elevated rights.

query_plan accepts a query string but executes it inside EXPLAIN (...) only — the query itself is never run.

Quick start

pip install mcp-postgres-analytics
export MCP_POSTGRES_DSN="postgresql://reader@host:5432/db"
mcp-postgres-analytics serve

Claude Desktop config:

{
  "mcpServers": {
    "postgres-analytics": {
      "command": "mcp-postgres-analytics",
      "args": ["serve"],
      "env": {
        "MCP_POSTGRES_DSN": "postgresql://reader@host:5432/db"
      }
    }
  }
}

Typical agent workflow

Agent: "Why is our /api/checkout endpoint slow this week?"
↓
1. slow_queries → top 5 queries by mean time
2. query_plan on the worst → spots a sequential scan
3. index_usage → confirms missing index hint
4. size_summary → confirms the table is 14GB
5. Output: "Index on orders(status, created_at) missing. ~150ms saved per call. Run during low-traffic window."

What it does NOT do

  • No write operations of any kind
  • No connection to non-PostgreSQL databases (use the DuckDB MCP for Parquet/CSV)
  • No backup/restore (use pg_dump directly)
  • No replication topology management

If you need write access for an agent workflow, use a separate MCP server with explicit gates. Mixing read-only analytics with write operations is exactly the kind of conflated tooling that this server was built to avoid.

License

MIT.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured