.mcp.json

PostgreSQL MCP server (read-only)

Lets Claude query a PostgreSQL database through DBHub, a local MCP server started with npx. Use a database user that can only read, so Claude cannot change data.

Tested with Claude Code 2.1.329

.mcp.json
{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["-y", "@bytebase/dbhub", "--dsn", "${POSTGRES_READONLY_DSN}"]
    }
  }
}

Notes

  • Create a database user with SELECT rights only and put its connection string in the `POSTGRES_READONLY_DSN` environment variable.
  • Needs Node.js for npx.
  • Do not point it at a production database that holds personal data; use a masked copy.

Related lessons

Type to search the reference, templates and lessons.