Provides comprehensive database access with 36 tools for querying, managing schemas, tables, indexes, views, sequences, JSONB operations, stored procedures, and other PostgreSQL-specific features. Supports both read-only and write operations with security controls, SSL/TLS connections, and connection pooling.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@PostgreSQL MCP Servershow me the structure of the users table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
PostgreSQL MCP Server
A comprehensive Model Context Protocol (MCP) server for PostgreSQL database access. Provides 36 tools for querying, managing, and interacting with PostgreSQL databases through the MCP interface.
Features
36 Database Tools: Complete set of read-only and write operations
PostgreSQL-Specific Features: Schema support, JSONB operations, extensions, functions, triggers, views, sequences
Full SSL/TLS Support: CA certificates, client certificates, configurable TLS versions
Security First: Query validation, rate limiting, blocked dangerous operations
Connection Pooling: Efficient connection management with configurable limits
Audit Logging: Track all database operations
Installation
Configuration
Copy .env.example to .env and configure your PostgreSQL connection:
Required Settings
Variable | Description | Default |
| PostgreSQL server hostname |
|
| PostgreSQL server port |
|
| Database username |
|
| Database password | - |
| Target database name | - |
| Default schema |
|
SSL Configuration
Variable | Description | Options |
| SSL connection mode |
|
| Reject self-signed certs |
|
| Path to CA certificate | - |
| Path to client certificate | - |
| Path to client key | - |
| Minimum TLS version |
|
Security Settings
Variable | Description | Default |
| Enable INSERT/UPDATE/DELETE |
|
| Max pool connections |
|
| Query timeout (ms) |
|
| Maximum rows returned |
|
Rate Limiting
Variable | Description | Default |
| Queries per minute |
|
| Queries per hour |
|
| Concurrent queries |
|
Usage
With Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
With MCP Inspector
Available Tools
Core Read-Only Tools (7)
Tool | Description |
| Execute SELECT queries |
| List all tables in schema |
| Get table structure and columns |
| Get database version and settings |
| List indexes on a table |
| Get query execution plan |
| List table constraints |
PostgreSQL-Specific Read-Only Tools (14)
Tool | Description |
| List all schemas in database |
| Get current search path |
| List installed extensions |
| Get detailed extension information |
| List user-defined functions |
| List triggers on a table |
| List views in schema |
| List sequences in schema |
| Get table statistics |
| Get current connection details |
| Get database/table sizes |
| Query JSONB columns |
| Execute JSON path queries |
Write Operation Tools (15)
Requires
Tool | Description |
| Insert a single row |
| Update rows with conditions |
| Delete rows with conditions |
| Create a new table |
| Modify table structure |
| Drop a table |
| Insert multiple rows |
| Call stored procedures |
| Create an index |
| Remove an index |
| Rename a table |
| Change schema search path |
| Create a new schema |
| Drop a schema |
| Update JSONB fields |
| Optimize table statistics |
MCP Resources
The server exposes database schema as MCP resources:
pg://database/schema- List all tables and columnspg://database/info- Database informationpg://table/{schema}.{table}- Individual table schema
Security Features
Blocked Operations
The server blocks dangerous operations by default:
File system operations (
COPY FROM/TO,pg_read_file, etc.)Permission modifications (
GRANT,REVOKE,ALTER ROLE)Administrative commands (
CREATE ROLE,DROP DATABASE, etc.)System catalog modifications
Protected Tables
Access to sensitive system tables is blocked:
pg_catalog.pg_authidpg_catalog.pg_shadowpg_catalog.pg_auth_members
Query Validation
All identifiers are validated (max 63 characters, safe characters only)
Query timeouts prevent long-running operations
Rate limiting prevents abuse
Setting Up a Read-Only User
For production use, create a dedicated read-only PostgreSQL user:
Or manually:
Development
Troubleshooting
Connection Issues
Verify PostgreSQL is running:
pg_isready -h localhost -p 5432Check credentials:
psql -h localhost -U your_user -d your_databaseEnable debug mode:
MCP_DEBUG=true
SSL Issues
Verify certificate paths are correct
Check certificate permissions (readable by the user running the server)
Try
PG_SSL_MODE=requirefirst, then upgrade toverify-caorverify-full
Rate Limiting
If you're hitting rate limits:
Increase
RATE_LIMIT_PER_MINUTEandRATE_LIMIT_PER_HOURBatch operations where possible
Use more specific queries to reduce call volume
License
MIT