# PostgreSQL MCP Server

> Read-only DB access for safe analysis

- **URL**: https://followmcp.com/en/servers/postgres
- **Category**: Database
- **Origin**: Official
- **Stars**: 307
- **FMRS Score**: 68/100 (Grade C)
- **Source**: https://github.com/modelcontextprotocol/servers-archived/tree/main/src/postgres
- **Transports**: stdio (local process)
- **Runtimes**: Node.js
- **Auth**: API key / credential required

## 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.

## 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
- Query results may contain personal or business-sensitive data
- Complex read queries can still consume significant resources; use timeouts and a read replica

## Client config (JSON)
```json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://readonly:pwd@localhost/db"
      ]
    }
  }
}
```

## Tools (4)
- `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
