Skip to main content
Glama
MCPg - Production-grade PostgreSQL MCP Server

MCPg - Production-grade PostgreSQL MCP Server

Get role DDL

get_role_ddl
Read-only

Retrieve the CREATE ROLE DDL for a named PostgreSQL role via pg_get_roledef(), without shelling out to pg_dumpall. Returns found=false and empty DDL when the role does not exist.

Instructions

Return the CREATE ROLE DDL for a named role using PG 19's pg_get_roledef(oid) function — no shell-out to pg_dumpall --roles-only required. Returns found=false with an empty ddl when the role doesn't exist. Requires PG 19+; raises on older servers (pair with get_pg19_ddl_status to feature-detect). Returns an object with object_type ('role'), object_name, found (bool), and ddl (the verbatim CREATE statement).

Example: get_role_ddl(role_name='app_user')

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "role_name": "<role_name>"
    },
    "name": "get_role_ddl"
  }
}

Input Schema

NameRequiredDescriptionDefault
databaseNoOptional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected.
role_nameYes

Output Schema

NameRequiredDescriptionDefault
ddlYes
foundYes
object_nameYes
object_typeYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changedv0.8.4
    • changedInput schema / properties / database / description
      Previous value: -"Optional: target a configured secondary (read-only) database by name; omit for the primary. Call list_databases to see the configured ids."New value: +"Optional: a database id from list_databases, to target a configured secondary (read-only) database; omit for the primary. Database names that are not configured ids are rejected."
  2. First observedv0.6.8

TDQS

A4.7/5.0
Behavior5/5

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

Annotations already declare readOnlyHint=true and openWorldHint=false, and the description still adds substantive behavior: found=false with empty ddl for missing roles, an exception raised on pre-PG-19 servers, and a version-detection teammate. Error and edge-case behavior are disclosed rather than left to inference.

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

Conciseness5/5

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

Front-loaded with the action, then fallback mechanism, edge case, version constraint, and return shape — each sentence carries distinct information with no restatement of the name or title.

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

Completeness5/5

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

Even though an output schema exists, the description voluntarily names the key result fields and the found=false semantics, and it covers the main failure mode (pre-PG-19 servers). Nothing an agent needs to invoke this correctly is missing.

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

Parameters4/5

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

Schema coverage is 50%; the `database` parameter is fully documented in the schema, while `role_name` has no schema description. The description compensates by clarifying that role_name is the named role whose CREATE statement is returned and by supplying a worked example call.

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?

States a specific verb and resource ('Return the CREATE ROLE DDL for a named role') and names the exact mechanism (pg_get_roledef) plus the alternative it replaces (pg_dumpall --roles-only). It is clearly distinguishable from siblings like get_database_ddl and get_tablespace_ddl.

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 a concrete usage condition — requires PG 19+, and explicitly routes the agent to get_pg19_ddl_status for feature detection on older servers. It does not address when to prefer list_roles or grantees inspection, but the operative when/when-not is covered.

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

Deploy Server

Other Tools