Pgsql MCP Server

A Model Context Protocol (MCP) server that provides tools for interacting with a PostgreSQL database. It enables AI assistants to execute SQL

Local serverstdioGo

What is the Pgsql MCP Server?

A Model Context Protocol (MCP) server that provides tools for interacting with a PostgreSQL database. It enables AI assistants to execute SQL queries, explain

Configuration and credentials

  • Go 1.23 or later - A PostgreSQL database server

More MCP options

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

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
read_queryExecutes a SELECT SQL query.
write_queryExecutes an INSERT, UPDATE, or DELETE SQL query.
create_tableExecutes a CREATE TABLE SQL statement.
list_tablesLists all user-created tables in the database.
explain_queryReturns the execution plan for a given SQL query.
stdioThe server communicates over standard input and output. This is the default mode and is ideal for local testing or direct integration with command-line-based MCP clients.
streamableHttpThe server uses the Streamable HTTP transport, a more modern and flexible HTTP-based transport for MCP.

How to install the Pgsql MCP Server

{
  "mcpServers": {
    "pgsql-mcp-server": {
      "command": "/path/to/pgsql-mcp-server",
      "args": [],
      "env": {
        "DB_HOST": "localhost",
        "DB_PORT": "5432",
        "DB_NAME": "postgres",
        "DB_USER": "your_username",
        "DB_PASSWORD": "YOUR_DB_PASSWORD",
        "DB_SSLMODE": "disable",
        "SERVER_MODE": "stdio"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

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

Configuration

  • Go 1.23 or later - A PostgreSQL database server
VariableDescriptionRequired
DB_HOSTDeclared in the maintainer’s client configuration.Check documentation
DB_PORTDeclared in the maintainer’s client configuration.Check documentation
DB_NAMEDeclared in the maintainer’s client configuration.Check documentation
DB_USERDeclared in the maintainer’s client configuration.Check documentation
DB_PASSWORDDeclared in the maintainer’s client configuration.Check documentation
DB_SSLMODEDeclared in the maintainer’s client configuration.Check documentation
SERVER_MODEDeclared in the maintainer’s client configuration.Check documentation

Example prompts to try

  • “Use Pgsql to read query.”
  • “Use Pgsql to write query.”
  • “Use Pgsql to create table.”

Frequently asked questions

A Model Context Protocol (MCP) server that provides tools for interacting with a PostgreSQL database. It enables AI assistants to execute SQL queries, explain Confirm the tools offered by your installed version in the connected client. Tool availability and permissions depend on the server and account configuration.