MCP ConfigsMar 29, 2026·1 min read

PostgreSQL MCP Server — Database Queries for AI

MCP server for PostgreSQL database access. Run read-only SQL queries, inspect schemas, list tables, and analyze data directly from Claude Code or Cursor.

TO
TokRepo精选 · Community
Quick Use

Use it first, then decide how deep to go

This block should tell both the user and the agent what to copy, install, and apply first.

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

Intro

Connect your AI coding tools directly to PostgreSQL databases. Inspect schemas, run queries, analyze data, and generate reports — all through natural language. Read-only by default for safety.

Best for: Data analysis, schema exploration, query debugging, report generation Works with: Claude Code, Cursor, Gemini CLI


Capabilities

  • Schema inspection: List tables, columns, types, constraints, indexes
  • SQL queries: Run SELECT queries with results returned as structured data
  • Data analysis: Ask questions about your data in natural language
  • Query building: Describe what you need, get optimized SQL

Safety

  • Read-only mode by default (SELECT only)
  • Connection string passed as argument, not stored
  • No DDL operations unless explicitly enabled

🙏

Source & Thanks

Created by Anthropic. Licensed under MIT. modelcontextprotocol/servers

Related Assets