Postgres

v1.0.0Databasesstable

Enables comprehensive PostgreSQL database management through natural language including queries, schema operations, user management, and administrative tasks. Features enterprise-grade connection pooling, transaction support, and full database admini

postgres-mcp-servermcpai-integration
Share:
176
Stars
0
Downloads
0
Weekly
0/5

What is Postgres?

Postgres is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to enables comprehensive postgresql database management through natural language including queries, schema operations, user management, and administrative tasks. features enterprise-grade connection pool...

Enables comprehensive PostgreSQL database management through natural language including queries, schema operations, user management, and administrative tasks. Features enterprise-grade connection pooling, transaction support, and full database admini

This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.

Features

  • Enables comprehensive PostgreSQL database management through

Use Cases

Query and manage PostgreSQL databases via natural language.
Perform schema operations and user management.
Execute complex SQL with enterprise-grade connection pooling.
ericzakariasson

Maintainer

LicenseMIT License
Languagetypescript
Versionv1.0.0
UpdatedMay 1, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx postgres-mcp-server

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

How to Set Up and Use Postgres

The Postgres MCP Server connects AI assistants directly to a PostgreSQL database, allowing them to execute SQL queries, inspect table schemas, and retrieve sample data through natural language. It exposes a `query` tool and resource endpoints for listing tables and browsing schema information, making it easy to explore and manage your database without leaving your AI client. Connection pooling and optional TLS support make it suitable for both local development and production database environments. Developers use it to run ad-hoc queries, debug data issues, and perform schema discovery through conversation.

Prerequisites

  • Node.js 18 or later installed
  • A running PostgreSQL database with a valid connection string
  • The `DATABASE_URL` environment variable set to your connection string (e.g., `postgres://user:pass@localhost:5432/mydb`)
  • An MCP-compatible client such as Claude Desktop or Cursor
1

Obtain your PostgreSQL connection string

Gather your PostgreSQL host, port, username, password, and database name. Form a connection string in the format `postgres://user:password@host:port/dbname`. If your database uses TLS, you may also need a CA certificate path.

2

Set the DATABASE_URL environment variable

Export the connection string so the MCP server can find it at runtime. You can place this in your shell profile or pass it directly in the MCP client configuration.

export DATABASE_URL="postgres://myuser:mypassword@localhost:5432/mydb"
3

Test the server locally with npx

Run the server using npx to confirm it starts and connects successfully before wiring it into your MCP client. The `--transport stdio` flag is required for Claude Desktop integration.

npx --yes pg-mcp-server --transport stdio
4

Add the server to your MCP client configuration

Open your Claude Desktop (or other MCP client) configuration file and add the pg-mcp-server entry. Include the DATABASE_URL in the env block so the process receives it.

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["--yes", "pg-mcp-server", "--transport", "stdio"],
      "env": {
        "DATABASE_URL": "postgres://myuser:mypassword@localhost:5432/mydb"
      }
    }
  }
}
5

Enable write operations if needed

By default the server may restrict write operations for safety. Set the `DANGEROUSLY_ALLOW_WRITE_OPS` environment variable to `true` to allow INSERT, UPDATE, DELETE, and DDL statements.

"env": {
  "DATABASE_URL": "postgres://...",
  "DANGEROUSLY_ALLOW_WRITE_OPS": "true"
}
6

Restart your MCP client and verify connection

Restart Claude Desktop or your MCP client. The postgres server should appear in the connected tools list. Try asking it to list your tables to confirm everything is working.

Postgres Examples

Client configuration

Complete Claude Desktop config block for the Postgres MCP server with read-only access.

{
  "mcpServers": {
    "postgres": {
      "command": "npx",
      "args": ["--yes", "pg-mcp-server", "--transport", "stdio"],
      "env": {
        "DATABASE_URL": "postgres://myuser:mypassword@localhost:5432/mydb"
      }
    }
  }
}

Prompts to try

Example prompts to use once the server is connected to your AI assistant.

- "Show me all tables in the public schema"
- "Show me the first 5 users from the users table"
- "What columns does the orders table have?"
- "Write a query to find all orders placed in the last 7 days and their total value"
- "How many active users are there in the database?"

Troubleshooting Postgres

Connection refused or authentication failed

Double-check that DATABASE_URL is correctly formed and the PostgreSQL server is running and accessible from your machine. Test with `psql "$DATABASE_URL"` from the command line first.

Write operations are rejected or not available

Set `DANGEROUSLY_ALLOW_WRITE_OPS=true` in the env block of your MCP client config. Be aware this allows full write access including schema changes.

SSL/TLS connection errors

Set the `PG_SSL_ROOT_CERT` environment variable to the path of your CA certificate file, or append `?sslmode=require` to your DATABASE_URL connection string.

Frequently Asked Questions about Postgres

What is Postgres?

Postgres is a Model Context Protocol (MCP) server that enables comprehensive postgresql database management through natural language including queries, schema operations, user management, and administrative tasks. features enterprise-grade connection pooling, transaction support, and full database admini It connects AI assistants to external tools and data sources through a standardized interface.

How do I install Postgres?

Follow the installation instructions on the Postgres GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.

Which AI clients work with Postgres?

Postgres works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.

Is Postgres free to use?

Yes, Postgres is open source and available under the MIT License license. You can use it freely in both personal and commercial projects.

Browse More Databases MCP Servers

Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.

Quick Config Preview

{ "mcpServers": { "postgres-mcp-server": { "command": "npx", "args": ["-y", "postgres-mcp-server"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

Ready to use Postgres?

Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.

33,000+ ServersFree & Open SourceStep-by-Step Guides