Registry / devops / postgres-ssh-mcp

postgres-ssh-mcp

JSON →
library0.1.4jsnpmunverified

An MCP server for PostgreSQL with SSH tunnel support, enabling AI assistants like Claude to query and introspect databases through direct, SSH config, or explicit SSH connections. Version 0.1.4 is the latest stable release. It provides read-only query execution, EXPLAIN plans, schema/table listing, and connection status monitoring. Unlike other PostgreSQL MCP servers, it natively handles SSH tunneling for bastion hosts, supporting both SSH config aliases and explicit credentials. Works cross-platform on macOS, Linux, and Windows.

npm install postgres-ssh-mcp
INSTALL
IMPORT
SIG · POSTGRES-SSH-MCP
P
postgres-ssh-mcp
devopsjavascriptv0.1.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

server (config-based)
Add JSON configuration to MCP client as shown in README
Installing globally or requiring as a library
This package is a CLI tool, not a library. Use via MCP client configuration with npx.

Example configuration for connecting to a PostgreSQL database through the MCP server.

// Configure your MCP client (e.g., Claude Desktop) with: { "mcpServers": { "postgres-ssh-mcp": { "command": "npx", "args": ["-y", "postgres-ssh-mcp"], "env": { "DB_HOST": "localhost", "DB_NAME": "mydb", "DB_USER": "dbuser", "DB_PASSWORD": "dbpassword" } } } } // Or via Claude Code CLI: claude mcp add --transport stdio postgres-ssh-mcp \ --env DB_HOST=localhost \ --env DB_NAME=mydb \ --env DB_USER=dbuser \ --env DB_PASSWORD=dbpassword \ -- npx -y postgres-ssh-mcp
Debug
Known issues
gotchaSSH_HOSTNAME requires both SSH_USER and SSH_HOSTNAME; setting only one may cause connection failure
fix
Always set both SSH_HOSTNAME and SSH_USER if using explicit SSH; or use SSH_HOST for SSH config alias.
affects: <0.1.4
gotchaQueries are read-only by default; if DB_READ_ONLY is set to false, destructive queries are allowed
fix
Set DB_READ_ONLY=true for safety (default) or use parameterized queries to prevent injection.
affects: >=0.1.0
deprecatedSSH_KEY_PASSPHRASE may be deprecated in future; prefer setting SSH_KEY without passphrase or using SSH config
fix
Use SSH config alias (SSH_HOST) with IdentityFile set in ~/.ssh/config instead.
affects: <0.1.4
Errors
Common errors & fixes
Error: Cannot find module 'postgres-ssh-mcp'
Running directly without npx -y or global install
fix
Use 'npx -y postgres-ssh-mcp' or install globally with 'npm install -g postgres-ssh-mcp'.
Error: All DB_HOST, DB_NAME, DB_USER, DB_PASSWORD env vars must be set
Missing one or more required database environment variables
fix
Check that DB_HOST, DB_NAME, DB_USER, and DB_PASSWORD are all defined in the MCP server env.
Error: Could not resolve SSH config: No such host
SSH_HOST set to an alias not present in ~/.ssh/config
fix
Verify the SSH config alias exists in ~/.ssh/config or use explicit SSH_HOSTNAME/SSH_USER.
Error: connect ECONNREFUSED 127.0.0.1:5432
PostgreSQL is not running or SSH tunnel failed to establish
fix
Check that PostgreSQL is running and accessible; for SSH tunnels, verify SSH credentials and network.
Upgrade
Version history
0.1.4latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
5 hits · last 30 days
node
4
Resources
postgres-ssh-mcp — npm install postgres-ssh-mcp · libregistry