Skip to main content
Glama
easy-pg-admin-mcp

easy-pg-admin-mcp

by chenkumi

easy-pg-admin-mcp

High-privilege PostgreSQL admin MCP server for database and role/grant management.

This project is a DBA-style tool. It does not provide raw SQL execution and does not manage tables, schemas, views, indexes, triggers, or functions. Use easy-pg-mcp for data access and schema/table operations.

Features

  • List, create, inspect, and change owners for databases

  • List, create, update, and drop PostgreSQL roles

  • Grant and revoke role memberships

  • Grant and revoke database-level privileges

  • Protect destructive actions with short-lived confirmation tokens

Related MCP server: PostgreSQL MCP Server

Available Tools

Tool

Description

pg_list_databases

List databases in the current PostgreSQL instance

pg_create_database

Create a PostgreSQL database

pg_describe_database

Inspect a PostgreSQL database

pg_alter_database_owner

Change a database owner

pg_drop_database

Request database deletion and return a confirmation token

pg_list_roles

List PostgreSQL roles

pg_create_role

Create a PostgreSQL role without SUPERUSER support

pg_alter_role_password

Change a role password

pg_alter_role_attributes

Change supported role attributes

pg_drop_role

Request role deletion and return a confirmation token

pg_grant_role

Grant a role to another role

pg_revoke_role

Revoke a role from another role

pg_show_role_memberships

Show memberships for a role

pg_grant_privileges

Grant database-level privileges to a role

pg_revoke_privileges

Revoke database-level privileges from a role

pg_show_grants

Show database-level grants for a role

pg_confirm_task

Confirm and execute a destructive action token

Safety

  • No raw SQL passthrough

  • No schema, table, view, index, trigger, or function management

  • SUPERUSER role creation and modification are not supported

  • pg_drop_database and pg_drop_role require pg_confirm_task

  • pg_drop_role does not support REASSIGN OWNED or DROP OWNED

  • Confirmation tokens are random, single-use, and expire quickly

Configuration

Use environment variables, matching the rest of the easy-*-mcp family.

Variable

Required

Default

Description

PG_CONNECTION_STRING

Conditional

-

PostgreSQL connection string. Takes precedence when provided

PG_HOST

Conditional

-

PostgreSQL host when no connection string is provided

PG_PORT

No

5432

PostgreSQL port

PG_USER

Conditional

-

PostgreSQL admin role name when no connection string is provided

PG_PASSWORD

No

-

PostgreSQL password

PG_DATABASE

Conditional

-

Default database used for the admin connection

PG_CONNECTION_LIMIT

No

10

Maximum number of active pool connections

PG_CONNECTION_TIMEOUT

No

10000

Connection establishment timeout in milliseconds

PG_IDLE_TIMEOUT

No

30000

Idle connection timeout in milliseconds

PG_ENABLE_KEEP_ALIVE

No

true

Whether TCP keep-alive is enabled

PG_KEEP_ALIVE_INITIAL_DELAY

No

0

Initial TCP keep-alive delay in milliseconds

PG_SSL

No

false

Use true, false, or no-verify

PG_ADMIN_TOKEN_TTL_SECONDS

No

120

Confirmation token lifetime in seconds

Example

PG_HOST=localhost
PG_PORT=5432
PG_USER=postgres
PG_PASSWORD=your_password
PG_DATABASE=postgres
PG_SSL=false
PG_ADMIN_TOKEN_TTL_SECONDS=120

Claude Desktop Example

{
  "mcpServers": {
    "easy-pg-admin-mcp": {
      "command": "npx",
      "args": ["-y", "easy-pg-admin-mcp"],
      "env": {
        "PG_HOST": "localhost",
        "PG_PORT": "5432",
        "PG_USER": "postgres",
        "PG_PASSWORD": "your_password",
        "PG_DATABASE": "postgres",
        "PG_SSL": "false",
        "PG_ADMIN_TOKEN_TTL_SECONDS": "120"
      }
    }
  }
}

Codex config.toml Example

[mcp_servers.easy-pg-admin-mcp]
args = ["-y", "easy-pg-admin-mcp"]
command = "npx"
enabled = true

[mcp_servers.easy-pg-admin-mcp.env]
PG_HOST = "localhost"
PG_PORT = "5432"
PG_USER = "postgres"
PG_PASSWORD = "your_password"
PG_DATABASE = "postgres"
PG_SSL = "false"
PG_ADMIN_TOKEN_TTL_SECONDS = "120"

OpenCode opencode.jsonc Example

{
  "$schema": "https://opencode.ai/config.json",
  "mcp": {
    "easy-pg-admin-mcp": {
      "type": "local",
      "command": ["npx", "-y", "easy-pg-admin-mcp"],
      "enabled": true,
      "environment": {
        "PG_HOST": "localhost",
        "PG_PORT": "5432",
        "PG_USER": "postgres",
        "PG_PASSWORD": "your_password",
        "PG_DATABASE": "postgres",
        "PG_SSL": "false",
        "PG_ADMIN_TOKEN_TTL_SECONDS": "120",
      },
    },
  },
}

Available Tools

17 tools
pg_alter_database_ownerC

Change the owner of a PostgreSQL database.

Inputs: owner (required), database (required).

pg_alter_role_attributesC

Change PostgreSQL role attributes. SUPERUSER is intentionally not supported.

Inputs: role (required), login, inherit, createdb, +5 more.

pg_alter_role_passwordC

Change a PostgreSQL role password.

Inputs: role (required), password (required).

pg_confirm_taskC

Confirm and execute a previously issued destructive action token.

Inputs: token (required).

pg_create_databaseD

Create a PostgreSQL database.

Inputs: database (required), owner, locale, encoding, +1 more.

pg_create_roleC

Create a PostgreSQL role. SUPERUSER is intentionally not supported.

Inputs: role (required), login, inherit, createdb, +6 more.

pg_describe_databaseC

Inspect a PostgreSQL database definition.

Inputs: database (required).

pg_drop_databaseC

Request database deletion and return a short-lived confirmation token.

Inputs: database (required), force.

pg_drop_roleC

Request role deletion and return a short-lived confirmation token.

Inputs: role (required).

pg_grant_privilegesC

Grant database-level PostgreSQL privileges to a role.

Inputs: role (required), database (required), privileges (required), withGrantOption.

pg_grant_roleC

Grant a PostgreSQL role to another role.

Inputs: role (required), member (required), adminOption.

pg_list_databasesA

List databases in the current PostgreSQL instance.

Inputs: no named parameters.

pg_list_rolesC

List PostgreSQL roles.

Inputs: includeSystem.

pg_revoke_privilegesC

Revoke database-level PostgreSQL privileges from a role.

Inputs: role (required), database (required), privileges (required), grantOptionFor.

pg_revoke_roleC

Revoke a PostgreSQL role from another role.

Inputs: role (required), member (required), adminOption.

pg_show_grantsB

Show database-level PostgreSQL grants for a role.

Inputs: role (required), database.

pg_show_role_membershipsC

Show memberships for a PostgreSQL role.

Inputs: role (required).

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    B3.1/5.0

    Scored across 17 tools

    Disambiguation5/5

    Each tool targets a distinct action on either databases or roles, with clear descriptions that prevent overlap. For example, pg_grant_privileges and pg_grant_role are explicitly different operations.

    Naming Consistency5/5

    All tools follow the consistent pattern 'pg_verb_noun' (e.g., pg_create_database, pg_drop_role). The naming is uniform and predictable.

    Tool Count5/5

    With 17 tools covering database and role CRUD, grants, and listings, the count matches the domain well. Each tool serves a specific purpose without unnecessary overlap.

    Completeness4/5

    The set covers essential PostgreSQL admin tasks: create, drop (with confirmation), list, alter, and grant/revoke for both databases and roles. Minor gaps like renaming or altering database properties other than owner are absent but acceptable for an 'easy' admin tool.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      Not graded
      quality
      D
      maintenance
      MCP server that exposes PostgreSQL database operations via psycopg2, including connection management, query execution, and transaction control.
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Full-featured MCP server that exposes 36 tools for interacting with PostgreSQL databases, covering schema introspection, query execution, data exploration, performance monitoring, security auditing, and maintenance.
      36
      5 npm
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Local MCP server for safe querying and inspecting PostgreSQL databases, with write and maintenance operations disabled by default.
      8
      1
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      A Python MCP 2.0 server for self-hosted PostgreSQL instances, providing schema/relation discovery, SQL query and controlled transactional execution tools with security features like read-only transactions, role hardening guidance, and optional human approval for write commands.
      MIT