pg-guard-mcp
v0.2.0A PostgreSQL MCP server that enforces read-only access at the protocol and privilege level — not by parsing the query string.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
pg_run_query
Run a single read-only SQL statement (SELECT / WITH / EXPLAIN / SHOW) against the configured PostgreSQL database and return the rows. Rejects anything that isn't exactly one plain read-only statement — multiple statements, transaction-control keywords (COMMIT, ROLLBACK, BEGIN, ...), and any write/DDL/admin keyword anywhere in the query are all refused before the query is sent to the database. Results are capped at PG_GUARD_ROW_LIMIT rows (default 1000).
| Parameter | Type | Description |
|---|---|---|
sql * | string |
pg_explain_query
Return the PostgreSQL query plan for a read-only SELECT/WITH statement, without running it. Useful for checking whether a query will be slow before running it for real.
| Parameter | Type | Description |
|---|---|---|
sql * | string |
pg_list_tables
List the tables and views visible to the connected role in the given schema (default: public).
| Parameter | Type | Description |
|---|---|---|
schema | string |
pg_check_privileges
Report any write privilege (INSERT/UPDATE/DELETE/TRUNCATE) the connected role actually holds on any table. An empty list is the expected, safe result — anything else means the privilege layer of defense is missing and the role should be locked down (see README.md), even though the protocol and session layers still hold on their own.
pg_describe_table
List the columns of a table: name, data type, nullability, and default, in column order.
| Parameter | Type | Description |
|---|---|---|
table_name * | string | |
schema | string |
pg_check_migration_safety
Statically check DDL (CREATE INDEX, ALTER TABLE ADD/RENAME/ALTER COLUMN TYPE, ADD CONSTRAINT) for lock/downtime/breakage patterns that cause real production incidents on a table that already has traffic — a missing CONCURRENTLY, a FOREIGN KEY added without NOT VALID, a NOT NULL column added with no DEFAULT, an in-place RENAME, and similar. Pure text analysis — never connects to the database, never runs anything. An empty findings list means no known-unsafe pattern was found, not a guarantee the migration is safe; see the rule engine's module docstring for wh…
| Parameter | Type | Description |
|---|---|---|
sql * | string |
pg_check_migration_file
Same as pg_check_migration_safety, reading the SQL from a file on disk instead of inline content. Confined to PG_GUARD_MIGRATIONS_DIR when that's set; otherwise reads any local path this process can access — see _migrations_dir()'s docstring. UNC network paths are always rejected, configured or not.
| Parameter | Type | Description |
|---|---|---|
path * | string |