MCP Postgres Secure MCP Server

A secure Model Context Protocol server for PostgreSQL with readonly, DML, and full access modes

Local serverstdio

What is the MCP Postgres Secure MCP Server?

A secure Model Context Protocol server for PostgreSQL with readonly, DML, and full access modes

What you get

A Model Context Protocol server for PostgreSQL with permission-based access modes. Choose how much database power the AI gets at install time.

Recorded tools

  • query — Read-only SQL. Supports PostgreSQL ($1, $2) and MySQL-style (?) placeholders.
  • connect_db — Optional runtime connection when PG_LOCK_CONNECTION=false and env vars are not set. Disabled by default when using env-based config.

More MCP options

Compare MCP servers by category, or browse hosted MCP servers if you prefer an endpoint over a local process.

Maintainer setup documentation.

Recorded tools

Check the linked publisher documentation and your connected client's tool list. Names and availability can vary with the server version and account permissions.

ToolWhat it does
connect_db

How to install the MCP Postgres Secure MCP Server

{
  "mcpServers": {
    "postgres-readonly": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "-y",
        "mcp-postgres-secure",
        "--access-mode",
        "readonly"
      ],
      "env": {
        "PG_HOST": "localhost",
        "PG_PORT": "5432",
        "PG_USER": "mcp_readonly",
        "PG_PASSWORD": "YOUR_PG_PASSWORD",
        "PG_DATABASE": "your_database",
        "PG_LOCK_CONNECTION": "true"
      }
    }
  }
}

From the project documentation. Replace placeholders and example paths before connecting.

Configuration

VariableDescriptionRequired
PG_HOSTDeclared in the maintainer’s client configuration.Check documentation
PG_PORTDeclared in the maintainer’s client configuration.Check documentation
PG_USERDeclared in the maintainer’s client configuration.Check documentation
PG_PASSWORDDeclared in the maintainer’s client configuration.Check documentation
PG_DATABASEDeclared in the maintainer’s client configuration.Check documentation
PG_LOCK_CONNECTIONDeclared in the maintainer’s client configuration.Check documentation

Example prompts to try

  • “Use MCP Postgres Secure to query.”
  • “Use MCP Postgres Secure to connect db.”

Frequently asked questions

A secure Model Context Protocol server for PostgreSQL with readonly, DML, and full access modes Confirm the tools offered by your installed version in the connected client. Tool availability and permissions depend on the server and account configuration.