- Home
- MCP servers
- PostgreSQL
PostgreSQL
- typescript
0
GitHub Stars
typescript
Language
7 months ago
First Indexed
3 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"currentspace-pg_mcp_prod": {
"command": "./start_mcp.sh",
"args": [],
"env": {
"RDS_HOST": "your-database.rds.amazonaws.com",
"SSH_HOST": "your-ec2-instance.amazonaws.com",
"SSH_USER": "ec2-user",
"POSTGRES_DB": "your_database",
"SSH_KEY_PATH": "/path/to/ssh/key",
"POSTGRES_USER": "readonly_user",
"POSTGRES_PASSWORD": "your_password"
}
}
}
}You can securely read data from a PostgreSQL database through an SSH-tunneled MCP server that enforces read-only access, supports query timeouts, and offers convenient tools to explore schemas and data without risking modifications.
How to use
Connect to the MCP server from your client and run read-only queries against your PostgreSQL database through the established SSH tunnel. Use the provided tools to query data, list tables, describe schemas, and analyze tables. All operations run in read-only mode, with a 15-second timeout to prevent long-running queries. If you need to integrate with your application, use the standard MCP client workflow exposed by the server (no write operations are permitted). You can start the server locally and then connect your client or use a remote MCP endpoint if that becomes available.
How to install
Prerequisites you need before installing this MCP server are Node.js v24 or newer and the pnpm package manager. You also need access to your PostgreSQL database and SSH access to the database server.
# Install dependencies
pnpm install
# Build the server
pnpm run build
# Start the MCP server
./start_mcp.sh
# Development mode with hot reload
./start_mcp.sh dev
Additional configuration and notes
Configuration involves preparing a local environment file with your database and SSH details, and setting up a read-only user in PostgreSQL.
# PostgreSQL Database Configuration
POSTGRES_DB=your_database
POSTGRES_USER=readonly_user
POSTGRES_PASSWORD=your_password
# SSH Tunnel Configuration
SSH_HOST=your-ec2-instance.amazonaws.com
SSH_USER=ec2-user
SSH_KEY_PATH=/path/to/ssh/key
# RDS Configuration
RDS_HOST=your-database.rds.amazonaws.com
Security and access control
All queries are validated to run within read-only transactions, and a 15-second timeout is enforced for every operation. Connections are encrypted via SSH, and credentials are stored outside the repository.
Available tools
postgres_query
Execute read-only SQL queries against the PostgreSQL database through the MCP server.
postgres_list_tables
List all tables with optional row counts to understand the data structure.
postgres_describe_table
Provide detailed schema information for a specific table.
postgres_analyze_table
Analyze a table to surface data quality issues and statistics.
postgres_find_related
Identify foreign key relationships and related tables.
postgres_explain_query
Return the execution plan for a given query to analyze performance.