Skip to main content
Glama
PgAdmin-MCP

PgAdmin-MCP

by Mhdd-24

@mhdd_24/pgadmin-mcp

MCP server for PostgreSQL / pgAdmin-style exploration and SQL from Cursor (or any MCP client). Follows the same architecture as flyway-mcp.

Say "pg status", "list postgres tables", or "run this SQL on Dev" in chat — the assistant calls the matching tools.

Full documentation: docs/WIKI.md


Tools

Tool

Role

pg_set_profile

Sticky session switch: dev | qa | default

pg_status

Sticky + active profile, host, SELECT 1

pg_list_databases

List databases on active (or one-shot) profile server

pg_list_schemas

List user schemas

pg_list_tables

List tables/views in a schema

pg_describe_table

Column metadata

pg_query

Run SQL (read-only by default)

Profiles (no connection details in chat)

  1. Put both Dev and QA credentials in mcp.json (PG_DEV_*, PG_QA_*).

  2. Say pgprofile=qa or pgprofile=dev — the assistant calls pg_set_profile.

  3. Later tools reuse that sticky profile until you switch or the MCP process restarts.

  4. Optional one-shot: pass profile: "qa" on a single tool without changing sticky.

  5. database still means the logical DB name on that server (e.g. transboard), not the env profile.


Related MCP server: Database Assistant MCP Server

Safety

  • Read-only by default — only SELECT / WITH…SELECT / EXPLAIN / SHOW / VALUES

  • Set PG_ALLOW_WRITE=true to allow writes (still subject to DB user privileges)

  • PG_MAX_ROWS caps returned rows; PG_QUERY_TIMEOUT_MS sets statement timeout


Install / run

cd C:/workspace/pgadmin-mcp
npm install
npm run build
node dist/index.js

Cursor mcp.json

"pgadmin": {
  "command": "node",
  "args": ["C:/workspace/pgadmin-mcp/dist/index.js"],
  "env": {
    "PG_PROFILE": "dev",
    "PG_DEV_HOST": "192.168.1.141",
    "PG_DEV_PORT": "5432",
    "PG_DEV_USER": "postgres",
    "PG_DEV_PASSWORD": "YOUR_PASSWORD",
    "PG_DEV_DATABASE": "postgres",
    "PG_ALLOW_WRITE": "false",
    "PG_MAX_ROWS": "500"
  }
}

Or use discrete PGHOST / PGUSER / PGPASSWORD / PGDATABASE, or a single DATABASE_URL.

Restart Cursor after saving.


Example prompts

  • pgprofile=qa

  • pgprofile=dev

  • pg status

  • list databases

  • list tables in schema transc for database transboard

  • describe table translations schema transc database transboard

  • run: SELECT version();

Available Tools

7 tools
pg_describe_tableA

Describe columns for a table or view. Optional schema, database, and/or profile override.

Inputs: table (required), schema, profile, database.

pg_list_databasesA

List databases on the active profile server (or optional one-shot profile=dev|qa).

Inputs: profile.

pg_list_schemasA

List non-system schemas. Optional database and/or profile (dev|qa) override.

Inputs: profile, database.

pg_list_tablesA

List tables/views for a schema (default public). Optional database and/or profile override.

Inputs: schema, profile, database.

pg_queryA

Run SQL against the sticky session profile (or optional profile=dev|qa for one call). Read-only by default. Optional database name and maxRows. Do not ask the user for connection host/password — use profiles.

Inputs: sql (required), maxRows, profile, database.

pg_set_profileA

Set the sticky session connection profile to "dev" or "qa" (or "default"). Call when the user says pgprofile=dev, pgprofile=qa, use Dev DB, switch to QA, etc. Later tools reuse this profile automatically — no host/password in chat. Credentials are loaded from PG_DEV_* / PG_QA_* in mcp.json.

Inputs: profile (required), verify.

pg_statusA

Show current sticky PostgreSQL profile, host, database, write mode, and a live SELECT 1 health check. Optional profile arg for a one-shot check without changing the sticky session.

Inputs: profile, database.

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.2/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool maps to a distinct operation: profile management, status, list databases/schemas/tables, describe table, and execute queries. No overlapping purposes.

    Naming Consistency5/5

    All tools follow the pg_ prefix with clear verb-ish suffixes (list_*, describe_*, set_*, query). Consistent and predictable pattern.

    Tool Count5/5

    7 tools is well-scoped for a PostgreSQL browsing and querying server. No redundancy and each tool serves a clear need.

    Completeness4/5

    Covers profile switching, metadata exploration, and querying. Missing write operations or schema modification, but core read and navigate workflows are complete.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Enables querying and interacting with PostgreSQL databases using natural language through MCP. Supports configuration via environment variables and Cursor IDE integration.
      3
      MIT
    • F
      license
      A
      quality
      D
      maintenance
      Enables read-only exploration and querying of PostgreSQL or MySQL databases via MCP, with schema discovery, safe SQL validation, natural language to SQL conversion, and CSV export.
      11
      2
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      Enables read-only, SELECT-only querying of any Postgres database through MCP-compatible clients like Claude, with schema introspection and guarded SQL execution.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables natural language interaction with PostgreSQL databases via MCP, supporting database exploration, schema listing, and SQL queries with profile-based connections.
      7
      5 npm
      ISC