Skip to main content
Glama
ferronicardoso

mcp-postgresql

MCP-Server für PostgreSQL

Docker Publish GHCR Node.js

Produktionsorientierter MCP-Server für PostgreSQL, der Datenbankoperationen für MCP-Clients (Claude Desktop, VS Code Copilot, Cursor und kompatible Hosts) bereitstellt.

Funktionen

  • Abfrageausführung (SELECT, INSERT, UPDATE, DELETE)

  • Datenbankerkennung und Schema-Introspection

  • Tabellenmetadaten-Inspektion (Spalten, Typen, Nullable, Defaults, PK)

  • Index- und Fremdschlüsselerkennung

  • Umgebungsgesteuerte Konfiguration für sicheren Einsatz

Related MCP server: Azure Database for PostgreSQL MCP Server

Verfügbare Tools

Tool

Beschreibung

execute_query

Führt eine SQL-Anweisung aus und gibt Zeilen oder die Anzahl betroffener Zeilen zurück

list_tables

Listet Tabellen aus INFORMATION_SCHEMA.TABLES auf (optionaler Schema-Filter)

describe_table

Gibt Tabellenspalten-Metadaten und Primärschlüssel-Markierungen zurück

list_databases

Listet alle PostgreSQL-Datenbanken auf

get_table_indexes

Listet Tabellenindizes mit Definitionen und PK/Unique-Flags auf

get_foreign_keys

Listet Fremdschlüssel einer Tabelle und referenzierte Ziele auf

Voraussetzungen

  • Node.js 18+

  • Zugriff auf eine PostgreSQL-Instanz

  • Netzwerkverbindung vom MCP-Host zur PostgreSQL (host:port)

Konfiguration

Verbindungseinstellungen über Umgebungsvariablen festlegen:

Variable

Erforderlich

Standard

Beschreibung

PGHOST (oder POSTGRES_HOST)

Nein

localhost

PostgreSQL-Host oder IP

PGPORT (oder POSTGRES_PORT)

Nein

5432

PostgreSQL-TCP-Port

PGDATABASE (oder POSTGRES_DB)

Nein

postgres

Standarddatenbank

PGUSER (oder POSTGRES_USER)

Ja

Datenbankbenutzer

PGPASSWORD (oder POSTGRES_PASSWORD)

Ja

Datenbankpasswort

PGSSL (oder POSTGRES_SSL)

Nein

false

Aktiviert SSL/TLS

PGPOOL_MAX

Nein

10

Maximale Pool-Verbindungen

PGPOOL_IDLE_TIMEOUT_MS

Nein

30000

Pool-Leerlauf-Timeout (ms)

MCP_TRANSPORT

Nein

stdio

Transportmodus: stdio (Standard, für npx/Claude Desktop/VS Code) oder http (Streamable HTTP, für Docker/Remote-Clients wie n8n)

MCP_HTTP_PORT

Nein

3002

Port für den HTTP-Server (nur verwendet, wenn MCP_TRANSPORT=http)

MCP_HTTP_HOST

Nein

0.0.0.0

Bind-Adresse für den HTTP-Server (nur verwendet, wenn MCP_TRANSPORT=http)

Verwendung

Direkt von GitHub ausführen

npx github:ferronicardoso/mcp-postgresql

Claude Code (CLI)

claude mcp add postgresql --scope user -- npx -y github:ferronicardoso/mcp-postgresql

--scope steuert, wo die Server-Registrierung gespeichert wird:

Bereich

Gespeichert in

Sichtbar für

local (Standard)

projektlokal, nicht versioniert

nur für Sie, nur in diesem Projekt

project

.mcp.json im Projektstammverzeichnis

jeder, der das Repository klont (einchecken zum Teilen)

user

Ihrer globalen Claude Code-Konfiguration

Sie, projektübergreifend

Umgebungsvariablen können mit wiederholten --env KEY=VALUE-Flags vor dem -- übergeben werden, z.B.:

Bash (Linux/macOS/WSL):

claude mcp add postgresql --scope user \
  --env PGHOST=localhost \
  --env PGPORT=5432 \
  --env PGDATABASE=postgres \
  --env PGUSER=postgres \
  --env PGPASSWORD=your-password \
  -- npx -y github:ferronicardoso/mcp-postgresql

PowerShell:

claude mcp add postgresql --scope user `
  --env PGHOST=localhost `
  --env PGPORT=5432 `
  --env PGDATABASE=postgres `
  --env PGUSER=postgres `
  --env PGPASSWORD=your-password `
  -- npx -y github:ferronicardoso/mcp-postgresql

Codex CLI

Bash (Linux/macOS/WSL):

codex mcp add postgresql \
  --env PGHOST=localhost \
  --env PGPORT=5432 \
  --env PGDATABASE=postgres \
  --env PGUSER=postgres \
  --env PGPASSWORD=your-password \
  npx -- -y github:ferronicardoso/mcp-postgresql

PowerShell:

codex mcp add postgresql `
  --env PGHOST=localhost `
  --env PGPORT=5432 `
  --env PGDATABASE=postgres `
  --env PGUSER=postgres `
  --env PGPASSWORD=your-password `
  npx -- -y github:ferronicardoso/mcp-postgresql

Dies registriert den Server in ~/.codex/config.toml. Zum Entfernen führen Sie codex mcp remove postgresql aus.

Claude Desktop-Konfiguration

%APPDATA%\\Claude\\claude_desktop_config.json:

{
  "mcpServers": {
    "postgresql": {
      "command": "npx",
      "args": ["github:ferronicardoso/mcp-postgresql"],
      "env": {
        "PGHOST": "localhost",
        "PGPORT": "5432",
        "PGDATABASE": "postgres",
        "PGUSER": "postgres",
        "PGPASSWORD": "your-password"
      }
    }
  }
}

VS Code MCP-Konfiguration

.vscode/mcp.json:

{
  "servers": {
    "postgresql": {
      "command": "npx",
      "args": ["github:ferronicardoso/mcp-postgresql"],
      "env": {
        "PGHOST": "localhost",
        "PGPORT": "5432",
        "PGDATABASE": "postgres",
        "PGUSER": "postgres",
        "PGPASSWORD": "your-password"
      }
    }
  }
}

Mit Docker ausführen (HTTP-Transport)

Das veröffentlichte Image läuft standardmäßig im Streamable HTTP-Modus, zur Verwendung als Remote-MCP-Endpunkt (z.B. vom n8n MCP Client Tool-Knoten oder jedem Streamable HTTP-kompatiblen Client):

Bash (Linux/macOS/WSL):

docker run -d --name mcp-postgresql \
  -p 3002:3002 \
  -e PGHOST=host.docker.internal \
  -e PGPORT=5432 \
  -e PGDATABASE=postgres \
  -e PGUSER=postgres \
  -e PGPASSWORD=your-password \
  ghcr.io/ferronicardoso/mcp-postgresql:latest

PowerShell:

docker run -d --name mcp-postgresql `
  -p 3002:3002 `
  -e PGHOST=host.docker.internal `
  -e PGPORT=5432 `
  -e PGDATABASE=postgres `
  -e PGUSER=postgres `
  -e PGPASSWORD=your-password `
  ghcr.io/ferronicardoso/mcp-postgresql:latest

Der MCP-Endpunkt ist dann unter http://localhost:3002/mcp verfügbar.

Lokale Entwicklung

git clone https://github.com/ferronicardoso/mcp-postgresql
cd mcp-postgresql
npm install
npm run build

Starten Sie den kompilierten Server:

npm start

Build- und Commit-Workflow

Dieses Repository verfolgt absichtlich dist/, um die Verwendung von npx github:user/repo zu unterstützen.

Das Projekt verwendet einen Husky pre-commit-Hook, um:

  1. TypeScript zu bauen (npm run build)

  2. generierte Artefakte zu stagen (git add dist)

Manueller Fallback:

npm run build
git add dist

Sicherheitshinweise

  • Committen Sie niemals echte Anmeldedaten oder .env-Dateien.

  • Bevorzugen Sie Datenbankbenutzer mit minimalen Rechten für den Produktionseinsatz.

  • Aktivieren Sie für öffentliche oder unsichere Netzwerke die Verschlüsselung (PGSSL=true) und konfigurieren Sie Zertifikate entsprechend.

Lizenz

MIT © Raphael Augusto Ferroni Cardoso

Install Server
A
license - permissive license
A
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    An extensible MCP server for database operations that supports PostgreSQL for managing schemas, tables, data, and user permissions. It features automatic migration recording for DDL changes and integrates with various AI-powered editors like Cursor, Zed, and Claude Code.
    22
    2
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol (MCP) Server that allows AI models to securely interact with data hosted in Azure Database for PostgreSQL. It enables natural language querying, schema exploration, and data management through MCP clients like Claude Desktop and Visual Studio Code.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    A production-ready MCP server for PostgreSQL — built for Claude Desktop, Claude Code, and any MCP-compatible AI agent.
    Apache 2.0
  • A
    license
    Not graded
    quality
    C
    maintenance
    A Model Context Protocol (MCP) server that provides secure database access to PostgreSQL through Kysely ORM, enabling Claude Desktop to interact with PostgreSQL databases using natural language.
    22
    1
    ISC

View all related MCP servers

Related MCP Connectors

View all MCP Connectors

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ferronicardoso/mcp-postgresql'

If you have feedback or need assistance with the MCP directory API, please join our Discord server