list_users_by_org
Retrieve a list of organization users with details including user ID, email, and role for user management and access control in Grafana.
Instructions
List users by organization. Returns a list of users with details like userid, email, role etc
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/admin.ts:37-62 (handler)The ToolDefinition export including the handler function that executes the tool logic by fetching users via GrafanaClient and formatting the response.export const listUsersByOrg: ToolDefinition = { name: 'list_users_by_org', description: 'List users by organization. Returns a list of users with details like userid, email, role etc', inputSchema: ListUsersByOrgSchema, handler: async (_params, context: ToolContext) => { try { const client = new GrafanaClient(context.config.grafanaConfig); const users = await client.listUsers(); // Format the response const formatted = users.map(user => ({ id: user.id, email: user.email, name: user.name, login: user.login, role: user.role, lastSeenAt: user.lastSeenAt, isDisabled: user.isDisabled, })); return createToolResult(formatted); } catch (error: any) { return createErrorResult(error.message); } }, };
- src/tools/admin.ts:10-10 (schema)Zod input schema for the list_users_by_org tool (accepts no parameters).const ListUsersByOrgSchema = z.object({});
- src/tools/admin.ts:66-66 (registration)Registration of the list_users_by_org tool via server.registerTool call within registerAdminTools function.server.registerTool(listUsersByOrg);
- src/cli.ts:123-123 (registration)Invocation of registerAdminTools which registers the admin tools including list_users_by_org.registerAdminTools(server);