Postgres Mcp Server X
Extended PostgreSQL MCP server with transactional write and column comment tools

Установить Postgres Mcp Server X в Claude Desktop, Claude Code, Cursor
Ставит в Claude Desktop, Claude Code, Cursor и VS Code — сам разбирается с npx, uvx и сборкой из исходников.
$ unyly install postgres-mcp-server-xВпервые? Поставь CLI: curl -fsSL https://unyly.org/install | sh
Пошаговые гайды: как установить Postgres Mcp Server X
Описание
Extended PostgreSQL MCP server with transactional write and column comment tools
README
@modelcontextprotocol/server-postgres 的扩展维护版。上游 0.6.2 只在只读事务中提供 query;本项目保留只读能力,并增加显式写入、原子批处理和字段注释工具。
上游已归档且不再维护。本项目基于其 MIT 许可源码独立发布,来源与固定提交见 NOTICE。
功能
query:在只读事务中执行一条 SQL,结束后回滚。execute_sql:在读写事务中执行一条 SQL,成功提交、失败回滚。execute_batch:按顺序原子执行多条 SQL,任一失败则整批回滚。comment_columns:安全引用 schema、表名、字段名和中文注释,批量设置或清空字段注释。- 可配置资源发现 schema,返回可空性和默认值。
BIGINT无损序列化为字符串,二进制结果序列化为 Base64。- 拒绝多语句注入和客户端事务控制语句,事务统一由服务端管理。
使用
npx -y postgres-mcp-server-x "postgresql://user:password@host:5432/database"
Codex 配置示例:
[mcp_servers.postgres_x]
command = "npx"
args = ["-y", "[email protected]", "postgresql://user:password@host:5432/database"]
[mcp_servers.postgres_x.env]
POSTGRES_MCP_SCHEMA = "ai_agent"
POSTGRES_MCP_WRITE_ENABLED = "true"
也可用 POSTGRES_URL 或 DATABASE_URL 传入连接串,避免将连接串写在参数中。
写入控制
本包是可写扩展版,写工具默认启用。若某个连接只用于查询,可关闭写工具:
POSTGRES_MCP_WRITE_ENABLED=false
单批默认最多 10,000 项,可通过 POSTGRES_MCP_MAX_BATCH_SIZE 调整。数据库账号自身的权限仍然生效;MCP 不会绕过 PostgreSQL 权限。
MCP 工具注解
从 1.0.1 起,tools/list 为每个工具返回四个标准行为提示:
| 工具 | readOnlyHint |
destructiveHint |
idempotentHint |
openWorldHint |
|---|---|---|---|---|
query |
true |
false |
true |
true |
execute_sql |
false |
true |
false |
true |
execute_batch |
false |
true |
false |
true |
comment_columns |
false |
true |
true |
false |
query 使用只读数据库事务。按 MCP 规范,destructiveHint 和 idempotentHint 仅在 readOnlyHint=false 时有意义。三个接受 SQL 的工具可能调用数据库函数或扩展,因此保守声明 openWorldHint=true。
comment_columns 只生成字段注释 SQL,作用范围为当前连接的数据库;它可以覆盖或清空已有注释,因此声明 destructiveHint=true。相同参数重复调用后,最终字段注释相同,因此声明 idempotentHint=true。
这些注解供客户端理解工具行为,实际执行仍受数据库权限和写入开关控制。1.0.1 保留现有 SQL 执行逻辑及默认开启写入的行为。
字段注释示例
调用 comment_columns:
{
"schema": "ai_agent",
"comments": [
{ "table": "sys_user", "column": "username", "comment": "用户名" },
{ "table": "sys_user", "column": "old_field", "comment": null }
]
}
整批在同一个事务内执行。字段不存在、权限不足或任意一条失败时,全部回滚。
开发与验证
npm ci
npm test
真实 PostgreSQL 集成测试:
TEST_POSTGRES_URL="postgresql://postgres:[email protected]:5432/postgres" npm run test:integration
集成测试会创建临时 schema,验证中文与引号注释、批处理失败回滚和最大 BIGINT 精度,结束后删除该 schema。
License
MIT
FAQ
Postgres Mcp Server X MCP бесплатный?
Да, Postgres Mcp Server X MCP бесплатный — установка в пару кликов через Unyly без оплаты.
Нужен ли API-ключ для Postgres Mcp Server X?
Да, требуются переменные окружения: POSTGRES_MCP_WRITE_ENABLED, TEST_POSTGRES_URL. Unyly подставит их в конфиг при установке.
Postgres Mcp Server X — hosted или self-hosted?
Self-hosted: сервер запускается локально на твоей машине командой из раздела установки.
Как установить Postgres Mcp Server X в Claude Desktop, Claude Code или Cursor?
Открой Postgres Mcp Server X на unyly.org, выбери вкладку своего клиента (Claude Desktop, Claude Code, Cursor) и нажми Install — конфиг сгенерируется автоматически, без правки JSON.
Похожие MCP
Postgres
AnthropicQuery your database in natural language
wenb1n-dev/SmartDB_MCP
wenb1n-devConnect to multiple databases at once (MySQL, PostgreSQL, SQL Server, MariaDB, Dameng, Oracle) for operations, health analysis and SQL optimization.
Postgres Server
madhurprashThis server enables interaction with PostgreSQL databases through the Model Context Protocol, optimized for the AWS Bedrock AgentCore Runtime. It provides tools
PostgreSQL
modelcontextprotocolRead-only database access with schema inspection.
Redis
modelcontextprotocolInteract with Redis key-value stores.
SQLite
modelcontextprotocolDatabase interaction and business intelligence capabilities.
mxcp
raw-labsOpen-source framework for building enterprise-grade MCP servers using just YAML, SQL, and Python, with built-in auth, monitoring, ETL and policy enforcement.
julien040/anyquery
julien040Query apps with SQL from a single local-first binary; also connects to PostgreSQL, MySQL and SQLite-compatible databases.
drakonkat/wizzy-mcp-tmdb
drakonkatSearch and retrieve movie, TV show and person information from The Movie Database (TMDB) API.
longevity-genie/opengenes-mcp
longevity-genieQuery the OpenGenes database for aging and longevity research.
Сравнить Postgres Mcp Server X с
Не уверен что выбрать?
Найди свой стек за 60 секунд
Автор?
Embed-бейдж для README
Похожее
Все в категории data
