
全访问Postgres mcp服务器
概览
一个强大的模型上下文协议服务器,为PostgreSQL数据库提供服务。与只读的官方MCP PostgreSQL服务器不同,这一增强实现使大型语言模型(LLM)能够在适当的事务管理和安全控制下查询和修改数据库内容。 - 安全执行DML操作(插入、更新、删除)- 使用DDL创建、修改和管理数据库对象- 带显式提交的事务管理 - 安全超时和自动回滚保护 - 详细的列元数据(数据类型、描述、最大长度、可空性)- 主键识别 - 外键关系 - 带有类型和唯一性标志的索引信息 - 表行计数估计 - 表和列描述(如可用) - SQL 查询分类(DQL、DML、DDL、DCL、TCL) - 强制只读执行以安全查询 - 所有操作在独立事务中运行 - 自动事务超时监控 - 可配置安全限制 - 两步......
概述(AI 翻译)
一个强大的模型上下文协议服务器,提供对PostgreSQL数据库的完整读写访问。与只读官方MCP PostgreSQL服务器不同,这种增强的实现允许大型语言模型(LLMs)在适当的事务管理和安全控制下查询和修改数据库内容。
目录
- 特色
- 完全读写访问
- 丰富模式信息
- 高级安全控制
- 工具
- execute_query
- execute_dml_ddl_dcl_tcl
- execute_maintenance
- execute_commit
- execute_rollback
- list_tables
- describe_table
- 资源
- 与 Claude Desktop 结合使用
- Claude桌面集成
- 重要提示:使用“允许一次”以保证安全
- 环境变量
- 使用 Claude 实现全数据库访问
- 安全考量
- 数据库用户权限
- 安全使用的最佳实践
- Docker
- 许可证
- 与官方PostgreSQL MCP服务器的比较
🌟 特色
完全读写访问
- 安全执行DML操作(插入、更新、删除)
- 使用 DDL 创建、修改和管理数据库对象
- 带有显式提交的事务管理
- 安全超时和自动回滚保护
丰富的模式信息
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
PostgreSQL Full Access MCP Server
A powerful Model Context Protocol server providing full read-write access to PostgreSQL databases. Unlike the read-only official MCP PostgreSQL server, this enhanced implementation allows Large Language Models (LLMs) to both query and modify database content with proper transaction management and safety controls.
Table of Contents
- Features
- Tools
- Resources
- Using with Claude Desktop
- Environment Variables
- Using Full Database Access with Claude
- Security Considerations
- Docker
- License
- Comparison with Official PostgreSQL MCP Server
🌟 Features
Full Read-Write Access
- Safely execute DML operations (INSERT, UPDATE, DELETE)
- Create, alter, and manage database objects with DDL
- Transaction management with explicit commit
- Safety timeouts and automatic rollback protection
Rich Schema Information
- Detailed column metadata (data types, descriptions, max length, nullability)
- Primary key identification
- Foreign key relationships
- Index information with type and uniqueness flags
- Table row count estimates
- Table and column descriptions (when available)
Advanced Safety Controls
- SQL query classification (DQL, DML, DDL, DCL, TCL)
- Enforced read-only execution for safe queries
- All operations run in isolated transactions
- Automatic transaction timeout monitoring
- Configurable safety limits
- Two-step transaction commit process with explicit user confirmation
🔧 Tools
-
execute_query
- Execute read-only SQL queries (SELECT statements)
- Input:
sql(string): The SQL query to execute - All queries are executed within a READ ONLY transaction
- Results include execution time metrics and field information
-
execute_dml_ddl_dcl_tcl
安装
npx -y mcp-postgres-full-access postgresql://username:password@localhost:5432/database配置
{
"mcpServers": {
"postgres-full": {
"command": "npx",
"args": [
"-y",
"mcp-postgres-full-access",
"postgresql://username:password@localhost:5432/database"
],
"env": {
"TRANSACTION_TIMEOUT_MS": "60000",
"MAX_CONCURRENT_TRANSACTIONS": "5",
"PG_STATEMENT_TIMEOUT_MS": "30000"
}
}
}
}