Most database servers hand a model everything the connection role can do; this one splits the difference into two switches — security mode for writes and DDL, --allow-destructive for drops, resets and raw SQL — so exploring a production database and administering it are different configurations of the same install. The rest of the design follows from that: structured where predicates instead of string fragments, unknown fields rejected before a connection is opened, and per-call connection strings off by default so a tool call cannot point itself at a different database.
A PostgreSQL administration surface built as a small number of meta-tools: one tool per subject area, with an operation argument selecting what it does. It starts read-only, and writes, DDL and arbitrary SQL are unlocked by explicit flags.
- pg_execute_query runs parameterised SELECT, count and exists queries with a limit and a timeout; pg_execute_mutation does insert, update, delete and upsert against a table with structured where predicates and a returning clause
- pg_execute_sql takes arbitrary SQL, with transactional execution for multi-statement calls
- pg_manage_schema creates and alters tables, lists schema information and manages enums; pg_manage_functions and pg_manage_triggers cover the same ground for functions and triggers
- pg_manage_indexes creates, drops, reindexes and — with analyze_usage and showUnused — reports which indexes are earning their keep
- pg_manage_constraints handles foreign keys and other constraints, including onDelete, onUpdate and deferrable settings
- pg_manage_rls enables Row-Level Security on a table and creates policies with using and check expressions per role and command
- pg_manage_users creates and alters roles and grants or revokes permissions, with login, superuser, createdb, createrole and validUntil attributes
- pg_manage_query returns EXPLAIN plans with analyze, buffers and costs, plus slow query analysis and query statistics that can be reset
- pg_analyze_database and pg_debug_database look at configuration and performance and work through common failure modes at a log level you choose
- pg_monitor_database returns live activity, optionally including locks, running queries, table statistics and replication, against alert thresholds you set
- pg_export_table_data and pg_import_table_data move JSON or CSV in and out with an optional filter, and pg_copy_between_databases copies a table straight from one connection to another
- pg_manage_comments reads and sets comments on tables, columns, functions and other objects — the documentation layer that usually goes stale
A reachable PostgreSQL server and Node.js 18.0.0 or higher; it runs as npx @henkey/postgres-mcp-server, or from the Docker image. The connection string belongs to the server, not to the tools: --connection-string or POSTGRES_CONNECTION_STRING, and per-call connectionString arguments are refused unless you pass --allow-tool-connection-string. From 2.0.0 the server starts in readonly mode — mutations, DDL, role administration, import and export and arbitrary SQL need --security-mode write, admin or unsafe, and drops, resets, broad grants and arbitrary SQL additionally need --allow-destructive. String where clauses are rejected in favour of structured predicates, and unknown fields in a tool call fail before a connection is opened.
One command plus a key — npm install -g @henkey/postgres-mcp-server, then supply credentials
