PostgreSQL MCP Server

PostgreSQL MCP Server

postgres-connector•bymartymarkenson

An MCP server that lets MCP-compatible clients query a PostgreSQL database, test connections, list tables, and run read-only SQL.

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

WHAT IT DOES

  • •Tests the configured PostgreSQL database connection and displays the current configuration with the password hidden.
  • •Retrieves a list of all tables in the public schema of the connected database.
  • •Executes SELECT-only SQL queries against the database with security validation.
  • •Blocks dangerous keywords such as DROP, DELETE, TRUNCATE, ALTER, CREATE, INSERT, and UPDATE, validating each SQL statement individually.

BEST FOR

  • •Querying and exploring a PostgreSQL database from an MCP-compatible client such as Claude Desktop.
  • •Reading table data with read-only SELECT queries while preventing destructive operations.
  • •Listing tables in a database schema to understand its structure.

ABOUT POSTGRES-CONNECTOR

PostgreSQL MCP Server is cataloged as an MCP server attributed to martymarkenson. An MCP server that lets MCP-compatible clients query a PostgreSQL database, test connections, list tables, and run read-only SQL. 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 PostgreSQL MCP Server 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

What SQL operations does the server allow?

Only SELECT statements are permitted; operations like DROP, DELETE, TRUNCATE, ALTER, CREATE, INSERT, and UPDATE are automatically blocked.

How is the database connection configured?

Through environment variables including POSTGRES_HOST, POSTGRES_PORT, POSTGRES_DB, POSTGRES_USER, and POSTGRES_PASSWORD.

Upstream README

View this exact version on GitHub

README.md · 295a79c01489 · Fetched 2026-11-13 08:51:47 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.

PostgreSQL MCP Server

Postgres Icon

An MCP (Model Context Protocol) server for querying a PostgreSQL database. Execute SQL queries, view table details, and manage database connections through MCP-compatible clients.

Key Features

  • Database Connection: Connect to PostgreSQL databases with authentication
  • SQL Execution: Execute SELECT queries with security validation
  • Connection Testing: Test database connection status

Installation

Claude Desktop

Follow these steps for installation:

Step 1: Download the MCP Server

Download the postgres-connector.mcpb file from this repository (located in the root directory).

Step 2: Install the MCP Server

  1. Open Claude Desktop
  2. Navigate to Settings > Features
  3. Click "Install Extension" and select the postgres-connector.mcpb file

Installation Step 2 Screenshot placeholder: Installing the .mcpb file

Step 3: Configure Database Connection

After installation, the PostgreSQL Connector will appear in your Claude Desktop with default environment variables that you can configure with your database details.

Configuration Screen Screenshot placeholder: Database configuration interface showing environment variables

Step 4: Test the database connection

Send a query "test the database connection" Test Database Connection

Configuration

Required Database Settings

You'll need to provide the following information for your PostgreSQL database:

Environment VariableDescriptionRequiredDefault
POSTGRES_HOSTThe hostname or IP address of your PostgreSQL server✅ Yes-
POSTGRES_PORTThe port number for your PostgreSQL server❌ No5432
POSTGRES_DBThe name of the specific database to connect to✅ Yes-
POSTGRES_USERYour PostgreSQL username✅ Yes-
POSTGRES_PASSWORDYour PostgreSQL password✅ Yes-

These environment variables will be automatically available for configuration in the extension settings panel after installing the extension in Claude Desktop.

Available Tools

1. Test PostgreSQL Connection

Tool: test-postgres-connection

Tests your database connection and displays the current configuration (password hidden for security).

Example Output:

✅ Database connection successful!

Configuration:
{
  "host": "localhost",
  "port": "5432",
  "database": "myapp_production",
  "username": "postgres",
  "password": "***hidden***"
}

Connection test result: [
  {
    "test": 1
  }
]

2. Get All Tables

Tool: get-all-tables

Retrieves a list of all tables in the public schema of your database.

Example Output:

[
  {
    "table_name": "users"
  },
  {
    "table_name": "orders"
  },
  {
    "table_name": "products"
  },
  {
    "table_name": "categories"
  }
]

3. Execute SQL Query

Tool: execute-sql-query

Executes SELECT queries on your database with security validation.

Input:

  • sql: The SQL query to execute (SELECT statements only)

Example Usage:

SELECT id, name, email FROM users LIMIT 5;

Example Output:

[
  {
    "id": 1,
    "name": "John Doe",
    "email": "john@example.com"
  },
  {
    "id": 2,
    "name": "Jane Smith",
    "email": "jane@example.com"
  }
]

Security & Safety

SQL Query Validation

The PostgreSQL MCP server includes security measures:

  • READ-ONLY Operations: Only SELECT statements are permitted
  • Dangerous Keywords Blocked: DROP, DELETE, TRUNCATE, ALTER, CREATE, INSERT, UPDATE operations are automatically blocked
  • Statement-Level Validation: Each SQL statement is validated individually
  • Safe Error Handling: Database errors are caught and displayed safely

Best practice is to create a read-only database user for the postgres connector to use.

Blocked Operations

The following SQL operations are NOT ALLOWED for security:

  • DROP (deleting tables/databases)
  • DELETE (removing data)
  • TRUNCATE (clearing tables)
  • ALTER (modifying structure)
  • CREATE (creating new objects)
  • INSERT (adding data)
  • UPDATE (modifying data)

Usage Examples

Get Database Tables

Use the get-all-tables tool to retrieve all tables in your database schema.

Execute Queries

Use the execute-sql-query tool with SELECT statements:

SELECT * FROM users LIMIT 10;

Troubleshooting

Connection Issues

Problem: "Database connection failed"

  • Check: Verify your host, port, database name, username, and password
  • Check: Ensure your PostgreSQL server is running and accessible
  • Check: Verify that your database user has the necessary permissions

Problem: "Connection timeout"

  • Check: Your database server might be behind a firewall
  • Check: The host address and port number are correct
  • Check: Network connectivity to the database server

Query Issues

Problem: "Dangerous operation detected"

  • Cause: You're trying to execute a non-SELECT statement
  • Solution: Only SELECT queries are allowed for security reasons

Problem: "Query execution failed"

  • Check: Your SQL syntax is correct
  • Check: The tables and columns you're referencing exist
  • Check: Your database user has SELECT permissions on the tables

Configuration Issues

Problem: MCP server not appearing in Claude Desktop client

  • Solution: Restart Claude Desktop
  • Check: Verify the .mcpb file was installed correctly
  • Check: Look for any error messages in Claude Desktop's console

Problem: Environment variables not showing up

  • Solution: Restart Claude Desktop after installation
  • Check: Ensure the extension is enabled in Settings > Features

Problem: Cannot configure database settings

  • Solution: Make sure all required environment variables are filled out
  • Check: Verify your database credentials are correct

Technical Details

System Requirements

  • PostgreSQL database (version 9.0 or higher)
  • Network access to your PostgreSQL server

Dependencies

  • Node.js runtime
  • PostgreSQL client libraries
  • MCP (Model Context Protocol) framework

Project Structure

postgres-connector/
├── src/
│   └── server.ts          # Main MCP server implementation
├── package.json           # Node.js dependencies
├── manifest.json          # MCP extension manifest
├── icon.png              # Extension icon
└── postgres-connector.mcpb # Compiled extension bundle

License

MIT License - see the LICENSE file for details.

Author

Marty Markenson


Need help? Open an issue in this repository or reach out to martymarkenson

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 PostgreSQL MCP Server 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-connector)

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