LabscoMCP early access ↗
devopamMCP SERVER · OFFICIAL PROJECT

MCPg - Production-grade PostgreSQL MCP Server

A wide PostgreSQL surface for agents — catalog, query, tuning, diagnostics — read-only until you opt into writes.

by devopam ↗Relational SQL Databases✓ Official

LABSCO SUMMARY

Capability gates, not a single read-only switch.

Writes, schema changes, shell operations and LISTEN/NOTIFY are four separate doors, each needing both an access mode and its own environment flag. That granularity is what lets you hand an agent the tuning advisors and the catalog without also handing it run_ddl. The operational plumbing is unusually complete for a database server — OIDC with a role claim mapped to a Postgres role, read-replica round-robin for read-only queries, an IP allowlist applied before auth, and one OpenTelemetry span per call that records the tool name and argument count but never argument values.

What it is

A production-oriented Postgres server. Every user-supplied statement parses through a validated AST allowlist before it executes, identifier interpolation is regex-constrained, and each tool publishes MCP annotations derived from its capability gate so a client knows what is safe to auto-approve.

What you get

  • Catalog introspection: list_schemas, list_tables, describe_table, list_indexes, list_constraints, list_foreign_keys, list_views, list_functions, list_triggers, list_partitions, list_policies, list_extensions and more, plus get_compact_schema when context is tight
  • Query and cursors: run_select, run_select_tuned, run_select_parallel, open_cursor/fetch_cursor/close_cursor, explain_query, analyze_query_plan and translate_nl_to_sql
  • Health and advisors: check_database_health, analyze_table_bloat, audit_database, analyze_workload, detect_n_plus_one, recommend_indexes, recommend_index_drops, find_unused_objects, find_sensitive_columns, lint_naming_conventions
  • Structure work: compare_schemas, generate_schema_diagram, generate_fk_cascade_graph, generate_schema_docs
  • Self-description: get_server_info, describe_self, describe_tool, get_metrics_exposition, plus list_session_intents and enable_session_intent for dynamic toolsets
  • 256 tools in the generated index, grouped by feature area and labelled with the gate each one needs

Requirements

The PyPI package mcpg, version 0.8.0, over uvx and stdio, or pip install mcpg. Postgres 14 to 19. Read tools work in every access mode; run_write and friends need restricted or higher; DDL, shell and LISTEN each need unrestricted mode plus their own opt-in — MCPG_ALLOW_DDL, MCPG_ALLOW_SHELL, MCPG_ALLOW_LISTEN. The HTTP transport adds its own layer: MCPG_HTTP_AUTH_TOKEN for a static bearer token, or MCPG_AUTH_MODE=oidc with issuer and audience, plus an IP allowlist, TLS and per-request role mapping.

Setup effort

One command plus credentials — uvx mcpg, then supply credentials