postgres-postgis-docsbox-mcp read-only

An MCP (Model Context Protocol) server that lets an LLM agent safely explore and query a PostgreSQL + PostGIS database. Every database tool runs inside a SET TRANSACTION READ ONLY block with a short statement_timeout and is unconditionally rolled back.

Endpoints

Tools

ToolPurpose
list_tablesUser tables/views with row estimate & geometry flag.
get_table_schemaDDL + sample rows + indexes for one table.
get_column_valuesDistinct sample values for one column.
list_sridsSRIDs in active use across geometry columns.
get_relationshipsForeign-key edges.
list_extensionsInstalled extensions (PostGIS, pgvector, ...).
pick_interesting_tablesScore by rows + geometry + FK hubness.
validate_sqlStatic SQL safety check (no DB needed).
explain_sqlEXPLAIN [ANALYZE] inside a rolled-back tx.
execute_sqlRead-only SELECT/WITH/EXPLAIN with row caps.
postgis_helpCurated PostGIS recipe reference.
list_sections / get_documentationDoc manifest browser.
run_locallyPlan-only execution recipes (psql, pg_dump, ogr2ogr, ...).

Configure

export PG_DOCSBOX_DSN=postgresql://user:pass@host:5432/db
postgres-postgis-docsbox-mcp

opencode / Claude Code

{
  "mcpServers": {
    "postgres-postgis-docsbox": {
      "type": "http",
      "url": "http://127.0.0.1:7820/mcp"
    }
  }
}