PostgreSQL MCP Server

PostgreSQL MCP Server

postgresql-mcp•bytobecrazy

A Model Context Protocol server that provides Create, Read, Update, and Delete operations on configured PostgreSQL database tables.

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

WHAT IT DOES

  • •Performs create, read, update, and delete operations on specified PostgreSQL tables through MCP tools.
  • •Enforces table and column-level access control based on a YAML configuration file.
  • •Lists configured tables and returns schema information for a specific table.
  • •Executes custom SQL queries with parameters and returns standardized success or error responses.

BEST FOR

  • •Managing PostgreSQL records from an MCP client with restricted table and column access.
  • •Inspecting PostgreSQL table schemas during an MCP-driven workflow.
  • •Running custom SQL queries against a PostgreSQL database through an MCP tool.

ABOUT POSTGRESQL-MCP

PostgreSQL MCP Server is cataloged as an MCP server attributed to tobecrazy. A Model Context Protocol server that provides Create, Read, Update, and Delete operations on configured PostgreSQL database tables. 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.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

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

Can access to tables and columns be restricted?

Yes. The configuration specifies which tables are accessible, which columns are allowed for operations, and which operations are permitted.

Does the server support custom SQL queries?

Yes. It includes an execute_query tool that executes a custom SQL query with parameters.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 9c0b9519ed37 · 采集于 2026-11-13 12:44:40 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

PostgreSQL MCP Server

A Model Context Protocol (MCP) server that provides CRUD operations for PostgreSQL database tables.

Overview

This MCP server allows you to interact with PostgreSQL databases through a set of tools that provide Create, Read, Update, and Delete (CRUD) operations on specified tables. The server uses the FastMCP library and runs in stdio mode, making it compatible with various MCP clients.

Features

  • Connect to PostgreSQL databases
  • Perform CRUD operations on specified tables
  • Table and column-level access control
  • Schema inspection
  • Custom SQL query execution
  • Configuration via YAML file

Installation

  1. Clone this repository:

    git clone https://github.com/yourusername/postgresql-mcp.git
    cd postgresql-mcp
    
  2. Install the required dependencies:

    pip install -r requirements.txt
    

Configuration

The server is configured using the config.yaml file. This file contains:

  1. Database connection details
  2. Table configurations, including:
    • Which tables are accessible
    • Which columns are allowed for operations
    • Which operations (create, read, update, delete) are allowed

Example configuration:

database:
  host: localhost
  port: 5432
  dbname: postgres
  user: postgres
  password: postgres
  
tables:
  - name: users
    allowed_columns:
      - id
      - name
      - email
      - created_at
    allowed_operations:
      - create
      - read
      - update
      - delete
  
  - name: products
    allowed_columns:
      - id
      - name
      - price
      - description
      - category
    allowed_operations:
      - create
      - read
      - update
      - delete

Usage

Run the MCP server:

python postgresql_mcp_server.py

The server will start in stdio mode, ready to receive commands from an MCP client.

Available MCP Tools

list_tables

Lists all tables available in the configuration.

response = list_tables()

create_record

Creates a new record in the specified table.

response = create_record(
    table_name="users",
    data={
        "name": "John Doe",
        "email": "john@example.com"
    }
)

read_records

Reads records from the specified table with optional filtering.

response = read_records(
    table_name="users",
    filters={"name": "John Doe"},
    limit=10,
    offset=0
)

update_record

Updates a record in the specified table.

response = update_record(
    table_name="users",
    record_id=1,
    data={"email": "newemail@example.com"},
    id_column="id"
)

delete_record

Deletes a record from the specified table.

response = delete_record(
    table_name="users",
    record_id=1,
    id_column="id"
)

execute_query

Executes a custom SQL query.

response = execute_query(
    query="SELECT * FROM users WHERE age > %s",
    params=[18]
)

get_table_schema

Gets the schema information for a specific table.

response = get_table_schema(table_name="users")

Response Format

All tools return responses in a standard format:

{
  "status": "success",
  "message": "Optional message",
  "records": [...],  // For read operations
  "record": {...},   // For create/update operations
  "count": 10        // For read operations
}

Or in case of an error:

{
  "status": "error",
  "message": "Error message"
}

Security Considerations

  • The execute_query tool allows arbitrary SQL execution, which could be a security risk. Consider restricting its use or implementing additional validation.
  • Database credentials are stored in plain text in the config.yaml file. Consider using environment variables or a secure secret management solution in production.
  • The server validates table and column access based on the configuration, but it's important to ensure that the configuration itself is secure.

License

MIT License

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/postgresql-mcp)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

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

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

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