Get role DDL
get_role_ddlRetrieve 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
| Name | Required | Description | Default |
|---|---|---|---|
| database | No | 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. | |
| role_name | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ddl | Yes | ||
| found | Yes | ||
| object_name | Yes | ||
| object_type | Yes |