postgres-schema-mcp
v0.1.2Schema access for an agent is a retrieval problem, not a dump.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
search_schema
Find the tables relevant to a question and return their DDL. Prefer this over trying to read the whole schema. The schema is far larger than the part of it any one question needs, and sending all of it costs context you will want for the answer. Pass the user's question in natural language, not a table name guess: this ranks on column names, types and the schema's own comments. Returns the highest-scoring tables with their columns and keys, plus the foreign-key edges *between the returned tables*, which is what you need to write the joins. On failure or a disappointing result: * If a tabl…
| Parameter | Type | Description |
|---|---|---|
question * | string | |
limit | integer |
describe_table
Return full detail for one table by name. Use this when you already know the table name: either search_schema returned it and you need the complete column list, or search_schema did *not* return it and you believe it exists anyway. This does not use the ranking, so it is the reliable way to reach a table that retrieval scored poorly. Accepts either a qualified name ("sales.salesorderheader") or a bare one ("salesorderheader"). Returns columns with types and comments, the primary key, foreign keys out, and the foreign keys pointing in, which is how you find the tables that join to this one.…
| Parameter | Type | Description |
|---|---|---|
name * | string |
explain_query
Plan a SELECT without executing it. Use this before run_query when the query touches a large table, has no WHERE clause, or joins several tables, so you can see the cost before committing to it. The query is planned only; no rows are read and nothing is executed. EXPLAIN ANALYZE is deliberately not offered, because it would run the statement. Read total_cost as a relative number, useful for comparing two phrasings of the same query rather than as a time. On failure: * "Blocked: ..." means the same read-only policy as run_query rejected it. Rewrite as a plain SELECT. * A "column does…
| Parameter | Type | Description |
|---|---|---|
sql * | string |
run_query
Execute a read-only SELECT and return the rows. Use this once you know which tables and columns you need. If you do not yet know, call search_schema first rather than guessing table names; a query against a table that does not exist wastes a round trip. Only a single SELECT is accepted. WITH is fine as long as the whole statement is read-only. Anything else, including INSERT/UPDATE/DELETE, DDL, statement stacking, and DML hidden inside a CTE, is rejected before it reaches the database. On failure: * "Blocked: ..." means the statement violated the read-only policy. The message names th…
| Parameter | Type | Description |
|---|---|---|
sql * | string | |
max_rows | integer |