Skip to main content
Glama
Simple PostgreSQL MCP Server

Simple PostgreSQL MCP Server

by perrypixel

Simple PostgreSQL MCP Server

A minimal Model Context Protocol (MCP) server for executing SQL queries on PostgreSQL databases with configurable permissions.

Features

  • Execute SQL queries with optional read-only or write access

  • Server-level mode (read-only/write) configurable via command line

  • Returns structured results with metadata

  • Simple setup using a PostgreSQL connection string

Related MCP server: pg-mcp

Getting Started

  1. Clone the repository

    git clone https://github.com/perrypixel/Simple-Postgres-MCP
    cd Simple-Postgres-MCP
  2. Install dependencies

    npm install
  3. Build the project

    npm run build

MCP Configuration

Add the following to your MCP client configuration (mcp.json):

Write Mode (default)

{
  "mcpServers": {
    "simple-postgresql-mcp": {
      "command": "node",
      "args": [
        "/path/to/build/index.js",
        "postgresql://username:password@localhost:5432/database_name",
        "write"
      ]
    }
  }
}

Read-Only Mode

{
  "mcpServers": {
    "simple-postgresql-mcp": {
      "command": "node",
      "args": [
        "/path/to/build/index.js",
        "postgresql://username:password@localhost:5432/database_name",
        "readonly"
      ]
    }
  }
}

Note: Update the path in the configuration to point to the index.js file inside your build folder.

Usage

  1. Copy the appropriate MCP configuration (read-only or write mode) to your tool’s mcp.json (e.g., Cursor, Windsurf, Copilot, etc.).

  2. Start your MCP client. The server is now ready to use!

Support

If you find this tool helpful, you can support the development by:

Available Tools

1 tool
execute_queryC

Execute SQL queries on PostgreSQL database

Inputs: query (required), readOnly.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    B3/5.0

    Scored across 1 tool

    Disambiguation5/5

    With only one tool, there is no possibility of ambiguity or overlap between tools. The single tool has a clear and distinct purpose, making it impossible for an agent to misselect between tools.

    Naming Consistency5/5

    Since there is only one tool, it inherently follows a consistent naming pattern. The tool name 'execute_query' uses a clear verb_noun structure, and there are no other tools to cause inconsistency.

    Tool Count2/5

    A single tool for a PostgreSQL server is too few for the apparent scope, as it lacks basic operations like listing tables, inserting data, or managing connections. This minimal set will likely cause agent failures due to incomplete functionality.

    Completeness1/5

    The tool surface is severely incomplete for a PostgreSQL server. It only provides query execution, missing essential CRUD operations, schema management, and other database interactions, leaving significant gaps that will hinder agent workflows.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      A production-ready MCP server that enables safe, read-only SQL SELECT queries against PostgreSQL databases with built-in security validation. It features connection pooling, automatic row limits, and structured logging to ensure secure and reliable database interactions.
      MIT
    • A
      license
      B
      quality
      D
      maintenance
      A lightweight Postgres MCP server for safe database exploration and query analysis, read-only by default, with multi-database support.
      4
      4
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      An open-source MCP server for PostgreSQL schema introspection and guarded read-only queries. It enables MCP clients to discover schemas, tables, columns, indexes, relationships, and safe queryable data from a configured PostgreSQL database.
      9 npm
      1
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      A cross-platform MCP server for querying and introspecting PostgreSQL databases with SSH tunnel support, featuring multi-layered query safety and read-only enforcement.
      13 npm
      MIT