cribl_listWorkerGroups
List worker groups in your Cribl deployment, optionally filtered by product type (stream, edge, search, or all) to manage and query cluster resources.
Instructions
Lists available worker groups in the Cribl deployment, optionally filtered by product type (stream, edge, search, or all).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| productType | No | Filter groups by product type (stream, edge, search, all). Defaults to stream. |
Implementation Reference
- src/server.ts:106-138 (registration)Registration of the 'cribl_listWorkerGroups' tool on the MCP server, including the Zod schema for arguments (productType filter) and the handler callback.
server.tool( 'cribl_listWorkerGroups', 'Lists available worker groups in the Cribl deployment, optionally filtered by product type (stream, edge, search, or all).', ListWorkerGroupsArgsShape, async (args: ValidatedArgs<typeof ListWorkerGroupsArgsShape>) => { const { productType } = args; console.error(`[Tool Call] cribl_listWorkerGroups (Filtering for: ${productType})`); const result = await listWorkerGroups(); if (!result.success || !result.data) { console.error('[Tool Error] cribl_listWorkerGroups:', result.error); return { isError: true, content: [{ type: 'text', text: `Error listing worker groups: ${result.error || 'Unknown error'}` }], }; } // Filter based on productType, skip if 'all' const groupsToReturn = productType === 'all' ? result.data : result.data.filter(group => { if (productType === 'stream') return !group.isFleet && !group.isSearch; if (productType === 'edge') return group.isFleet === true; if (productType === 'search') return group.isSearch === true; return false; // Should not happen }); console.error(`[Tool Success] cribl_listWorkerGroups: Found ${groupsToReturn.length} groups matching filter '${productType}'.`); return { content: [{ type: 'text', text: JSON.stringify(groupsToReturn, null, 2) }], }; } ); - src/server.ts:110-138 (handler)Handler function for cribl_listWorkerGroups. It calls listWorkerGroups() from the API client, filters results by productType (stream/edge/search/all), and returns the matching worker groups as JSON.
async (args: ValidatedArgs<typeof ListWorkerGroupsArgsShape>) => { const { productType } = args; console.error(`[Tool Call] cribl_listWorkerGroups (Filtering for: ${productType})`); const result = await listWorkerGroups(); if (!result.success || !result.data) { console.error('[Tool Error] cribl_listWorkerGroups:', result.error); return { isError: true, content: [{ type: 'text', text: `Error listing worker groups: ${result.error || 'Unknown error'}` }], }; } // Filter based on productType, skip if 'all' const groupsToReturn = productType === 'all' ? result.data : result.data.filter(group => { if (productType === 'stream') return !group.isFleet && !group.isSearch; if (productType === 'edge') return group.isFleet === true; if (productType === 'search') return group.isSearch === true; return false; // Should not happen }); console.error(`[Tool Success] cribl_listWorkerGroups: Found ${groupsToReturn.length} groups matching filter '${productType}'.`); return { content: [{ type: 'text', text: JSON.stringify(groupsToReturn, null, 2) }], }; } ); - src/server.ts:98-104 (schema)Zod schema definition for the 'productType' argument of cribl_listWorkerGroups. Accepts 'stream', 'edge', 'search', or 'all', defaulting to 'stream'.
// Define schema for listWorkerGroups arguments const ListWorkerGroupsArgsShape = { productType: z.preprocess( (val) => (val === null || val === undefined || val === '' ? 'stream' : val), // Map null/undefined/empty to default z.enum(['stream', 'edge', 'search', 'all']) ).describe('Filter groups by product type (stream, edge, search, all). Defaults to stream.'), }; - src/api/criblClient.ts:320-333 (helper)The listWorkerGroups() API client function that performs the GET /api/v1/master/groups HTTP request to fetch all worker groups from the Cribl leader.
export async function listWorkerGroups(): Promise<ClientResult<CriblWorkerGroup[]>> { const context = 'listWorkerGroups'; // Using /master/groups path as it reportedly worked previously const url = '/api/v1/master/groups'; console.error(`[stderr] Attempting API call: GET ${url}`); try { // Assuming the response structure has an 'items' array const response = await apiClient.get<CriblApiResponse>(url); return { success: true, data: response.data.items as CriblWorkerGroup[] }; } catch (error) { const errorMessage = handleApiError(error, context); return { success: false, error: errorMessage }; } }