pg-query
Execute read-only SQL queries against the connected PostgreSQL database.The SQL query to execute
All queries are executed within a READ ONLY transaction for safety.
Example Usage
Response
Returns query results as a JSON array of row objects:pg-explain
Generate execution plan for SQL queries against the connected PostgreSQL database.The SQL query to explain
Example Usage
Response
Returns the PostgreSQL query execution plan showing access methods, costs, and row estimates:pg-stats
Get comprehensive statistics for a specific table in the connected database.The name of the table to retrieve statistics for
Example Usage
Response
Returns detailed table statistics including:pg-connect
Connect to a PostgreSQL database with specified credentials.PostgreSQL connection string in format
postgresql://host:port/dbname or host:port/dbname (credentials should not be included in the connection string)PostgreSQL username
PostgreSQL password
Example Usage
Supported Connection Formats
postgresql://host:port/dbnamehost:port/dbname
SSL/TLS Encryption
To enable SSL encryption, append?sslmode=require to the connection string:
PG_SSL environment variable to true.
When using Docker on macOS, use
host.docker.internal to connect to databases running on localhost.Response
pg-awr
Generate a comprehensive PostgreSQL performance report similar to Oracle AWR.This tool requires the
pg_stat_statements extension for detailed query statistics. The report will still generate without it, but with limited query-level data.Example Usage
Response
Returns a comprehensive performance report including: Database Statistics:- Connection information and uptime
- Transaction and commit/rollback rates
- Cache hit ratios
- Database size and growth
- Queries by total execution time
- Queries by number of calls
- Queries by mean execution time
- I/O statistics per query
- Sequential vs index scan ratios
- Dead tuple counts
- Last vacuum and analyze timestamps
- Table and index sizes
- Index usage patterns
- Index sizes and scan counts
- Missing indexes
- Tables needing vacuum
- Configuration suggestions
Resources
The server automatically provides schema information for all tables in the connected database:Table Schemas
URI Format:postgres://<dbname>/<table>/schema
Returns JSON schema information including:
- Column names and data types
- Constraints and indexes
- Automatically discovered from database metadata
Configuration
The PostgreSQL server supports two methods for credential management:Environment Variables
Runtime Connection
Use thepg-connect tool to establish connections dynamically without environment variables.
Connection strings should contain only host, port, and database information. Credentials are always passed separately via environment variables or the connect tool.