Return what depends on one role, cluster-wide, from pg_shdepend.
read-onlyany connectionsweeps instancesweeps group
roleDependencies(role)
Return what depends on one role, cluster-wide, from pg_shdepend. checkRoleAccess answers whether a role may USE an object; this answers the inverse, which is the whole of "role cannot be dropped because some objects depend on it" -- a message that reports a count and names nothing. by_kind separates owner (which blocks DROP ROLE outright and is cleared by REASSIGN OWNED) from acl and policy (cleared by DROP OWNED), because that decides whether you reassign or hunt.
Every row this database can resolve is named: tables, functions, schemas and types as schema.name, and every other class -- policies, default privileges, large objects, languages, foreign servers, subscriptions, parameters granted with GRANT SET ON PARAMETER -- by PostgreSQL's own pg_identify_object, so a policy reads as 'p on public.t'. IMPORTANT: pg_shdepend is shared across the cluster, so total and by_database cover EVERY database; but an object id is only resolvable from the database it lives in, so 'objects' names only those in this database and the shared catalogs.
A row counted in another database is real and unnamed here -- connect there and ask again. Reporting only what this database can see would answer 'nothing depends on it' to somebody about to DROP the role.
Also accepts connection, instance, group, described once under arguments every tool takes.
What depends on one role, cluster-wide. An absent extension or a missing grant is reported as {error, hint} instead.
| Field | Type |
|---|---|
| by_database | object | null |
| by_kind | object | null |
| exists | boolean | null |
| objects | array | null |
| resolvable_in_this_database | integer | null |
| role | string | null |
| total | integer | null |
A physical replica is byte-identical here, so asking each member of a replication group adds nothing.
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "roleDependencies",
"arguments": {
"role": "app_legacy"
}
}
}
{
"role": "app_legacy",
"exists": true,
"total": 4,
"by_kind": {
"owner": 2,
"acl": 1,
"policy": 1
},
"by_database": {
"shop": 3,
"reports": 1
},
"resolvable_in_this_database": 3,
"objects": [
{
"kind": "pg_class",
"name": "shop.legacy_export",
"column": null,
"dependency": "owner"
},
{
"kind": "pg_proc",
"name": "shop.rebuild_export",
"column": null,
"dependency": "owner"
},
{
"kind": "pg_policy",
"name": "legacy_read on shop.orders",
"column": null,
"dependency": "policy"
}
]
}
Invented values on a fictional shop database, shaped by and checked against this tool's output schema. Real output is returned as structuredContent to clients that negotiate MCP 2025-06-18 or later.