← Back to PostgreSQL MCP Server

Install PostgreSQL MCP Server

Pick your client, copy the command, done.

Manual setup required. The maintainer's config contains paths only you know - edit the placeholders below before adding it to Claude Code.
1

Prepare the server locally

Run this once before adding it to Claude Code.

git clone https://github.com/guibracco/postgres-mcp-server
cd postgres-mcp-server

Then follow the repository README for any remaining dependency or build steps.

2

Register it in Claude Code

claude mcp add -e "DB_NAME=${DB_NAME}" -e "DB_USER=${DB_USER}" -e "DB_PASSWORD=${DB_PASSWORD}" -e "DB_HOST=${DB_HOST}" -e "DB_PORT=${DB_PORT}" postgres-mcp-server -- poetry -C /absolute/path/to/postgres-mcp-server run python postgres-mcp-server/main.py

Replace any placeholder paths in the command with the real path on your machine.

Required:DB_NAMEDB_USERDB_PASSWORDDB_HOSTDB_PORT

Environment Variables

Set these before running PostgreSQL MCP Server.

VariableDescriptionRequired
DB_NAMEThe name of the PostgreSQL databaseYes
DB_USERThe username for database authenticationYes
DB_PASSWORDThe password for database authenticationYes
DB_HOSTThe host address of the database serverYes
DB_PORTThe port number for the database connectionYes

Available Tools (1)

Once configured, PostgreSQL MCP Server gives your AI agent access to:

get_schemaRetrieves the database schema to allow the AI to understand the structure of your PostgreSQL database.

Try It Out

After setup, try these prompts with your AI agent:

Can you retrieve the database schema so I can understand the table structures?
What tables are currently available in my PostgreSQL database?
Help me understand the relationships between the tables in my database schema.

Keep this setup from going cold

Save the docs, env vars, and workflow around PostgreSQL MCP Server in Conare so Claude Code, Codex, and Cursor remember it next time.

Remember this setup