Install Database Postgres in Claude Code
What you need first
- Claude Code, installed.
- Node.js, which
gives the
npxcommand the server starts with. - Your own values for
YOUR_POSTGRES_HOST,YOUR_POSTGRES_USER,YOUR_POSTGRES_DATABASE.
Steps
- Run this in a terminal, in the project folder. It adds the server for you in that
project; put
--scope userafterclaude mcp addto have it in every project.
claude mcp add --env POSTGRES_HOST=YOUR_POSTGRES_HOST --env POSTGRES_USER=YOUR_POSTGRES_USER --env POSTGRES_DATABASE=YOUR_POSTGRES_DATABASE --transport stdio database-mcp-postgres -- npx -y @database-mcp/[email protected] - Replace
YOUR_POSTGRES_HOST,YOUR_POSTGRES_USER,YOUR_POSTGRES_DATABASEwith your own values. - Start Claude Code and type
/mcp: the server is listed with its state.
Check it worked
Ask Claude Code: List the tools of database-mcp-postgres.
If it does not start
- spawn npx ENOENT
- Node.js is not on the PATH that Claude Code sees. Install it, or write the
full path of
npxin the config. - The server starts, but its tools fail
- A
YOUR_…placeholder is still in the config, or its value is wrong.