list-roles
Retrieve a paginated list of roles, with options to include related entities such as policies, teams, and users.
Instructions
List roles with pagination
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fields | No | Comma-separated fields to include (e.g. 'policies,teams,users') | |
| limit | No | Number of results per page | |
| before | No | Cursor for backward pagination | |
| after | No | Cursor for forward pagination | |
| include | No | Include deleted entities | non-deleted |
Implementation Reference
- src/tools/access.ts:14-16 (handler)Handler function that calls omClient.get('/roles', params) to list roles from OpenMetadata API
export async function listRoles(params: z.infer<typeof listRolesSchema>) { return omClient.get("/roles", params); } - src/tools/access.ts:6-12 (schema)Zod schema defining input parameters for list-roles: fields, limit (default 10), before, after cursors, and include filter
export const listRolesSchema = z.object({ fields: z.string().optional().describe("Comma-separated fields to include (e.g. 'policies,teams,users')"), limit: z.coerce.number().optional().default(10).describe("Number of results per page"), before: z.string().optional().describe("Cursor for backward pagination"), after: z.string().optional().describe("Cursor for forward pagination"), include: z.enum(["non-deleted", "deleted", "all"]).optional().default("non-deleted").describe("Include deleted entities"), }); - src/index.ts:159-164 (registration)Local tool() helper that registers the tool in the ToolRegistry and conditionally registers with MCP server based on category enablement
function tool(name: string, description: string, schema: any, handler: any): void { registry.register(name, description, currentCategory); if (registry.isEnabled(currentCategory)) { server.tool(name, description, schema, handler); } } - src/index.ts:370-371 (registration)Registration of list-roles tool with name, description, schema, and wrapped handler in the 'admin' category
tool("list-roles", "List roles with pagination", listRolesSchema.shape, wrapToolHandler(listRoles)); tool("get-role", "Get role details by name", getRoleSchema.shape, wrapToolHandler(getRole)); - src/tools/utils.ts:18-43 (helper)wrapToolHandler wraps handlers with error handling (redacts tokens, formats errors)
export const wrapToolHandler = createWrapToolHandler({ redactionPatterns: [/OPENMETADATA_TOKEN/i], errorExtractors: [ { match: (error) => error instanceof WriteBlockedError, extract: (error) => ({ kind: "passthrough", text: (error as WriteBlockedError).message, }), }, { match: (error) => error instanceof OpenMetadataError, extract: (error) => { const err = error as OpenMetadataError; return { kind: "structured", data: { message: err.message, status: err.status, details: err.body, }, }; }, }, ], });