connect_db
Connect to PostgreSQL database. NOTE: Default connection exists - only use when requested or if other commands fail
Run parameterised SELECTs and separate write statements against a PostgreSQL database, and read its schemas and table structure before you do.
LABSCO SUMMARY
query runs SELECT and execute runs INSERT, UPDATE and DELETE, which puts the distinction where a reviewer of tool calls can see it instead of inside an SQL string. The default connection comes from configuration and connect_db is the exception — its own description says to reach for it only when asked or when other commands fail. Schema exploration exists before any SQL is written, which matters on a database nobody on the call has seen.
A PostgreSQL client of 6 tools that takes its connection from the environment and keeps reads and writes on separate tools.
A reachable PostgreSQL database, addressed by PG_HOST, PG_PORT, PG_USER, PG_PASSWORD and PG_DATABASE.
One command plus credentials — npx mcp-postgres-server, then supply credentials
USE CASES
Find the table, read its structure, and run a parameterised SELECT against it in the same conversation.
Read the affected rows first, then issue the write as a separate call so the change is visible as a write rather than buried in a query.
Start from the schema list, walk down into tables, and read column structure before writing anything against it.
Switch the connection to another host or database when the configured default is not the one holding the answer.
Counted once with only startup setup. Other versions, modes or optional credentials may expose a different list.
connect_dbConnect to PostgreSQL database. NOTE: Default connection exists - only use when requested or if other commands fail
describe_tableGet table structure
executeExecute an INSERT, UPDATE, or DELETE query
list_schemasList all schemas in the database
list_tablesList tables in the database
queryExecute a SELECT query
BEFORE YOU INSTALL
6 tools when we connected. execute runs INSERT, UPDATE and DELETE and cannot be turned off; query is the SELECT-only counterpart.
The documented client runs the server on your machine.
CONTEXT COST
Rated by the size of the 6 tool definitions that ride along on every turn, not by how many there are
INSTALLATION
npx mcp-postgres-server{
"mcpServers": {
"postgres": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-postgres-server"
],
"env": {
"PG_HOST": "<YOUR_PG_HOST>",
"PG_PORT": "5432",
"PG_USER": "<YOUR_PG_USER>",
"PG_PASSWORD": "<YOUR_PG_PASSWORD>",
"PG_DATABASE": "<YOUR_PG_DATABASE>"
}
}
}
}