PostgreSQL MCP Server Configuration & Usage Guide

📦
Installationnpx
⚠️
Risk LevelMedium Risk
🔑
API KeyNot Required
💻
Clients3 supported

PostgreSQL 数据库只读访问,支持查询和 schema 检查

Medium Risk Category: Database & Data Query Verified: 2026-05-18 Status: Verified

Supported Clients

Installation Command

npx -y @modelcontextprotocol/server-postgres postgresql://user:pass@localhost/dbname

Configuration Example

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://user:pass@localhost/mydb"
      ]
    }
  }
}

Permission Scope & Security Notes

连接数据库进行查询,建议使用只读账号和测试数据库

Risk Score:4/10

Common Errors

连接超时
确认数据库地址和端口可达
认证失败
检查用户名密码和数据库名称
SSL required
连接字符串添加 ?sslmode=require

Sources

Recently Verified:2026-05-18。Client versions and configuration formats may change. Please refer to official documentation before use.

Related Tools