Skip to main content
MCP Server

Read-only database access with schema inspection

Share
1,800 stars TypeScript MIT Updated: 2025-04-15

Send to Your Agent

Copy this prompt and paste it into Claude, Cursor, or any MCP client to install instantly.

Install the PostgreSQL MCP server for me.

Server: PostgreSQL
Description: Read-only database access with schema inspection
Install command: npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@host/db

Environment variables needed:
- DATABASE_URL: PostgreSQL connection string (required)

GitHub: https://github.com/modelcontextprotocol/servers-archived/tree/main/src/postgres

Please install this MCP server and confirm when ready.

Paste into any AI agent with MCP support — works with Claude Desktop, Cursor, Cline, and more.

Quick Install

Config file: ~/Library/Application Support/Claude/claude_desktop_config.json

  1. Open Claude Desktop app
  2. Go to Settings → Developer → Edit Config
  3. Paste the config below into the file
  4. Restart Claude Desktop
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:pass@host/db"
      ],
      "env": {
        "DATABASE_URL": "postgresql://user:password@localhost:5432/mydb"
      }
    }
  }
}

Add this to your ~/Library/Application Support/Claude/claude_desktop_config.json

Installation Methods

npx Run directly with npx
npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@host/db

Tools (3)

query

Execute a read-only SQL query against the database

execute

Execute a SQL command (INSERT, UPDATE, DELETE)

get_schema

Get the database schema including tables and columns

Environment Variables

DATABASE_URL Required

PostgreSQL connection string

Example: postgresql://user:password@localhost:5432/mydb

Compatibility

Claude Desktop
Cursor
Cline
VS Code
Devin (formerly Windsurf)

About

A Model Context Protocol server that provides access to PostgreSQL databases. This server enables LLMs to inspect database schemas and execute read-only queries.

Key Features

  • Schema inspection — View tables, columns, types, and relationships
  • Read-only queries — Execute SELECT statements safely
  • Write operations — Execute INSERT, UPDATE, DELETE when enabled
  • Connection via URL — Simple connection string configuration

Security

By default, the server operates in read-only mode. Write operations must be explicitly enabled. Always use a dedicated database user with minimal permissions.

Use Cases

  • Database exploration — "Show me all tables and their columns"
  • Query generation — "Write a query to find all users who signed up last week"
  • Data analysis — "What's the average order value by month?"
  • Schema design — "Suggest indexes for this query pattern"
  • Debugging — "Find all records where status is null"

Related Resources

Compare LLM Pricing

This server works with Claude, GPT-4o, and other models. Compare API costs side-by-side to find the cheapest option for your workflow.