What is Postgres Mcp?
Postgres Mcp is a lightweight MCP (Model Context Protocol) server for querying a Postgres database using SQL or plain English commands. It provides tools for database operations, table introspection, and query execution with smart permission handling, intended for use with MCP-enabled AI assistants.
How to use Postgres Mcp?
Configure the server in an mcpServers JSON block with environment variables POSTGRES_HOST, POSTGRES_USER, POSTGRES_PASSWORD, and POSTGRES_DATABASE (and optionally POSTGRES_PORT, POSTGRES_SSL, etc.). On macOS/Linux use npx -y @freakynit/postgres-mcp@latest as the command; on Windows use cmd /k npx -y @freakynit/postgres-mcp@latest.
Key features of Postgres Mcp
- Smart query permission handling (read-only, read-write, admin/DDL)
- Dry-run mode to validate queries without execution
- Comprehensive table introspection (columns, keys, indexes, triggers, constraints)
- Multiple database switching capability
- Robust error handling and rollback
Use cases of Postgres Mcp
- Ask an AI assistant to list all tables and describe their schemas
- Execute read-only queries (SELECT, EXPLAIN) with automatic approval
- Run INSERT/UPDATE/DELETE queries after user confirmation
- Switch between multiple Postgres databases in one session
- Safely test SQL statements using dry-run mode
コメント