mcp-postgresql
MCP-Server für PostgreSQL
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 |
| Führt eine SQL-Anweisung aus und gibt Zeilen oder die Anzahl betroffener Zeilen zurück |
| Listet Tabellen aus |
| Gibt Tabellenspalten-Metadaten und Primärschlüssel-Markierungen zurück |
| Listet alle PostgreSQL-Datenbanken auf |
| Listet Tabellenindizes mit Definitionen und PK/Unique-Flags auf |
| 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 |
| Nein |
| PostgreSQL-Host oder IP |
| Nein |
| PostgreSQL-TCP-Port |
| Nein |
| Standarddatenbank |
| Ja | — | Datenbankbenutzer |
| Ja | — | Datenbankpasswort |
| Nein |
| Aktiviert SSL/TLS |
| Nein |
| Maximale Pool-Verbindungen |
| Nein |
| Pool-Leerlauf-Timeout (ms) |
| Nein |
| Transportmodus: |
| Nein |
| Port für den HTTP-Server (nur verwendet, wenn |
| Nein |
| Bind-Adresse für den HTTP-Server (nur verwendet, wenn |
Verwendung
Direkt von GitHub ausführen
npx github:ferronicardoso/mcp-postgresqlClaude 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 |
| projektlokal, nicht versioniert | nur für Sie, nur in diesem Projekt |
|
| jeder, der das Repository klont (einchecken zum Teilen) |
| 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-postgresqlPowerShell:
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-postgresqlCodex 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-postgresqlPowerShell:
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-postgresqlDies 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:latestPowerShell:
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:latestDer 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 buildStarten Sie den kompilierten Server:
npm startBuild- 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:
TypeScript zu bauen (
npm run build)generierte Artefakte zu stagen (
git add dist)
Manueller Fallback:
npm run build
git add distSicherheitshinweise
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
Maintenance
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
- AlicenseNot gradedqualityCmaintenanceAn 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.222MIT
- AlicenseNot gradedqualityDmaintenanceA 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
- AlicenseNot gradedqualityCmaintenanceA production-ready MCP server for PostgreSQL — built for Claude Desktop, Claude Code, and any MCP-compatible AI agent.Apache 2.0
- AlicenseNot gradedqualityCmaintenanceA 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.221ISC
Related MCP Connectors
MCP server for managing Prisma Postgres.
MCP server for interacting with the Supabase platform
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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