
This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

A Model Context Protocol server providing tools for AI assistants to interact with a PostgreSQL database.
PostgreSQL MCP Server is cataloged as an MCP server attributed to leixiaotian1. A Model Context Protocol server providing tools for AI assistants to interact with a PostgreSQL database. 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.
Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.
Catalog license label: MIT License. Check the source repository's current license and terms before using, modifying or distributing this software.
能力定义尚未审核。未核验的采集内容不会作为可信接口展示。
暂无可展示的已审核记录。这不表示上游不支持此能力。
暂无可展示的已审核记录。这不表示上游不支持此能力。
暂无可展示的已审核记录。这不表示上游不支持此能力。
Email delivery is not connected. This page does not collect email addresses or create subscriptions.
Browse the registry for current listings instead.
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.
The server supports stdio, Server-Sent Events (SSE), and Streamable HTTP transport modes.
No, the write_query tool is specifically for INSERT, UPDATE, or DELETE statements.
README.md · d04d36cd74c4 · 采集于 2026-11-13 10:14:40 UTC
保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。
当前显示最后一次成功采集的文档快照,请以来源页面为准。
中文 | English
A Model Context Protocol (MCP) server that provides tools for interacting with a PostgreSQL database. It enables AI assistants to execute SQL queries, explain statements, create tables, and list database tables via the MCP protocol.
read_query, write_query).create_table) and listing (list_tables).explain_query).stdio, Server-Sent Events (sse), and streamableHttp for flexible client integration..env file.The server exposes the following tools for MCP clients to invoke:
| Tool Name | Description | Parameters |
|---|---|---|
read_query | Executes a SELECT SQL query. | query (string, required): The SELECT statement to execute. |
write_query | Executes an INSERT, UPDATE, or DELETE SQL query. | query (string, required): The INSERT/UPDATE/DELETE statement to execute. |
create_table | Executes a CREATE TABLE SQL statement. | schema (string, required): The CREATE TABLE statement. |
list_tables | Lists all user-created tables in the database. | schema (string, optional): The schema name to filter tables by. |
explain_query | Returns the execution plan for a given SQL query. | query (string, required): The query to explain (must start with EXPLAIN). |
Clone the repository:
git clone https://github.com/leixiaotian1/pgsql-mcp-server.git
cd pgsql-mcp-server
Install dependencies:
go mod download
Build the MCP server:
go build -o pgsql-mcp-server
The pg-mcp-server requires database connection details to be provided via environment variables. Create a .env file in the project root with the following variables:
DB_HOST=localhost # PostgreSQL server host
DB_PORT=5432 # PostgreSQL server port
DB_NAME=postgres # Database name
DB_USER=your_username # Database user
DB_PASSWORD=your_pass # Database password
DB_SSLMODE=disable # SSL mode (disable, require, verify-ca, verify-full)
SERVER_MODE=stdio # Server mode (stdio, sse, streamableHttp)
./pgsql-mcp-server
To use this server with an MCP-enabled AI assistant, add the following to your MCP configuration:
{
"mcpServers": {
"pgsql-mcp-server": {
"command": "/path/to/pgsql-mcp-server",
"args": [],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "5432",
"DB_NAME": "postgres",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_SSLMODE": "disable",
"SERVER_MODE": "stdio"
},
"disabled": false,
"autoApprove": []
}
}
}
Clone the project
git clone https://github.com/leixiaotian1/pgsql-mcp-server.git
cd pgsql-mcp-server
Configure .env file
Create a .env file in the project root directory. This file stores database connection information. Ensure the DB_HOST value matches the database container name you'll start later.
DB_HOST=postgres
DB_PORT=5432
DB_NAME=postgres
DB_USER=user
DB_PASSWORD=password
DB_SSLMODE=disable
SERVER_MODE=sse
Create Docker network
To enable communication between the application container and database container, create a shared Docker network. This command only needs to run once.
docker network create sql-mcp-network
Start PostgreSQL database container
Use this command to start a PostgreSQL container and connect it to our network.
Note:
--name postgres: Container name, must exactly match theDB_HOSTin your.envfile.--network sql-mcp-network: Connect to the shared network.-p 5432:5432: Maps host's5432port to container's5432port. This means you can connect from your computer (e.g., using DBeaver) vialocalhost:5432, while the app container will access5432port directly through the internal network.
docker run -d \
--name postgres \
--network sql-mcp-network \
-e POSTGRES_USER=user \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=postgres \
-p 5432:5432 \
postgres
Build and run the application
Now you can use commands from the Makefile to manage the application.
Build image and run container:
make build
make run
This will automatically stop old containers, build a new image, and start a new container.
View application logs:
make logs
If you see Successfully connected to database, everything is working correctly.
Stop the application:
make stop
You can select the transport protocol by setting the SERVER_MODE environment variable.
stdioThe server communicates over standard input and output. This is the default mode and is ideal for local testing or direct integration with command-line-based MCP clients.
sseThe server communicates using Server-Sent Events (SSE). When this mode is enabled, the server will start an HTTP service and listen for connections.
http://localhost:8088/ssehttp://localhost:8088/messagestreamableHttpThe server uses the Streamable HTTP transport, a more modern and flexible HTTP-based transport for MCP.
http://localhost:8088/mcpContributions are welcome! If you find any bugs, have feature requests, or suggestions for improvement, please feel free to submit a Pull Request or open an Issue.
git checkout -b feature/AmazingFeature).git commit -m 'Add some AmazingFeature').git push origin feature/AmazingFeature).This project is open source and is licensed under the MIT License.
Claim this server with your GitHub account to request manual ownership verification.
Link to the catalog listing for PostgreSQL MCP Server from your README. This badge does not certify ownership, compatibility or security.
[](https://awesome-mcp.com/servers/pgsql-mcp-server)Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.
来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。
尚无已审核的包 / 镜像标识,暂不展示下载统计。
Alternative and complementary servers in the same category

This is a Model Context Protocol (MCP) server for interacting with AIStor object stores.

A Model Context Protocol server that lets AI assistants run SQL queries against AWS Athena databases and retrieve results.

A Model Context Protocol (MCP) server that exposes access to an InfluxDB v2 instance using the InfluxDB OSS API v2.