Skip to main content
Glama

Roles and memberships

pg_roles
Read-onlyIdempotent

List PostgreSQL roles, attributes, memberships, and settings to identify who can log in or holds powerful privileges, with optional name filtering and system-role inclusion.

Instructions

List database roles (users and groups) with their attributes (superuser, createdb, createrole, login, replication, bypassrls), connection limit, password expiry, the roles each one belongs to (member_of) and its members, plus per-role settings.

Use it to see who can log in and who holds powerful attributes. Superusers also get the password method of each login role (scram-sha-256, md5 or none); the hash itself is never returned. pattern filters by name (* wildcard). Built-in pg_* roles are hidden unless include_system is true. From PostgreSQL 16 memberships show their admin/inherit/set options.

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "pg_roles"
  }
}

Input Schema

NameRequiredDescriptionDefault
limitNo
patternNo
connectionNo
include_systemNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.3/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations already cover read-only, idempotent, non-destructive, closed-world behavior, and the description adds substantial undisclosed context well beyond them: the password hash is never returned, the password method is only exposed for superusers, built-in pg_* roles are hidden by default, and PostgreSQL 16 memberships include admin/inherit/set options. These are security- and version-sensitive traits an agent cannot infer from annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Front-loads the returned fields, then moves to usage, then to behavioral caveats — a sensible order. The attribute list is long but each item is meaningful; no filler sentences. Slightly dense, but nothing is redundant.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema and four parameters, the description does a good job describing the shape of the result set, the filtering behavior, and the security-relevant exceptions. The remaining gap is the unexplained `connection` and `limit` parameters, which an agent must guess at from names alone.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description carries the burden, and it explains two of four parameters: `pattern` as a name filter with `*` wildcard support and `include_system` as the toggle that reveals pg_* roles. The `limit` and `connection` parameters receive no explanation at all, leaving half the surface undocumented.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

Names a specific verb and resource (list database roles) and enumerates the exact attributes returned: superuser, createdb, createrole, login, replication, bypassrls, connection limit, password expiry, member_of, members, per-role settings. This is clearly distinguishable from siblings like pg_privileges or pg_connections without opening the schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives an explicit use case: 'Use it to see who can log in and who holds powerful attributes.' That is a clear situation for selecting this tool, but it does not name alternatives or state when not to use it (e.g. for object-level grants, use pg_privileges).

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.