PostgreSQL
Rank #7,593io.github.antonorlov/mcp-postgres-server
MCP server for PostgreSQL: local, Docker, RDS, Neon, Supabase, or behind an SSH bastion.
What you can do with PostgreSQL
A small Node.js MCP server (mcp-postgres-server) for querying PostgreSQL, read-only by default with writes opt-in via an environment flag, and with SSL, SSH tunnelling, timeouts and a result-size cap built in.
- Run read-only SELECT, WITH, EXPLAIN and SHOW statements
- List schemas and tables, describe a table's columns
- Run INSERT/UPDATE/DELETE or DDL when writes are enabled
- Reach local, Docker, RDS, Neon or Supabase databases
- Switch databases at runtime when explicitly enabled
What PostgreSQL can and cannot do
Six tools: query (one read-only statement), execute (writes, refused unless PG_ALLOW_WRITE=true), list_schemas, list_tables, describe_table and connect_db (registered only with PG_ENABLE_RUNTIME_CONNECT=true). In the default mode each query runs inside BEGIN READ ONLY ... ROLLBACK.
- query
- execute
- list_schemas
- list_tables
- describe_table
- connect_db
- Read-only mode does not stop prompt injection carried in row data; the docs say not to point it at production
- With PG_ALLOW_WRITE=true the query tool loses its read-only wrapper, so a write sent through query would run
- One statement per call; multi-statement input is rejected
- sslmode allow/prefer encrypt without verifying the certificate and do not fall back to plaintext
- SSH host-key verification is mandatory: PG_SSH_FINGERPRINT must be set or the tunnel refuses to connect
What you need before using PostgreSQL
The registry listing declares no required environment variables or authentication. This is declared metadata, not a verified install — the repository README is the authority.
Declared by Glama, last synced Nov 30, 2026. Not independently verified by MCP Toplist.
- Runtime
- Node.js 20+ via npx -y mcp-postgres-server
- Credentials
- DATABASE_URL, or PG_HOST, PG_PORT, PG_USER, PG_PASSWORD, PG_DATABASE
- Permissions
- A least-privilege database role (the server warns on stderr when connected as superuser)
- Also needed
- PG_SSLMODE / PG_SSL_CA for TLS; PG_SSH_* for tunnelling; PG_ALLOW_WRITE=true to enable writes
- DATABASE_URL · optional
- PG_HOST · optional
- PG_PORT · optional
- PG_USER · optional
- PG_PASSWORD · optional
- PG_DATABASE · optional
- PG_ALLOW_WRITE · optional
- PG_SSLMODE · optional
- PG_SSL_CA · optional
- PG_ENABLE_RUNTIME_CONNECT · optional
- PG_MAX_RESULT_BYTES · optional
- PG_STATEMENT_TIMEOUT · optional
- PG_CONNECT_TIMEOUT · optional
- PG_SSH_HOST · optional
- PG_SSH_PORT · optional
- PG_SSH_USER · optional
- PG_SSH_PRIVATE_KEY · optional
- PG_SSH_PASSPHRASE · optional
- PG_SSH_AGENT · optional
- PG_SSH_PASSWORD · optional
- PG_SSH_FINGERPRINT · optional
- PG_SSH_KEEPALIVE_INTERVAL · optional
Connect PostgreSQL and confirm it works
- Add a server entry running npx -y mcp-postgres-server with DATABASE_URL in env
- Create a least-privilege role for the agent and use it in the URL
- Leave PG_ALLOW_WRITE unset for read-only; set it to true only when writes are needed
- Optionally tune PG_STATEMENT_TIMEOUT (default 30000 ms) and PG_MAX_RESULT_BYTES (default 32768)
claude mcp add mcp-postgres-server -e "DATABASE_URL=<your DATABASE_URL>" -e "PG_HOST=<your PG_HOST>" -e "PG_PORT=<your PG_PORT>" -e "PG_USER=<your PG_USER>" -e "PG_PASSWORD=<your PG_PASSWORD>" -e "PG_DATABASE=<your PG_DATABASE>" -e "PG_ALLOW_WRITE=<your PG_ALLOW_WRITE>" -e "PG_SSLMODE=<your PG_SSLMODE>" -e "PG_SSL_CA=<your PG_SSL_CA>" -e "PG_ENABLE_RUNTIME_CONNECT=<your PG_ENABLE_RUNTIME_CONNECT>" -e "PG_MAX_RESULT_BYTES=<your PG_MAX_RESULT_BYTES>" -e "PG_STATEMENT_TIMEOUT=<your PG_STATEMENT_TIMEOUT>" -e "PG_CONNECT_TIMEOUT=<your PG_CONNECT_TIMEOUT>" -e "PG_SSH_HOST=<your PG_SSH_HOST>" -e "PG_SSH_PORT=<your PG_SSH_PORT>" -e "PG_SSH_USER=<your PG_SSH_USER>" -e "PG_SSH_PRIVATE_KEY=<your PG_SSH_PRIVATE_KEY>" -e "PG_SSH_PASSPHRASE=<your PG_SSH_PASSPHRASE>" -e "PG_SSH_AGENT=<your PG_SSH_AGENT>" -e "PG_SSH_PASSWORD=<your PG_SSH_PASSWORD>" -e "PG_SSH_FINGERPRINT=<your PG_SSH_FINGERPRINT>" -e "PG_SSH_KEEPALIVE_INTERVAL=<your PG_SSH_KEEPALIVE_INTERVAL>" -- npx -y mcp-postgres-serverReplace each placeholder with your own value before saving.
[mcp_servers.mcp-postgres-server]
command = "npx"
args = ["-y", "mcp-postgres-server"]
[mcp_servers.mcp-postgres-server.env]
DATABASE_URL = "<your DATABASE_URL>"
PG_HOST = "<your PG_HOST>"
PG_PORT = "<your PG_PORT>"
PG_USER = "<your PG_USER>"
PG_PASSWORD = "<your PG_PASSWORD>"
PG_DATABASE = "<your PG_DATABASE>"
PG_ALLOW_WRITE = "<your PG_ALLOW_WRITE>"
PG_SSLMODE = "<your PG_SSLMODE>"
PG_SSL_CA = "<your PG_SSL_CA>"
PG_ENABLE_RUNTIME_CONNECT = "<your PG_ENABLE_RUNTIME_CONNECT>"
PG_MAX_RESULT_BYTES = "<your PG_MAX_RESULT_BYTES>"
PG_STATEMENT_TIMEOUT = "<your PG_STATEMENT_TIMEOUT>"
PG_CONNECT_TIMEOUT = "<your PG_CONNECT_TIMEOUT>"
PG_SSH_HOST = "<your PG_SSH_HOST>"
PG_SSH_PORT = "<your PG_SSH_PORT>"
PG_SSH_USER = "<your PG_SSH_USER>"
PG_SSH_PRIVATE_KEY = "<your PG_SSH_PRIVATE_KEY>"
PG_SSH_PASSPHRASE = "<your PG_SSH_PASSPHRASE>"
PG_SSH_AGENT = "<your PG_SSH_AGENT>"
PG_SSH_PASSWORD = "<your PG_SSH_PASSWORD>"
PG_SSH_FINGERPRINT = "<your PG_SSH_FINGERPRINT>"
PG_SSH_KEEPALIVE_INTERVAL = "<your PG_SSH_KEEPALIVE_INTERVAL>"Add to ~/.codex/config.toml. Replace each placeholder with your own value before saving.
{
"mcpServers": {
"mcp-postgres-server": {
"command": "npx",
"args": [
"-y",
"mcp-postgres-server"
],
"env": {
"DATABASE_URL": "<your DATABASE_URL>",
"PG_HOST": "<your PG_HOST>",
"PG_PORT": "<your PG_PORT>",
"PG_USER": "<your PG_USER>",
"PG_PASSWORD": "<your PG_PASSWORD>",
"PG_DATABASE": "<your PG_DATABASE>",
"PG_ALLOW_WRITE": "<your PG_ALLOW_WRITE>",
"PG_SSLMODE": "<your PG_SSLMODE>",
"PG_SSL_CA": "<your PG_SSL_CA>",
"PG_ENABLE_RUNTIME_CONNECT": "<your PG_ENABLE_RUNTIME_CONNECT>",
"PG_MAX_RESULT_BYTES": "<your PG_MAX_RESULT_BYTES>",
"PG_STATEMENT_TIMEOUT": "<your PG_STATEMENT_TIMEOUT>",
"PG_CONNECT_TIMEOUT": "<your PG_CONNECT_TIMEOUT>",
"PG_SSH_HOST": "<your PG_SSH_HOST>",
"PG_SSH_PORT": "<your PG_SSH_PORT>",
"PG_SSH_USER": "<your PG_SSH_USER>",
"PG_SSH_PRIVATE_KEY": "<your PG_SSH_PRIVATE_KEY>",
"PG_SSH_PASSPHRASE": "<your PG_SSH_PASSPHRASE>",
"PG_SSH_AGENT": "<your PG_SSH_AGENT>",
"PG_SSH_PASSWORD": "<your PG_SSH_PASSWORD>",
"PG_SSH_FINGERPRINT": "<your PG_SSH_FINGERPRINT>",
"PG_SSH_KEEPALIVE_INTERVAL": "<your PG_SSH_KEEPALIVE_INTERVAL>"
}
}
}
}Add to claude_desktop_config.json (Settings → Developer → Edit Config). Replace each placeholder with your own value before saving.
{
"mcpServers": {
"mcp-postgres-server": {
"command": "npx",
"args": [
"-y",
"mcp-postgres-server"
],
"env": {
"DATABASE_URL": "<your DATABASE_URL>",
"PG_HOST": "<your PG_HOST>",
"PG_PORT": "<your PG_PORT>",
"PG_USER": "<your PG_USER>",
"PG_PASSWORD": "<your PG_PASSWORD>",
"PG_DATABASE": "<your PG_DATABASE>",
"PG_ALLOW_WRITE": "<your PG_ALLOW_WRITE>",
"PG_SSLMODE": "<your PG_SSLMODE>",
"PG_SSL_CA": "<your PG_SSL_CA>",
"PG_ENABLE_RUNTIME_CONNECT": "<your PG_ENABLE_RUNTIME_CONNECT>",
"PG_MAX_RESULT_BYTES": "<your PG_MAX_RESULT_BYTES>",
"PG_STATEMENT_TIMEOUT": "<your PG_STATEMENT_TIMEOUT>",
"PG_CONNECT_TIMEOUT": "<your PG_CONNECT_TIMEOUT>",
"PG_SSH_HOST": "<your PG_SSH_HOST>",
"PG_SSH_PORT": "<your PG_SSH_PORT>",
"PG_SSH_USER": "<your PG_SSH_USER>",
"PG_SSH_PRIVATE_KEY": "<your PG_SSH_PRIVATE_KEY>",
"PG_SSH_PASSPHRASE": "<your PG_SSH_PASSPHRASE>",
"PG_SSH_AGENT": "<your PG_SSH_AGENT>",
"PG_SSH_PASSWORD": "<your PG_SSH_PASSWORD>",
"PG_SSH_FINGERPRINT": "<your PG_SSH_FINGERPRINT>",
"PG_SSH_KEEPALIVE_INTERVAL": "<your PG_SSH_KEEPALIVE_INTERVAL>"
}
}
}
}Add to ~/.cursor/mcp.json (global) or .cursor/mcp.json (per project). Replace each placeholder with your own value before saving.
{
"servers": {
"mcp-postgres-server": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"mcp-postgres-server"
],
"env": {
"DATABASE_URL": "<your DATABASE_URL>",
"PG_HOST": "<your PG_HOST>",
"PG_PORT": "<your PG_PORT>",
"PG_USER": "<your PG_USER>",
"PG_PASSWORD": "<your PG_PASSWORD>",
"PG_DATABASE": "<your PG_DATABASE>",
"PG_ALLOW_WRITE": "<your PG_ALLOW_WRITE>",
"PG_SSLMODE": "<your PG_SSLMODE>",
"PG_SSL_CA": "<your PG_SSL_CA>",
"PG_ENABLE_RUNTIME_CONNECT": "<your PG_ENABLE_RUNTIME_CONNECT>",
"PG_MAX_RESULT_BYTES": "<your PG_MAX_RESULT_BYTES>",
"PG_STATEMENT_TIMEOUT": "<your PG_STATEMENT_TIMEOUT>",
"PG_CONNECT_TIMEOUT": "<your PG_CONNECT_TIMEOUT>",
"PG_SSH_HOST": "<your PG_SSH_HOST>",
"PG_SSH_PORT": "<your PG_SSH_PORT>",
"PG_SSH_USER": "<your PG_SSH_USER>",
"PG_SSH_PRIVATE_KEY": "<your PG_SSH_PRIVATE_KEY>",
"PG_SSH_PASSPHRASE": "<your PG_SSH_PASSPHRASE>",
"PG_SSH_AGENT": "<your PG_SSH_AGENT>",
"PG_SSH_PASSWORD": "<your PG_SSH_PASSWORD>",
"PG_SSH_FINGERPRINT": "<your PG_SSH_FINGERPRINT>",
"PG_SSH_KEEPALIVE_INTERVAL": "<your PG_SSH_KEEPALIVE_INTERVAL>"
}
}
}
}Save as .vscode/mcp.json in your workspace. Replace each placeholder with your own value before saving.
{
"mcpServers": {
"mcp-postgres-server": {
"command": "npx",
"args": [
"-y",
"mcp-postgres-server"
],
"env": {
"DATABASE_URL": "<your DATABASE_URL>",
"PG_HOST": "<your PG_HOST>",
"PG_PORT": "<your PG_PORT>",
"PG_USER": "<your PG_USER>",
"PG_PASSWORD": "<your PG_PASSWORD>",
"PG_DATABASE": "<your PG_DATABASE>",
"PG_ALLOW_WRITE": "<your PG_ALLOW_WRITE>",
"PG_SSLMODE": "<your PG_SSLMODE>",
"PG_SSL_CA": "<your PG_SSL_CA>",
"PG_ENABLE_RUNTIME_CONNECT": "<your PG_ENABLE_RUNTIME_CONNECT>",
"PG_MAX_RESULT_BYTES": "<your PG_MAX_RESULT_BYTES>",
"PG_STATEMENT_TIMEOUT": "<your PG_STATEMENT_TIMEOUT>",
"PG_CONNECT_TIMEOUT": "<your PG_CONNECT_TIMEOUT>",
"PG_SSH_HOST": "<your PG_SSH_HOST>",
"PG_SSH_PORT": "<your PG_SSH_PORT>",
"PG_SSH_USER": "<your PG_SSH_USER>",
"PG_SSH_PRIVATE_KEY": "<your PG_SSH_PRIVATE_KEY>",
"PG_SSH_PASSPHRASE": "<your PG_SSH_PASSPHRASE>",
"PG_SSH_AGENT": "<your PG_SSH_AGENT>",
"PG_SSH_PASSWORD": "<your PG_SSH_PASSWORD>",
"PG_SSH_FINGERPRINT": "<your PG_SSH_FINGERPRINT>",
"PG_SSH_KEEPALIVE_INTERVAL": "<your PG_SSH_KEEPALIVE_INTERVAL>"
}
}
}
}Add to ~/.codeium/windsurf/mcp_config.json. Replace each placeholder with your own value before saving.
{
"mcpServers": {
"mcp-postgres-server": {
"command": "npx",
"args": [
"-y",
"mcp-postgres-server"
],
"env": {
"DATABASE_URL": "<your DATABASE_URL>",
"PG_HOST": "<your PG_HOST>",
"PG_PORT": "<your PG_PORT>",
"PG_USER": "<your PG_USER>",
"PG_PASSWORD": "<your PG_PASSWORD>",
"PG_DATABASE": "<your PG_DATABASE>",
"PG_ALLOW_WRITE": "<your PG_ALLOW_WRITE>",
"PG_SSLMODE": "<your PG_SSLMODE>",
"PG_SSL_CA": "<your PG_SSL_CA>",
"PG_ENABLE_RUNTIME_CONNECT": "<your PG_ENABLE_RUNTIME_CONNECT>",
"PG_MAX_RESULT_BYTES": "<your PG_MAX_RESULT_BYTES>",
"PG_STATEMENT_TIMEOUT": "<your PG_STATEMENT_TIMEOUT>",
"PG_CONNECT_TIMEOUT": "<your PG_CONNECT_TIMEOUT>",
"PG_SSH_HOST": "<your PG_SSH_HOST>",
"PG_SSH_PORT": "<your PG_SSH_PORT>",
"PG_SSH_USER": "<your PG_SSH_USER>",
"PG_SSH_PRIVATE_KEY": "<your PG_SSH_PRIVATE_KEY>",
"PG_SSH_PASSPHRASE": "<your PG_SSH_PASSPHRASE>",
"PG_SSH_AGENT": "<your PG_SSH_AGENT>",
"PG_SSH_PASSWORD": "<your PG_SSH_PASSWORD>",
"PG_SSH_FINGERPRINT": "<your PG_SSH_FINGERPRINT>",
"PG_SSH_KEEPALIVE_INTERVAL": "<your PG_SSH_KEEPALIVE_INTERVAL>"
}
}
}
}Replace each placeholder with your own value before saving.
Ask the agent "what tables are in the public schema?" so it calls list_tables.
Expected: A list of tables in public; a follow-up write through query fails because of the READ ONLY transaction.
When to choose another server
- Postgres MCP#996
You want health checks and index tuning on top of restricted SQL.
- DBHub#46
You also connect to MySQL, SQL Server, Oracle or SQLite.
- PostgreSQL Database Management Server#9,093
You need tiered administration tools (roles, RLS, import/export), not just queries.
Compared side by side in PostgreSQL MCP servers.
What changed, and when this was checked
- First listed
- Mar 24, 2025
- Latest version published
- Sep 14, 2026
- Version history
- 2 versions tracked (below)
- Requirements evidence
- Declared by Glama, last synced Nov 30, 2026. Not independently verified by MCP Toplist.
- Profile checked
- Oct 9, 2026 against README
- Ranking data as of
- Nov 30, 2026
- Glama ↗listed since Apr 26, 2026 · still listed
- PulseMCP ↗listed since May 22, 2026 · still listed
- mcp.so ↗listed since May 22, 2026 · still listed
- mcp.so ↗listed since May 22, 2026 · delisted, last seen Aug 25, 2026
- Official MCP ↗listed since Sep 15, 2026 · still listed
Do you maintain PostgreSQL? to show as its verified maintainer and add your own summary, sign-in details and links. The rest of this page is read from the registry listings and from MCP Toplist's own connection check.
Available versions (2)
| Version | Published |
|---|---|
| 0.3.1 | Sep 14, 2026 |
| 0.3.0 | Sep 14, 2026 |
Ranks ahead of 192,044 of 199,637 servers on MCP Toplist.
Show your rank
Maintain this server? Add the live rank badge to your README — it updates automatically as the leaderboard changes.
[](https://mcptoplist.com/server/io.github.antonorlov%2Fmcp-postgres-server)<a href="https://mcptoplist.com/server/io.github.antonorlov%2Fmcp-postgres-server"><img src="https://mcptoplist.com/badge/io.github.antonorlov%2Fmcp-postgres-server.svg" alt="MCP Toplist: Top 5% of 199,637" /></a>Variants: append ?metric=score or ?metric=stars to the image URL.
Frequently asked questions
- Who maintains PostgreSQL?
- PostgreSQL is maintained by antonorlov, which publishes 2 MCP servers (3 total versions) tracked on MCP Toplist.
- Is PostgreSQL listed on the Official MCP Registry?
- Yes — PostgreSQL is listed on the Official MCP Registry, alongside Glama, PulseMCP and mcp.so.
- How many versions does PostgreSQL have?
- MCP Toplist tracks 2 versions of PostgreSQL, most recently published on Sep 14, 2026.
- Where can I find the source code for PostgreSQL?
- The source code for PostgreSQL is hosted at github.com/antonorlov/mcp-postgres-server.
Do you run this server?
Community projects list the MCP servers behind real agents and apps. Publish yours and this page will link to it.