Skip to content

MCP Server: PostgreSQL (and Aurora / Redshift)

MCP Server: PostgreSQL (and Aurora / Redshift)

What This Repository Does

@modelcontextprotocol/server-postgres is an official MCP server that connects build-cli to a PostgreSQL database (and compatible databases: Amazon Aurora PostgreSQL-compatible, Redshift with limitations), enabling direct SQL execution and schema exploration in a session.

Common use cases:

  • Ask questions about your data without writing SQL manually
  • Validate assumptions (“how many nulls are in this column?”) during development
  • Generate SQL against the actual schema rather than describing it in text
  • Explore an unfamiliar database

For the Snowflake-specific MCP server, see the companion item repo:mcp-snowflake.

How to Use It

Add the server to your Claude Code MCP configuration (~/.claude/settings.json):

{
"mcpServers": {
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://user:password@host:5432/dbname"]
}
}
}

Replace the connection string with your credentials. Use a read-only database user where possible.

Security considerations:

  • Use read-only database credentials — MCP servers can execute arbitrary SQL.
  • Do not connect to production databases containing PII or regulated data without confirming compliance with your data steward and security team.
  • Credentials embedded in the config file are stored in plaintext — use environment variables or a secrets manager where possible.
  • Confirm with your team lead before connecting any MCP server to a production system.

Relevance to the Hub

This server enables DMDQP software engineers to query their PostgreSQL-family databases directly from build-cli, closing the loop between code authoring and data validation. It is especially useful during data quality investigations, schema-driven SQL generation, and ETL pipeline development.