list_groups
Retrieve a paginated list of all Wazuh agent groups. Use limit and offset parameters to control the number of results.
Instructions
List all Wazuh agent groups
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of groups to return (1-100) | |
| offset | No | Pagination offset |
Implementation Reference
- src/tools/groups.ts:27-60 (handler)The async handler function that executes the list_groups tool logic. Calls client.getGroups() with limit/offset params, maps the response items to a simplified result object, and returns JSON-formatted text content.
async ({ limit, offset }) => { try { const response = await client.getGroups({ limit, offset }); const data = response.data; const result = { groups: data.affected_items.map((group) => ({ name: group.name, count: group.count, config_sum: group.configSum, merged_sum: group.mergedSum, })), total: data.total_affected_items, limit, offset, }; return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], }; } catch (error) { return { content: [ { type: "text" as const, text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), }), }, ], isError: true, }; } } - src/tools/groups.ts:5-61 (registration)The registerGroupTools function registers the 'list_groups' tool (and other group tools) on the MCP server via server.tool().
export function registerGroupTools( server: McpServer, client: WazuhClient ): void { server.tool( "list_groups", "List all Wazuh agent groups", { limit: z .number() .int() .min(1) .max(100) .default(25) .describe("Maximum number of groups to return (1-100)"), offset: z .number() .int() .min(0) .default(0) .describe("Pagination offset"), }, async ({ limit, offset }) => { try { const response = await client.getGroups({ limit, offset }); const data = response.data; const result = { groups: data.affected_items.map((group) => ({ name: group.name, count: group.count, config_sum: group.configSum, merged_sum: group.mergedSum, })), total: data.total_affected_items, limit, offset, }; return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }], }; } catch (error) { return { content: [ { type: "text" as const, text: JSON.stringify({ error: error instanceof Error ? error.message : String(error), }), }, ], isError: true, }; } } ); - src/tools/groups.ts:12-26 (schema)Zod schema defining the input parameters for list_groups: 'limit' (int 1-100, default 25) and 'offset' (int min 0, default 0) for pagination.
{ limit: z .number() .int() .min(1) .max(100) .default(25) .describe("Maximum number of groups to return (1-100)"), offset: z .number() .int() .min(0) .default(0) .describe("Pagination offset"), }, - src/client.ts:378-382 (helper)The client.getGroups() helper method that makes the actual API GET request to the Wazuh '/groups' endpoint with query parameters.
async getGroups( params: Record<string, string | number> = {} ): Promise<WazuhApiResponse<WazuhPaginatedData<WazuhGroup>>> { return this.get("/groups", params); } - src/types.ts:322-327 (helper)The WazuhGroup type interface defining the shape of group data returned by the API (name, count, configSum, mergedSum).
export interface WazuhGroup { name: string; count?: number; configSum?: string; mergedSum?: string; }