← Back to directory
P

PostgreSQL MCP Server

Official
Archived
Read-only DB access for safe analysis
Category
Database #10 of 58
Stars
★ 305 Popular
Transport
stdio (local process)
Runtime
Node.js
Credentials
API key / credential required
License
MIT
Last commit
⚠
Tools
4
68FMRS · C

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.

Strongest · Security and permissions 16/20 Weakest · Maintenance 10/20

Reliability
15/20
Security and permissions
16/20
Maintenance
10/20
Documentation
14/20
Setup experience
13/20

Reviewed by an editorListed 2026-07-13

Read the FMRS scoring method →

Fit and risk

What it can accessConnects to a database

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

Setup

Before you start

Runtime:Node.js

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"
      ]
    }
  }
}

Shown for Claude Desktop. Other clients may use a different file or key (VS Code uses "servers") — the configurator below converts it.

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

Goes in your project's .vscode/mcp.json (VS Code uses a "servers" key).

Terminal
claude mcp add postgres -- npx -y @modelcontextprotocol/server-postgres postgresql://readonly:pwd@localhost/db

Run it in a terminal; replace any <…> placeholders with your own values first.

Check that it works

The client's tool list should show query, list_schemas, list_tables, and describe_table; calling list_tables and getting back table names from the connected database confirms the install works.

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

Things to try

Once connected, you can ask your AI assistant things like:

  • List all schemas in this PostgreSQL database
  • Show me the tables in the public schema
  • Describe the structure of the users table
  • Query the database for the most recent records

Tools 4

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

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 Desktop
Cursor
ClinePartial support

Listed from the project's documentation, not tested by this site.

Overview

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.

Similar servers

Source revision 9be4674d1ddf Data synced 2026-10-14 Read the FMRS scoring method