databasepostgressqlread-only

Summary

Read-only PostgreSQL access with automatic schema inspection — the reference MCP server for Postgres.

Features

  • Read-only SQL access to any PostgreSQL database
  • Automatic schema inspection for every table
  • Single-argument setup with a connection string

Installation

Set up this MCP server in your favorite AI agent — copy a ready-made configuration below.

Any MCP-compatible agent

Most agents (Claude, Cursor, Windsurf, VS Code, and more) read a standard mcpServers configuration.

  1. Open your agent's MCP configuration file.
  2. Merge the snippet below into it.
  3. Restart the agent — the "PostgreSQL" tools will be available.
{
  "mcpServers": {
    "postgres-reference": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://localhost/mydb"
      ]
    }
  }
}

Description

The reference PostgreSQL MCP server gives an assistant read-only access to a database, along with the schema information it needs to write correct queries.

What it does

  • Read-only query execution. Every statement runs inside a read-only transaction, so an assistant cannot modify data even if it decides to try.
  • Schema resources. Each table is exposed as a resource with its column names and types, so the model works from the actual schema rather than inferring one from table names.

Why the read-only constraint is the point

Giving a language model write access to a production database is a decision that deserves more thought than a config file entry. This server removes the question entirely, which makes it a sensible default for analysis, debugging, and answering questions about data.

Setup

One argument — the connection string — and you are running: npx -y @modelcontextprotocol/server-postgres postgresql://host/db. For write access or broader database support, DBHub and vendor-specific servers are better choices.

Part of the MCP reference server collection, now maintained in the archived servers repository.

Related MCP Servers

Browse all MCP servers →