npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@vitalyostanin/postgres-mcp

v0.1.0

Published

MCP server for comprehensive PostgreSQL integration: database operations, tables, queries, connection management, monitoring

Readme

PostgreSQL MCP Server

Also available in Russian: README-ru.md

CI npm version

Note: This project is designed for my personal needs. I do not plan to expand its functionality with features I don't use or cannot verify. You are free to submit suggestions and pull requests, but I make no guarantee that everything will be accepted.

MCP server for comprehensive PostgreSQL integration with the following capabilities:

  • Database operations - connect to PostgreSQL instances, list databases and schemas
  • Table management - list tables, views, functions and get detailed information
  • Query tools - execute SELECT, INSERT, UPDATE, DELETE queries with full PostgreSQL syntax
  • Connection management - manage PostgreSQL connections with read-only mode support
  • Streaming file export - streaming save to files for large datasets
  • Read-only mode - safe read-only operations to prevent accidental data modifications
  • Monitoring - database statistics, performance metrics
  • Schema operations - create, modify, and drop tables, views, functions and indexes

Table of Contents

Requirements

  • Node.js ≥ 20
  • Environment variables:
    • POSTGRES_MCP_CONNECTION_STRING — PostgreSQL connection string (postgresql:// format)
    • POSTGRES_MCP_TIMEZONE — optional timezone for date operations (default: Europe/Moscow), must be a valid IANA timezone identifier (e.g., Europe/London, America/New_York, Asia/Tokyo)
    • POSTGRES_MCP_POOL_SIZE — optional connection pool size (default: 1)

Configuration for Qwen Code

To use this MCP server with Qwen Code, add to ~/.qwen/settings.json:

{
  "mcpServers": {
    "postgres-mcp": {
      "command": "npx",
      "args": ["-y", "@vitalyostanin/postgres-mcp@latest"],
      "env": {
        "POSTGRES_MCP_CONNECTION_STRING": "postgresql://localhost:5432/postgres"
      }
    }
  }
}

Note: This configuration uses npx to run the published package. For local development, use "command": "node" with "args": ["/absolute/path/to/postgres-mcp/dist/index.js"]. The POSTGRES_MCP_TIMEZONE and POSTGRES_MCP_POOL_SIZE environment variables are optional.

Configuration for VS Code Cline

To use this MCP server with Cline extension in VS Code:

  1. Open VS Code with Cline extension installed
  2. Click the MCP Servers icon in Cline's top navigation
  3. Select the "Configure" tab and click "Configure MCP Servers"
  4. Add the following configuration to cline_mcp_settings.json:
{
  "mcpServers": {
    "postgres-mcp": {
      "command": "npx",
      "args": ["-y", "@vitalyostanin/postgres-mcp@latest"],
      "env": {
        "POSTGRES_MCP_CONNECTION_STRING": "postgresql://localhost:5432/postgres"
      }
    }
  }
}

Note: This configuration uses npx to run the published package. For local development, use "command": "node" with "args": ["/absolute/path/to/postgres-mcp/dist/index.js"]. The POSTGRES_MCP_TIMEZONE and POSTGRES_MCP_POOL_SIZE environment variables are optional.

MCP Tools

Read-Only Mode Tools

| Tool | Description | Main Parameters | | --- | --- | --- | | service-info | Get PostgreSQL service information and current connection status | — | | connect | Establish connection to PostgreSQL using connection string | readonlyMode — run in read-only mode (default: true), poolSize — connection pool size (default: 1), idleTimeoutMillis — idle timeout in milliseconds (default: 30000), connectionTimeoutMillis — connection timeout in milliseconds (default: 10000) | | disconnect | Disconnect from PostgreSQL and clear the connection | — | | list-schemas | List all schemas in the PostgreSQL database | — | | list-objects | List objects (tables, views, functions) in a PostgreSQL schema | schema — schema name (default: 'public'), type — type of objects: 'table', 'view', 'function', 'all' (default: 'all') | | show-object | Show detailed information about a PostgreSQL object (table, view, or function) | schema — schema name (default: 'public'), name — object name (table, view, or function name), type — type of the object: 'table', 'view', 'function' | | execute-sql | Execute a custom SQL query against PostgreSQL (supports SELECT, INSERT, UPDATE, DELETE, DDL operations) | query — SQL query to execute, params — parameters for the SQL query (optional), saveToFile — save results to a file instead of returning them directly. When enabled, uses cursor-based streaming for SELECT queries to avoid memory issues (optional), filePath — explicit path to save the file (optional, auto-generated if not provided), forceSaveToFile — force saving results to a file even if the query does not support cursor-based streaming (e.g., INSERT, UPDATE, DELETE). When this flag is true, non-SELECT queries will also be saved to file but may consume more memory. Default is false. | | index-operation | Create, drop, or list indexes on PostgreSQL tables (list operation only in read-only mode) | operation — operation to perform: 'create', 'drop' or 'list', schema — schema name where the table is located (default: 'public'), table — table name to create/drop index on (required for create/drop), name — index name (required for create/drop), columns — array of column names to include in the index (required for create), unique — whether to create a unique index (default: false), ifNotExists — add IF NOT EXISTS clause for create operation (default: false), ifExists — add IF EXISTS clause for drop operation (default: false), tableName — table name to list indexes for (optional for list operation) |

Non-Read-Only Mode Tools

| Tool | Description | Main Parameters | | --- | --- | --- | | execute-sql | Execute a custom SQL query against PostgreSQL (supports SELECT, INSERT, UPDATE, DELETE, DDL operations) | query — SQL query to execute, params — parameters for the SQL query (optional), saveToFile — save results to a file instead of returning them directly. When enabled, uses cursor-based streaming for SELECT queries to avoid memory issues (optional), filePath — explicit path to save the file (optional, auto-generated if not provided), forceSaveToFile — force saving results to a file even if the query does not support cursor-based streaming (e.g., INSERT, UPDATE, DELETE). When this flag is true, non-SELECT queries will also be saved to file but may consume more memory. Default is false. |

Note: The server runs in read-only mode by default to prevent accidental data modifications. In read-only mode, all write operations are blocked including:

  • Data modification operations: INSERT, UPDATE, DELETE, DDL statements
  • Index operations: create and drop operations in index-operation tool
  • Any execute-sql operations that contain write queries when in read-only mode

The following operations are restricted in read-only mode:

  • DDL operations in execute-sql (CREATE, ALTER, DROP, etc.)
  • create and drop operations in index-operation These operations are only available when the server is running in read-write mode.