pg-mcp-server
The PostgreSQL Model Context Protocol (PG-MCP) Server is a comprehensive solution for integrating AI agents with PostgreSQL databases. Key features include robust connection management, advanced query and schema discovery tools, and support for extensions like PostGIS. It's built for seamless database interaction via an enhanced API, ensuring secure and efficient data management.
PostgreSQL Model Context Protocol (PG-MCP) Server
PG-MCP is a server implementation of the Model Context Protocol for PostgreSQL databases, offering an API for AI agents to discover, query, and manage PostgreSQL databases. It extends the reference Postgres MCP implementation with features such as multi-database support, robust connection management, and detailed schema discovery tools.
Features
- Connection Management: Tools for registering, managing, and pooling connections
- Query Tools: Execute SQL queries, analyze execution plans
- Schema Discovery: Access schema details, tables, columns, constraints
- Data Access: Paginate table data, approximate row counts
- Extension Context: Contextual information for extensions like PostGIS, pgvector
Installation
Requires Python 3.13+ and a PostgreSQL database. Can be run with Docker or manually installed.
Usage
Includes test scripts to verify functionality, with support for natural language to SQL conversion using AI.
Architecture
Built on MCP, FastMCP, asyncpg, and YAML for extension contexts.
Security Considerations
- Read-only mode by default
- Secure handling of connection IDs
Contributing
Open for extensions and improvements in conjunction with PostgreSQL features.