$ recombobulate _
home / tips / add-the-postgres-mcp-server-for-live-database-queries
1

Add the Postgres MCP Server for Live Database Queries

bagwaa @bagwaa · Mar 25, 2026 · MCP Servers
add-the-postgres-mcp-server-for-live-database-queries

Without a live database connection, Claude writes SQL against imaginary columns. The Postgres MCP server fixes this — giving Claude read access to your real schema so every query it writes matches your actual tables.

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

Once connected, Claude can introspect your schema, write queries that match your real column names, and suggest indexes based on actual table structures. Ask it things like "which users signed up last week but haven't placed an order?" and it will write, explain, and refine the SQL based on what it can actually see.

-- Claude generates this knowing your real column names
SELECT u.email, u.created_at
FROM users u
LEFT JOIN orders o ON o.user_id = u.id
WHERE u.created_at >= NOW() - INTERVAL '7 days'
  AND o.id IS NULL;

For safety, always point it at a read-only replica or a local dev database — never connect it to a production instance with write access.

A Claude that can see your real schema writes far better SQL than one flying blind.

~/recombobulate $ tip --comments --count=0

Log in to leave a comment.

~/recombobulate $ tip --related --limit=3
0
Build a Custom MCP Server to Expose Your Internal APIs

Scaffold a custom MCP server with Claude to give it direct access to your internal APIs, dashboards, and microservices.

bagwaa @bagwaa · 3 hours ago
0
Lock Down MCP Servers with --strict-mcp-config

Use --strict-mcp-config to restrict Claude Code to only the MCP servers you explicitly provide, ignoring all other sources.

bagwaa @bagwaa · 4 hours ago
0
Use the /mcp Command to Inspect Your MCP Servers

When an MCP server misbehaves, /mcp gives you a live view of every connected server, its status, and the tools it's exposing — right inside your session.

bagwaa @bagwaa · 6 hours ago