Secure read-only PostgreSQL MCP server in Rust — a hardened alternative to the deprecated @modelcontextprotocol/server-postgres.
Setup
Choose your client, copy the config, then fill in any required environment variables.
claude mcp add postgresql-hardened-read-only --env DATABASE_URL='<DATABASE_URL>' -- npx -y postgres-mcp-hardened~/.codex/config.toml
[mcp_servers.postgresql-hardened-read-only]
command = "npx"
args = ["-y", "postgres-mcp-hardened"]
env = { DATABASE_URL = "<DATABASE_URL>" }
# codex mcp add postgresql-hardened-read-only --env DATABASE_URL='<DATABASE_URL>' -- npx -y postgres-mcp-hardened~/.cursor/mcp.json
{
"mcpServers": {
"postgresql-hardened-read-only": {
"command": "npx",
"args": [
"-y",
"postgres-mcp-hardened"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}.vscode/mcp.json
{
"servers": {
"postgresql-hardened-read-only": {
"type": "stdio",
"command": "npx",
"args": [
"-y",
"postgres-mcp-hardened"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}~/.gemini/settings.json
{
"mcpServers": {
"postgresql-hardened-read-only": {
"command": "npx",
"args": [
"-y",
"postgres-mcp-hardened"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}claude_desktop_config.json
{
"mcpServers": {
"postgresql-hardened-read-only": {
"command": "npx",
"args": [
"-y",
"postgres-mcp-hardened"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}.trae/mcp.json
{
"mcpServers": {
"postgresql-hardened-read-only": {
"command": "npx",
"args": [
"-y",
"postgres-mcp-hardened"
],
"env": {
"DATABASE_URL": "<DATABASE_URL>"
}
}
}
}Environment variables
DATABASE_URL
Replace the placeholders with your own credentials and keep them out of version control.