home / mcp / postgresql mcp server

PostgreSQL MCP Server

Mcp server for postgres

Installation
Add the following to your MCP client configuration file.

Configuration

View docs
{
  "mcpServers": {
    "1levick3-postgresql-mcp-server": {
      "command": "node",
      "args": [
        "/Users/1Levick3/Desktop/postgresql-mcp-server/build/index.js"
      ],
      "env": {
        "POSTGRES_SSL_CERT_PATH": "/Users/1levick3/Desktop/root.crt",
        "POSTGRES_CONNECTION_STRING": "postgresUrl"
      }
    }
  }
}

You can run direct PostgreSQL queries from MCP clients through this server, enabling parameterized SQL execution with configurable timeouts. It’s designed to work with MCP environments and the Cursor IDE, allowing you to connect securely to PostgreSQL databases and perform query operations from your MCP workflow.

How to use

Connect your MCP client to the PostgreSQL MCP Server using the stdio configuration defined in your MCP settings. You will run the server as a local process and provide the necessary connection details via environment variables. The server exposes direct SQL query execution against your target PostgreSQL databases, with support for parameterized queries and configurable timeouts. Ensure your client supplies SQL statements and parameters, and the server will execute them against the database you specify via the connection string.

How to install

Prerequisites you need before setup:

- Node.js >= 18.0.0

- PostgreSQL server (for target database operations)

- Network access to target PostgreSQL instances

Concrete steps to install and configure the MCP server locally are shown below. You will build the server and add an MCP configuration entry to enable runtime usage.

Install manually

1. Clone the PostgreSQL MCP Server repository

2. Install dependencies

npm install

3. Build the server

npm run build

4. Add the MCP configuration for the server. Use the following settings to run the server locally with Node and point to the built index file. The environment variables specify how to reach the PostgreSQL database and how to validate the SSL certificate if used.

{
  "mcpServers": {
    "postgresql_mcp": {
      "command": "node",
      "args": ["/Users/1Levick3/Desktop/postgresql-mcp-server/build/index.js"],
      "disabled": false,
      "alwaysAllow": [],
      "env": {
        "POSTGRES_CONNECTION_STRING": "postgresUrl",
        "POSTGRES_SSL_CERT_PATH": "/Users/1levick3/Desktop/root.crt"
      }
    }
  }
}