MCP Hub Logo

PostgreSQL Query

Run SQL queries against your PostgreSQL database from your AI assistant. Read-only by default, write mode optional.

postgresqlsqldatabasequeryanalytics
CuratedLast reviewed: Dec 5, 2024No Auth Required

About

PostgreSQL Query

Give your AI assistant direct access to your PostgreSQL database. Explore schemas, write and run queries, inspect tables, and analyze data without leaving your conversation.

Read-only by default. Set ALLOW_WRITES=true to enable INSERT/UPDATE/DELETE.

Setup

{
  "mcpServers": {
    "postgresql-query": {
      "command": "npx",
      "args": ["-y", "@mcpnodehub/postgresql-query"],
      "env": {
        "DATABASE_URL": "postgresql://user:pass@host:5432/dbname",
        "ALLOW_WRITES": "false"
      }
    }
  }
}

Example Prompts

  • "List all tables in my database"
  • "Show me the 10 most recent orders"
  • "What is the schema of the users table?"
  • "How many signups happened in the last 30 days?"

Permissions & Access

Permissions Required

read:database

External Systems Accessed

PostgreSQL