MCP Catalogs
Homepostgresql-ssh-mcp screenshot

postgresql-ssh-mcp

by Zlash65·6·Score 39

PostgreSQL MCP server with SSH tunneling for secure database access through bastion hosts.

databasedeveloper-toolssecurity
2
Forks
3
Open issues
5 mo ago
Last commit
2d ago
Indexed

Overview

This is a full-featured MCP server for PostgreSQL database access with built-in SSH tunneling capabilities. It provides dual transport modes - STDIO for Claude Desktop and HTTP for ChatGPT - making it versatile across different AI environments. The server implements robust security features including read-only defaults, OAuth support, and automatic SSH tunnel management with TOFU (trust on first use) authentication.

Try asking AI

After installing, here are 5 things you can ask your AI assistant:

you:Securely connecting to PostgreSQL databases behind bastion hosts for AI assistants
you:Enabling Claude Desktop to query databases without manual SSH tunnel setup
you:Providing database access to ChatGPT through a secure HTTP endpoint
you:How does the SSH tunneling work?
you:Can I modify database tables with this server?

When to choose this

Choose this server when you need secure PostgreSQL access through SSH tunnels, especially for ChatGPT integration or Claude Desktop in restricted environments.

When NOT to choose this

Don't choose this if you need write access by default (it's read-only-only unless explicitly configured) or if you're not using PostgreSQL.

Tools this server exposes

12 tools extracted from the README
  • execute_query

    Execute SQL with parameterized queries. Results capped by MAX_ROWS.

  • explain_query

    Get EXPLAIN plans in text, JSON, YAML, or XML format. Supports ANALYZE.

  • list_schemas

    List database schemas. Excludes system schemas by default.

  • list_tables

    List tables with row counts and sizes. Optionally include views.

  • describe_table

    Get columns, constraints, and indexes for a table.

  • list_databases

    List all databases with owner, encoding, and size.

  • get_connection_status

    Get pool stats, tunnel state, and connection info.

  • list_active_connections

    Show active connections from pg_stat_activity.

  • list_long_running_queries

    Find queries running longer than a threshold.

  • get_database_version

    Get PostgreSQL server version.

  • get_database_size

    Get database size and largest tables.

  • get_table_stats

    Get vacuum/analyze stats and scan counts for a table.

Comparable tools

supabase-mcpneon-mcppostgres-mcpmysql-mcpshell-mcp

Installation

Claude Desktop (STDIO)

Add to your Claude Desktop config:

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@zlash65/postgresql-ssh-mcp"],
      "env": {
        "DATABASE_URI": "postgresql://user:password@localhost:5432/mydb"
      }
    }
  }
}

ChatGPT (HTTP Server)

DATABASE_URI="postgresql://user:pass@localhost:5432/mydb" npx @zlash65/postgresql-ssh-mcp-http

Then configure ChatGPT to connect to the HTTP endpoint.

FAQ

How does the SSH tunneling work?
The server automatically creates an SSH tunnel to your bastion host and forwards database connections securely through it. No manual `ssh -L` commands needed.
Can I modify database tables with this server?
By default, the server is read-only to ensure safe production use. You can enable writes by setting the READ_ONLY environment variable to 'false'.

Compare postgresql-ssh-mcp with

GitHub →

Last updated · Auto-generated from public README + GitHub signals.