PostgreSQL MCP Server

PostgreSQL MCP Server

postgresql-mcp-ddz•byfanzhenddz

A Model Context Protocol server that lets AI assistants interact with a PostgreSQL database through a standardized interface.

License: Not specified•Runtime: Awaiting documentation review•Category: databases storage

WHAT IT DOES

  • •Executes parameterized SELECT queries and returns their results.
  • •Performs data modification operations such as INSERT, UPDATE and DELETE.
  • •Lists all tables in the database and describes a table's columns, primary keys and foreign keys.
  • •Analyzes query performance with EXPLAIN and runs SHOW statements.

BEST FOR

  • •Assistants that need to explore PostgreSQL schema and table structure.
  • •Running parameterized queries and data modifications against PostgreSQL from an AI assistant.
  • •Diagnosing query performance with EXPLAIN.

ABOUT POSTGRESQL-MCP-DDZ

PostgreSQL MCP Server is cataloged as an MCP server attributed to fanzhenddz. A Model Context Protocol server that lets AI assistants interact with a PostgreSQL database through a standardized interface. 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: Not specified. 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

How does the server prevent SQL injection?

Queries support parameterized input, and the query tool is restricted to SELECT, SHOW, EXPLAIN and WITH statements, with data modifications handled by the execute tool.

Can database connection be configured automatically?

Yes; when environment variables are added to the MCP client configuration, the server connects to the database automatically on startup and the connect_db step can be skipped.

上游原版 README

在 GitHub 查看同一版本原文

README.md · e20f32fef793 · 采集于 2026-11-13 12:57:20 UTC

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

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

PostgreSQL MCP Server

一个基于模型上下文协议(MCP)的 PostgreSQL 数据库操作服务器,让 AI 助手能够通过标准化接口与 PostgreSQL 数据库交互。

功能特性

  • 查询执行:执行带参数化的 SELECT 查询
  • 数据修改:执行 INSERT、UPDATE、DELETE 操作
  • 结构查询:列出数据库表、查看表结构
  • 性能分析:使用 EXPLAIN 分析查询性能
  • 连接管理:支持环境变量自动连接,安全可靠

安装

npm install postgresql-mcp-ddz

或直接使用 npx:

npx postgresql-mcp-ddz

配置

方式一:环境变量自动连接(推荐)

在 MCP 客户端配置中添加环境变量,服务器启动时会自动连接数据库:

{
  "mcpServers": {
    "postgresql-mcp-ddz": {
      "command": "npx",
      "args": ["postgresql-mcp-ddz"],
      "env": {
        "POSTGRES_HOST": "127.0.0.1",
        "POSTGRES_PORT": "5432",
        "POSTGRES_USER": "postgres",
        "POSTGRES_PASSWORD": "your_password",
        "POSTGRES_DB": "your_database"
      }
    }
  }
}

支持的环境变量:

变量名说明必填
POSTGRES_HOST数据库主机地址是
POSTGRES_PORT数据库端口(默认 5432)否
POSTGRES_USER数据库用户名是
POSTGRES_PASSWORD数据库密码是
POSTGRES_DB数据库名称是

方式二:手动连接

不在配置中添加环境变量时,需要通过 connect_db 工具手动连接:

{
  "mcpServers": {
    "postgresql": {
      "command": "npx",
      "args": ["postgresql-mcp-ddz"]
    }
  }
}

可用工具

connect_db

连接到 PostgreSQL 数据库(环境变量配置后可省略此步骤)。

参数:

  • host(字符串,必填):数据库主机地址
  • port(数字,可选):数据库端口,默认 5432
  • user(字符串,必填):数据库用户名
  • password(字符串,必填):数据库密码
  • database(字符串,必填):数据库名称

示例:

{
  "host": "localhost",
  "port": 5432,
  "user": "postgres",
  "password": "password",
  "database": "mydb"
}

query

执行 SELECT 查询并返回结果。

参数:

  • sql(字符串,必填):SQL SELECT 查询语句
  • params(数组,可选):查询参数

示例:

{
  "sql": "SELECT * FROM users WHERE age > $1",
  "params": [18]
}

execute

执行 INSERT、UPDATE 或 DELETE 查询。

参数:

  • sql(字符串,必填):SQL 语句
  • params(数组,可选):查询参数

示例:

{
  "sql": "INSERT INTO users (name, email) VALUES ($1, $2)",
  "params": ["张三", "zhangsan@example.com"]
}

list_tables

列出当前数据库中的所有表。

describe_table

获取指定表的结构信息,包括列、主键和外键。

参数:

  • table(字符串,必填):表名

示例:

{
  "table": "users"
}

explain

使用 EXPLAIN 分析 SQL 查询性能。

参数:

  • sql(字符串,必填):要分析的 SQL 查询

示例:

{
  "sql": "SELECT * FROM users WHERE email = 'test@example.com'"
}

show_statement

执行 SHOW 语句。

参数:

  • sql(字符串,必填):SHOW SQL 语句

示例:

{
  "sql": "SHOW ALL"
}

安全说明

  • query 工具仅允许 SELECT、SHOW、EXPLAIN 和 WITH 查询
  • 数据修改操作请使用 execute 工具
  • 所有查询支持参数化输入,防止 SQL 注入
  • 数据库凭据仅在运行时传递,不会被持久化存储

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-ddz)

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