describe_table
Get the structure of a database table
Query a PostgreSQL database and read its schema — tables, columns, constraints, indexes, views and functions — with read-only enforced by default.
LABSCO SUMMARY
The schema tools are the reason to reach for this rather than a bare SQL socket — constraints, indexes, views and function listings give a model enough to write a correct join instead of guessing at column names. Pagination, a query timeout and a read-only default keep an exploratory session from becoming an incident.
A PostgreSQL MCP server built on Kysely, aimed at letting a client read a live database safely. Queries are parameterized and paginated; alongside them sits a full schema-inspection surface — tables, columns, constraints, indexes, views, functions and table statistics — plus EXPLAIN for a plan without running the statement. READ_ONLY defaults to on, restricting execution to SELECT, WITH and EXPLAIN.
queryANALYZE, in text, json, xml or yaml — explain_querydescribe_table, get_constraintslist_schemas, list_tableslist_indexeslist_views, list_functionsget_table_statsCredentials for a PostgreSQL database, passed as environment variables: DB_HOST, DB_PORT (5432), DB_USER, DB_PASSWORD, DB_NAME and DB_SSL. The package is @abiswas97/postgres-mcp 2.0.0 with a postgres-mcp binary, run over stdio. READ_ONLY is true unless you change it, which is the setting that decides whether an agent can write to this database at all — leave it on for anything you care about. QUERY_TIMEOUT cuts a statement off at 30000 milliseconds, MAX_PAGE_SIZE caps a page at 500 rows and DEFAULT_PAGE_SIZE sets 100 when the call does not say.
One command plus credentials — npx @abiswas97/postgres-mcp, then supply credentials
USE CASES
List the schemas and tables, describe the ones that look relevant, read their constraints to find how they join, and only then write the query.
Read the execution plan, then check which indexes actually exist on the tables involved and how large they are before changing anything.
Leave READ_ONLY on so only SELECT, WITH and EXPLAIN run, and let pagination bound the result instead of a forgotten LIMIT.
List the views and the stored functions in a schema before rewriting business rules that are already implemented there.
Counted once with only startup setup. Other versions, modes or optional credentials may expose a different list.
describe_tableGet the structure of a database table
explain_queryGet query execution plan (EXPLAIN)
get_constraintsGet constraints for a table
get_table_statsGet table statistics and size information
list_functionsList functions and procedures in a schema
list_indexesList indexes for a table or schema
list_schemasList all schemas in the database
list_tablesList all tables in a schema
list_viewsList views in a schema
queryExecute SQL queries with pagination support and parameterization for security. Supports page sizes up to 500 rows.
BEFORE YOU INSTALL
10 tools when we connected.
The documented client runs the server on your machine.
CONTEXT COST
Rated by the size of the 10 tool definitions that ride along on every turn, not by how many there are
INSTALLATION
npx @abiswas97/postgres-mcp{
"mcpServers": {
"postgres-mcp-server": {
"command": "npx",
"args": [
"@abiswas97/postgres-mcp"
],
"env": {
"DB_HOST": "127.0.0.1",
"DB_PORT": "5432",
"DB_USER": "postgres",
"DB_PASSWORD": "<YOUR_DB_PASSWORD>",
"DB_NAME": "<YOUR_DB_NAME>",
"DB_SSL": "true"
}
}
}
}