PostgreSQL MCP Server
PostgreSQL MCP 服务器
一个连接到本地 PostgreSQL 数据库的 MCP (Model Context Protocol) 服务器,使 AI 助手能够查询和管理您的数据库。
提供的工具
工具 | 描述 |
query | 执行只读 SQL (SELECT, SHOW, EXPLAIN) |
execute | 执行写入 SQL (INSERT, UPDATE, DELETE, CREATE, ALTER, DROP) |
list_tables | 列出模式中的所有表 |
describe_table | 显示表的列、类型、键和索引 |
list_schemas | 列出数据库中的所有用户模式 |
Related MCP server: PostgreSQL MCP Server
资源
schema-overview (
postgres://schema/overview) — Markdown 格式的完整数据库模式概览
通过标头进行动态连接
此服务器支持动态 PostgreSQL 连接。您可以在初始 SSE 连接请求中通过 HTTP 标头提供数据库凭据。这允许单个已部署的服务器实例服务于多个不同的数据库。
支持的标头
标头 | 描述 | 默认值 |
| PostgreSQL 主机 |
|
| PostgreSQL 端口 |
|
| PostgreSQL 用户 |
|
| PostgreSQL 密码 |
|
| PostgreSQL 数据库 |
|
| 使用 SSL ( |
|
| CA 证书 |
|
在 Antigravity / Cursor (VS Code) 中配置
要在 Antigravity 或 Cursor 中使用此服务器,请将以下内容添加到您的 mcp_config.json(通常位于 %APPDATA%\antigravity\ 或您的 IDE 的 MCP 设置中):
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"mcp-remote",
"https://postgree-mcp-dfadduf9bsdvdwa9.eastasia-01.azurewebsites.net/sse",
"--header", "x-pg-host: pg-168600c0-aeiyankhan2-d42e.g.aivencloud.com",
"--header", "x-pg-port: 26768",
"--header", "x-pg-user: avnadmin",
"--header", "x-pg-password: YOUR_PASSWORD",
"--header", "x-pg-database: defaultdb",
"--header", "x-pg-ssl: true"
]
}
}
}在 Claude Code CLI 中配置
如果您使用 Claude Code CLI,可以使用以下命令添加此服务器:
1. 安装 Claude Code(如果尚未安装)
npm install -g @anthropic-ai/claude-code2. 添加 PostgreSQL MCP 服务器
在您的终端中运行此命令:
claude mcp add postgres -- npx mcp-remote https://postgree-mcp-dfadduf9bsdvdwa9.eastasia-01.azurewebsites.net/sse \
--header "x-pg-host: pg-168600c0-aeiyankhan2-d42e.g.aivencloud.com" \
--header "x-pg-port: 26768" \
--header "x-pg-user: avnadmin" \
--header "x-pg-password: YOUR_PASSWORD" \
--header "x-pg-database: defaultdb" \
--header "x-pg-ssl: true"在 Claude Desktop 中配置
将此内容添加到您的 claude_desktop_config.json:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"mcp-remote",
"https://postgree-mcp-dfadduf9bsdvdwa9.eastasia-01.azurewebsites.net/sse",
"--header", "x-pg-host: pg-168600c0-aeiyankhan2-d42e.g.aivencloud.com",
"--header", "x-pg-port: 26768",
"--header", "x-pg-user: avnadmin",
"--header", "x-pg-password: YOUR_PASSWORD",
"--header", "x-pg-database: defaultdb",
"--header", "x-pg-ssl: true"
]
}
}
}本地设置(用于开发)
1. 安装依赖项
npm install2. 配置默认数据库(可选)
您仍然可以使用 .env 文件进行本地开发:
PG_HOST=localhost
PG_PORT=5432
PG_USER=postgres
PG_PASSWORD=your_password_here
PG_DATABASE=your_database_name3. 构建并运行
npm run build
npm start使用示例
配置完成后,您可以向 AI 助手询问如下内容:
"列出我数据库中的所有表"
"描述 users 表"
"SELECT * FROM orders WHERE created_at > '2025-01-01'"
"创建一个名为 products 的新表"
This server cannot be installed
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
- AlicenseAqualityDmaintenanceEnables Claude to interact with a local PostgreSQL database through SQL queries, schema inspection, and CRUD operations.8225MIT
- FlicenseNot gradedqualityDmaintenanceEnables AI assistants to interact with PostgreSQL databases through natural language queries, schema inspection, and safe SQL execution.91
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to query and explore PostgreSQL databases with tools for executing SQL queries, listing tables, and describing table structures.MIT
- FlicenseNot gradedqualityCmaintenanceEnables AI models to execute SQL queries, list tables, and describe table structures on a local PostgreSQL database.2
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Comprehensive PostgreSQL documentation and best practices, including ecosystem tools
Explore, query, and inspect SQLite databases with ease. List tables, preview results, and view det…
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/aeiyannn/postgree-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server