PostgreSQL MCP Server

Databasestdiov0.6.2
Repository

Provides read-only access to PostgreSQL databases through the Model Context Protocol. Enables AI agents to inspect database schemas, run SELECT queries, and explore table structures. Designed for safe database exploration with read-only transaction isolation to prevent accidental data modification. Originally part of the reference servers, now archived and available in servers-archived.

Connect

Add this configuration to .claude/mcp.json

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ],
      "env": {
        "POSTGRES_CONNECTION_STRING": "<YOUR_POSTGRES_CONNECTION_STRING>"
      }
    }
  }
}

Tools (3)

query

Execute a read-only SQL query against the connected PostgreSQL database and return results.

{
  "type": "object",
  "required": [
    "sql"
  ],
  "properties": {
    "sql": {
      "type": "string",
      "description": "SQL query to execute (SELECT statements only)"
    }
  }
}

list_tables

List all tables in the connected PostgreSQL database with their schemas.

{
  "type": "object",
  "properties": {
    "schema": {
      "type": "string",
      "description": "Schema name to filter tables (defaults to public)"
    }
  }
}

describe_table

Get the column definitions, types, and constraints for a specific table.

{
  "type": "object",
  "required": [
    "table_name"
  ],
  "properties": {
    "schema": {
      "type": "string",
      "description": "Schema name (defaults to public)"
    },
    "table_name": {
      "type": "string",
      "description": "Name of the table to describe"
    }
  }
}

Resources (1)

postgres://{host}/{database}/schema

Access to the database schema information including tables, columns, and relationships.

Prompts

This server does not expose any prompts.

Server Information

Author
Anthropic (@modelcontextprotocol)
Repository
https://github.com/modelcontextprotocol/servers-archived
License
MIT
Version
0.6.2
Stars
86,200
Last Updated
January 27, 2026