mcp-postgres is an MCP server designed to give AI agents safe and controlled access to PostgreSQL databases. It enables agents to inspect database structures, execute read-only queries with safety mechanisms like row caps and timeouts, and perform guarded DML (INSERT, UPDATE, DELETE, MERGE) or administrative operations under strict policy controls. The server utilizes PostgreSQL parser-backed SQL classification to enforce safety policies, ensuring that agents can interact with databases reliably while minimizing risks. It supports STDIO transport, making it suitable for integration with desktop, IDE, and CLI agents.
主要功能
01Optional controlled DML mode with database allowlisting and broad UPDATE/DELETE blocking
02PostgreSQL parser-backed SQL classification for robust safety policies
03Optional admin mode requiring confirmation tokens for destructive and privilege-changing operations
04Read-only query tool with single-statement admission, row caps, and timeout controls
050 GitHub stars
06Dedicated inspection tools for databases, schemas, tables, columns, indexes, and constraints
使用案例
01Allow AI agents to inspect database schemas, tables, columns, and other metadata.
02Facilitate guarded DML or administrative operations by AI agents under explicit security policies.
03Enable AI agents to run safe, read-only SQL statements and retrieve JSON-friendly results.