Postgres MCP server for querying PostgreSQL databases

Postgres MCP server for querying PostgreSQL databases

postgres-mcp-freakynit•byfreakynit

A Model Context Protocol server that lets clients query a Postgres database, introspect tables, and switch between databases with permission-aware handling.

License: MIT License•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Executes raw SQL queries with permission validation and dry-run support.
  • •Lists all non-system tables in the connected database.
  • •Describes tables with columns, indexes, triggers, and constraints.
  • •Switches the active database connection between multiple databases.

BEST FOR

  • •Querying a PostgreSQL database from an MCP-enabled client using SQL.
  • •Inspecting table structure, keys, indexes, and constraints through a database tool.
  • •Working across several databases by switching the active connection.

ABOUT POSTGRES-MCP-FREAKYNIT

Postgres MCP server for querying PostgreSQL databases is cataloged as an MCP server attributed to freakynit. A Model Context Protocol server that lets clients query a Postgres database, introspect tables, and switch between databases with permission-aware handling. It is categorized under databases storage. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.

Capability inspector

Capability definitions are not reviewed. Unreviewed imports are not exposed as trusted interfaces.

Tools (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Resources (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

Prompts (0)

No reviewed records to display. This does not establish that upstream lacks this capability.

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Postgres MCP server for querying PostgreSQL databases are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

How are queries handled based on their permission level?

Read-only queries are automatically approved, read-write queries require user confirmation, and admin or DDL queries require elevated permission.

Can queries be validated before execution?

Yes, a dry-run mode allows validating queries without executing them.

Upstream README

View this exact version on GitHub

README.md · 478da8abc36a · Fetched 2026-11-13 11:53:31 UTC

Original upstream text, without AI rewriting. Scripts, forms and unsafe links are filtered for safety.

Showing the last retrieved documentation snapshot; check the source for current changes.

Postgres MCP

A lightweight MCP (Model Context Protocol) server built to query Postgres database using SQL or plain English commands. It provides comprehensive tools for database operations, table introspection, and query execution with smart permission handling.

Features

Smart Query Permission Handling

  • Read-only queries: Automatically approved (SELECT, EXPLAIN, SHOW, VALUES)
  • Read-write queries: User confirmation required (INSERT, UPDATE, DELETE, MERGE)
  • Admin/DDL queries: Elevated permission required (CREATE, ALTER, DROP, etc.)
  • Dry-run mode: Validate queries without execution

Comprehensive Table Introspection

  • Column definitions with types and constraints
  • Primary and foreign key relationships
  • Index definitions
  • Triggers and check constraints

Database Management

  • Multiple database switching capability
  • Robust error handling and rollback

Available Tools

ToolDescription
execute_raw_queryExecute SQL queries with permission validation and dry-run support
list_tablesList all non-system tables
describe_tablesGet comprehensive table information including columns, indexes, triggers, and constraints
switch_databaseSwitch the active database connection

Minimum needed environment variables

  1. POSTGRES_HOST
  2. POSTGRES_USER
  3. POSTGRES_PASSWORD
  4. POSTGRES_DATABASE

Other environment variables

  1. POSTGRES_PORT
  2. POSTGRES_SSL (boolean)
  3. POSTGRES_VERIFY (boolean)
  4. POSTGRES_SEND_RECEIVE_TIMEOUT (in seconds)
  5. POSTGRES_CONNECT_TIMEOUT (in seconds)

Configuring using mcpServers json

For Mac and Linux

{
  "mcpServers": {
    "postgres-mcp": {
      "command": "npx",
      "args": ["-y", "@freakynit/postgres-mcp@latest"],
      "env": {
        "POSTGRES_HOST": "<POSTGRES HOST>",
        "POSTGRES_USER": "<POSTGRES USER>",
        "POSTGRES_PASSWORD": "<POSTGRES PASSWORD>",
        "POSTGRES_DATABASE": "<POSTGRES DATABASE>"
      }
    }
  }
}

For Windows

{
  "mcpServers": {
    "postgres-mcp": {
      "command": "cmd",
      "args": ["/k", "npx", "-y", "@freakynit/postgres-mcp@latest"],
      "env": {
        "POSTGRES_HOST": "<POSTGRES HOST>",
        "POSTGRES_USER": "<POSTGRES USER>",
        "POSTGRES_PASSWORD": "<POSTGRES PASSWORD>",
        "POSTGRES_DATABASE": "<POSTGRES DATABASE>"
      }
    }
  }
}

Development Docs

Prerequisites

  • Node.js
  • A PostgreSQL server

Installation

npm i -g @freakynit/postgres-mcp

OR

git clone https://github.com/freakynit/postgres-mcp.git
cd postgres-mcp
npm install

Configuration

Create a .env file in the project root with the following variables:

# PostgreSQL
POSTGRES_HOST=your-db-host
POSTGRES_PORT=5432                      # Optional, default 5432
POSTGRES_USER=your-username
POSTGRES_PASSWORD=your-password
POSTGRES_DATABASE=your-database

# SSL settings (optional)
POSTGRES_SSL=false                      # Or true
POSTGRES_VERIFY=false                   # Verify server cert if SSL true

# Timeouts (optional, seconds)
POSTGRES_SEND_RECEIVE_TIMEOUT=60        # Query timeout
POSTGRES_CONNECT_TIMEOUT=60             # Connection timeout

Usage

Local Development

Start the server (Starts in stdio mode):

node src/index.js

With MCP Inspector

For debugging and development:

npx @modelcontextprotocol/inspector node src/index.js

Debugging with MCP inspector

npx @modelcontextprotocol/inspector node src/index.js

License

This project is licensed under the MIT License. See LICENSE for details.

Postgres-MCP Server Avatar Image

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Postgres MCP server for querying PostgreSQL databases from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/postgres-mcp-freakynit)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

Downloads and pulls

Separate sources, scopes and periods. Never combined or treated as installations, active users or security reviews.

No reviewed package or image identity; download statistics are not listed yet.

Related databases storage MCP Servers

Alternative and complementary servers in the same category

View all in databases storage →
AIStor MCP server
mcp-server-aistor•minio

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

Repository stats unavailable
Databases & Storage
InfluxDB v2 MCP Server
influxdb-mcp-server•idoru

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.

Repository stats unavailable
Databases & Storage