← Back to Hub

PostgreSQL MCP Server

MCP server configuration for connecting Claude Code to a PostgreSQL database. Enables schema inspection, queries, and migrations.

MCPdatapostgresqldatabasemcpsql

by Build Ship Grow

postgresql-mcp-server.json
json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:password@localhost:5432/mydb"
      ],
      "env": {
        "POSTGRES_SSL": "false"
      }
    }
  }
}

// Usage notes:
// 1. Replace the connection string with your actual database URL
// 2. For production, use environment variables instead of inline credentials
// 3. Place this in .claude/mcp.json at your project root
// 4. Available tools after connection:
//    - query: Run SELECT queries
//    - execute: Run INSERT/UPDATE/DELETE
//    - schema: Inspect table structures
//    - tables: List all tables
// 5. Claude Code will auto-discover the schema on first use