MCP server that provides PostgreSQL database access and operations
Setup
Choose your client, copy the config, then fill in any required environment variables.
claude mcp add postgresql --env DATABASE_URL='<DATABASE_URL>' -- npx mcp-postgres@latest~/.codex/config.toml
[mcp_servers.postgresql]
command = "npx"
args = ["mcp-postgres@latest"]
env = { DATABASE_URL = "<DATABASE_URL>" }
# codex mcp add postgresql --env DATABASE_URL='<DATABASE_URL>' -- npx mcp-postgres@latest~/.cursor/mcp.json
{
"mcpServers": {
"postgresql": {
"command": "npx",
"args": [
"mcp-postgres@latest"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}.vscode/mcp.json
{
"servers": {
"postgresql": {
"type": "stdio",
"command": "npx",
"args": [
"mcp-postgres@latest"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}~/.gemini/settings.json
{
"mcpServers": {
"postgresql": {
"command": "npx",
"args": [
"mcp-postgres@latest"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}claude_desktop_config.json
{
"mcpServers": {
"postgresql": {
"command": "npx",
"args": [
"mcp-postgres@latest"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}.trae/mcp.json
{
"mcpServers": {
"postgresql": {
"command": "npx",
"args": [
"mcp-postgres@latest"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}Environment variables
DATABASE_URL
Replace the placeholders with your own credentials and keep them out of version control.