← Back to directory
P

PostgreSQL MCP Server

Official
Archived
Read-only DB access for safe analysis
GitHub source repository ↗
★ 294 Stars Category · Database Popular Source revision 9be4674d1ddf
68FMRS · C
Reliability
15/20
Security and permissions
16/20
Maintenance
10/20
Documentation
14/20
Setup experience
13/20

The read-only interface reduces destructive risk, but database credentials, sensitive query results, and query load still need controls; no live database handshake is recorded yet.

Read the FMRS scoring method →

This server connects to PostgreSQL in read-only mode and exposes schema information alongside query access. It helps models write and explain SQL without modifying production data, making it useful for analysis and troubleshooting.

Tools

query
Run a read-only SQL query
list_schemas
List all schemas in the database
list_tables
List tables in a selected schema
describe_table
Inspect a table's columns and data types

Setup

Pass a PostgreSQL connection string as a startup argument. Use a dedicated read-only database account.

claude_desktop_config.json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://readonly:pwd@localhost/db"
      ]
    }
  }
}

Fit and risk

Best for

  • Analysts and developers exploring PostgreSQL data through natural language
  • Teams exposing schema and query access through a dedicated read-only account

Not for

  • Workflows that require writes, migrations, or database administration
  • Sensitive databases whose query results cannot enter a third-party model context

Required permissions

  • Network access to PostgreSQL
  • A dedicated read-only account with SELECT access to the intended schemas

Risks and side effects

  • Query results may contain personal or business-sensitive data
  • Complex read queries can still consume significant resources; use timeouts and a read replica

Troubleshooting

  1. Test the same connection string with psql
  2. Check firewall rules, SSL mode, and PostgreSQL listen addresses
  3. Confirm the account has schema USAGE and table SELECT privileges

Use cases

Generate reporting queries from natural-language requests
Investigate slow queries and missing indexes
Help new team members understand the database schema

Supported clients

Claude DesktopFull support
CursorFull support
ClinePartial support