
Postgres
io.github.ofershap由 GitHub 账号 ofershap 发布v1.0.0更新于 Oct 24, 2026
PostgreSQL MCP — query databases, inspect schemas, explain queries.
概览
一个本地 MCP 服务器,让 AI 助手查询 PostgreSQL 数据库、查看模式和表结构,并解释查询计划。
- 可以做什么
- 执行 SQL 查询(SELECT、WITH、EXPLAIN、SHOW、ANALYZE),以文本表格返回结果,支持单次调用覆盖连接字符串,并在关闭只读时允许写入。列出非系统模式及模式中的表、列和大致行数。查看单张表的列、类型、是否可空、默认值、主键和精确行数。以文本格式解释查询计划,可选带 ANALYZE。
- 适用场景
- 适用于使用本地或开发环境 PostgreSQL 数据库时,希望助手在不离开 IDE 或聊天客户端的情况下浏览模式、执行只读查询并理解查询计划。
- 运行要求
- 通过 npm 包 mcp-pg-server 以 npx 在本地运行,需要 Node.js。需要 PostgreSQL 连接,通过 DATABASE_URL 环境变量或单次调用的 connectionString 提供。需要能访问数据库主机的网络。
安装
在 SourceWeft 中
- 打开 控制台中的 Postgres,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
mcp-server-postgres
[npm version] [npm downloads] [CI] [TypeScript] [License: MIT]
Query PostgreSQL, inspect schemas, and explain queries from your AI assistant. A daily-driver MCP for local and dev Postgres — same belt as docker and sqlite servers, not an enterprise DBA suite.
Works with Claude Desktop, Cursor, VS Code Copilot, and any MCP client. Connects via
DATABASE_URLor per-callconnectionString.
Why
Postgres is the default for most new backends, local dev stacks, and agent workflows that need a real SQL database. You already run it in Docker or on localhost — this server lets your assistant query it, read schemas, and explain plans without leaving the IDE. Read-only by default so exploration stays safe; opt into writes when you need them.
Tools
Quick Start
Cursor
Add to .cursor/mcp.json:
Claude Desktop
Add to claude_desktop_config.json (macOS: ~/Library/Application Support/Claude/claude_desktop_config.json):
VS Code
Configure the MCP server in your VS Code settings to run npx mcp-pg-server with DATABASE_URL set.
Example prompts
- "Show me the schema of the public tables"
- "Query users: SELECT * FROM users LIMIT 10"
- "Explain this join query"
- "What schemas exist in this database?"
- "How many rows are in the orders table?"
Safety
Read-only by default. The query tool accepts only SELECT, WITH, EXPLAIN, SHOW, and ANALYZE in readonly mode. Set readonly=false to enable INSERT, UPDATE, DELETE, and DDL.
Pass connectionString on any tool to override DATABASE_URL for a single call.
Development
See also
More MCP servers and developer tools on my portfolio.
Author
License
MIT © 2026 Ofer Shapira
来源:README.md,提交 6b813b6
工具
0版本历史
1- v1.0.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分