cribl_getSources
Retrieve source configurations for a specified worker group or fleet in Cribl Stream, defaulting to the sole group if only one exists.
Instructions
Fetches source configurations in a specified worker group.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| groupName | No | Optional: The name of the Worker Group/Fleet. If omitted, defaults to attempting to use Cribl Stream and if only one group exists for Stream, it will use that sole group. |
Implementation Reference
- src/server.ts:177-202 (registration)The MCP tool 'cribl_getSources' is registered using server.tool() with a schema (GetSourcesArgsShape) that accepts an optional groupName. The handler resolves the group name, calls getSources(), and returns the result as JSON.
server.tool( 'cribl_getSources', 'Fetches source configurations in a specified worker group.', GetSourcesArgsShape, async (args: ValidatedArgs<typeof GetSourcesArgsShape>) => { console.error(`[Tool Call] cribl_getSources with args:`, args); const groupResolution = await resolveGroupName(args.groupName); // Pass directly, preprocess handles null if (groupResolution.error || !groupResolution.groupName) { return { isError: true, content: [{ type: 'text', text: groupResolution.error || 'Could not determine group name.' }] }; } const groupName = groupResolution.groupName; const result = await getSources(groupName); if (!result.success) { console.error(`[Tool Error] cribl_getSources (Group: ${groupName}):`, result.error); return { isError: true, content: [{ type: 'text', text: `Error fetching sources for group ${groupName}: ${result.error}` }], }; } console.error(`[Tool Success] cribl_getSources (Group: ${groupName}): Found ${result.data?.length || 0} sources.`); return { content: [{ type: 'text', text: JSON.stringify(result.data || [], null, 2) }], }; } ); - src/server.ts:173-175 (schema)The input schema for 'cribl_getSources' — GetSourcesArgsShape — defines an optional 'groupName' argument using GroupNameArgSchema (preprocesses null to undefined and validates as optional string).
const GetSourcesArgsShape = { groupName: GroupNameArgSchema, }; - src/api/criblClient.ts:352-369 (handler)The actual API client function getSources() that performs the HTTP GET request to /api/v1/m/{groupName}/system/inputs to fetch source configurations from Cribl. It handles validation, API errors, and returns a ClientResult<CriblSource[]>.
export async function getSources(groupName: string): Promise<ClientResult<CriblSource[]>> { const context = `getSources (Group: ${groupName})`; if (!groupName) { // This check might be redundant if called correctly, but good safety return { success: false, error: 'Group name is required for getSources.' }; } // Use group-specific path const url = `/api/v1/m/${groupName}/system/inputs`; console.error(`[stderr] Attempting API call: GET ${url}`); try { const response = await apiClient.get<CriblApiResponse>(url); // Assuming the response structure still has an 'items' array for inputs return { success: true, data: response.data.items as CriblSource[] }; } catch (error) { const errorMessage = handleApiError(error, context); return { success: false, error: errorMessage }; } }