Verified
PostgreSQL MCP
PostgreSQL MCP server that enables AI assistants to connect to PostgreSQL databases, run queries, explore schemas, and analyze data.
Install this MCP
Pick your client, then copy the config.
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
],
"env": {
"POSTGRES_CONNECTION_STRING": "YOUR_POSTGRES_CONNECTION_STRING"
}
}
}
}{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
],
"env": {
"POSTGRES_CONNECTION_STRING": "YOUR_POSTGRES_CONNECTION_STRING"
}
}
}
}{
"servers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
],
"env": {
"POSTGRES_CONNECTION_STRING": "YOUR_POSTGRES_CONNECTION_STRING"
}
}
}
}{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
],
"env": {
"POSTGRES_CONNECTION_STRING": "YOUR_POSTGRES_CONNECTION_STRING"
}
}
}
}# Add to ~/.codex/config.toml (or .codex/config.toml in a trusted project) [mcp_servers.postgres] command = "npx" args = ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"] [mcp_servers.postgres.env] POSTGRES_CONNECTION_STRING = "YOUR_POSTGRES_CONNECTION_STRING"
Set up with your agent
Uses the same client as above (Cursor). Paste into that agent.
Install the "PostgreSQL MCP" MCP for Cursor in this workspace.
1. Read official install docs: https://github.com/bjarneo/postgres-mcp-server
2. Merge this JSON into .cursor/mcp.json (project) or ~/.cursor/mcp.json (global):
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
],
"env": {
"POSTGRES_CONNECTION_STRING": "YOUR_POSTGRES_CONNECTION_STRING"
}
}
}
}
3. Required environment variables / secrets (ask the user; never invent secrets):
- POSTGRES_CONNECTION_STRING (required): PostgreSQL connection URI.
4. Restart Cursor if needed, then run a smoke test (list tools or one safe call). Confirm with the user before writing secrets.
Catalog: https://averlo.xyz/launches/postgres.htmlInstall the "PostgreSQL MCP" MCP for Claude Desktop in this workspace.
1. Read official install docs: https://github.com/bjarneo/postgres-mcp-server
2. Merge this JSON into ~/Library/Application Support/Claude/claude_desktop_config.json (macOS) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
],
"env": {
"POSTGRES_CONNECTION_STRING": "YOUR_POSTGRES_CONNECTION_STRING"
}
}
}
}
3. Required environment variables / secrets (ask the user; never invent secrets):
- POSTGRES_CONNECTION_STRING (required): PostgreSQL connection URI.
4. Restart Claude Desktop if needed, then run a smoke test (list tools or one safe call). Confirm with the user before writing secrets.
Catalog: https://averlo.xyz/launches/postgres.htmlInstall the "PostgreSQL MCP" MCP for VS Code in this workspace.
1. Read official install docs: https://github.com/bjarneo/postgres-mcp-server
2. Merge this JSON into .vscode/mcp.json:
{
"servers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
],
"env": {
"POSTGRES_CONNECTION_STRING": "YOUR_POSTGRES_CONNECTION_STRING"
}
}
}
}
3. Required environment variables / secrets (ask the user; never invent secrets):
- POSTGRES_CONNECTION_STRING (required): PostgreSQL connection URI.
4. Restart VS Code if needed, then run a smoke test (list tools or one safe call). Confirm with the user before writing secrets.
Catalog: https://averlo.xyz/launches/postgres.htmlInstall the "PostgreSQL MCP" MCP for Windsurf in this workspace.
1. Read official install docs: https://github.com/bjarneo/postgres-mcp-server
2. Merge this JSON into ~/.codeium/windsurf/mcp_config.json:
{
"mcpServers": {
"postgres": {
"command": "npx",
"args": [
"-y",
"@modelcontextprotocol/server-postgres",
"postgresql://localhost/mydb"
],
"env": {
"POSTGRES_CONNECTION_STRING": "YOUR_POSTGRES_CONNECTION_STRING"
}
}
}
}
3. Required environment variables / secrets (ask the user; never invent secrets):
- POSTGRES_CONNECTION_STRING (required): PostgreSQL connection URI.
4. Restart Windsurf if needed, then run a smoke test (list tools or one safe call). Confirm with the user before writing secrets.
Catalog: https://averlo.xyz/launches/postgres.htmlInstall the "PostgreSQL MCP" MCP for Codex in this workspace. 1. Read official install docs: https://github.com/bjarneo/postgres-mcp-server 2. Merge this TOML under [mcp_servers.*] into ~/.codex/config.toml (or .codex/config.toml in a trusted project): # Add to ~/.codex/config.toml (or .codex/config.toml in a trusted project) [mcp_servers.postgres] command = "npx" args = ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost/mydb"] [mcp_servers.postgres.env] POSTGRES_CONNECTION_STRING = "YOUR_POSTGRES_CONNECTION_STRING" 3. Required environment variables / secrets (ask the user; never invent secrets): - POSTGRES_CONNECTION_STRING (required): PostgreSQL connection URI. 4. Restart Codex if needed, then run a smoke test (list tools or one safe call). Confirm with the user before writing secrets. Catalog: https://averlo.xyz/launches/postgres.html
Try it
After install, paste one of these into your agent.
- Query PostgreSQL databases from AI
- Explore database schemas
- Analyze SQL data with AI

