list_sift_investigations
Retrieve Sift investigations from Grafana to monitor and analyze incident data, with optional limits for focused results.
Instructions
Retrieves a list of Sift investigations with an optional limit
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of investigations to return |
Implementation Reference
- src/tools/sift.ts:64-88 (handler)The handler function implementing the tool logic: creates Sift client, fetches investigations from /api/v1/investigations endpoint, formats the response, and returns it using createToolResult.handler: async (params, context: ToolContext) => { try { const client = createSiftClient(context.config.grafanaConfig); const response = await client.get('/api/v1/investigations', { params: { limit: params.limit || 10 }, }); const investigations = response.data.investigations || []; // Format the response const formatted = investigations.map((inv: any) => ({ id: inv.id, name: inv.name, status: inv.status, createdAt: inv.created_at, updatedAt: inv.updated_at, analyses: inv.analyses?.length || 0, })); return createToolResult(formatted); } catch (error: any) { return createErrorResult(error.response?.data?.message || error.message); } },
- src/tools/sift.ts:6-8 (schema)Zod input schema for the list_sift_investigations tool, defining optional 'limit' parameter.const ListSiftInvestigationsSchema = z.object({ limit: z.number().optional().describe('Maximum number of investigations to return'), });
- src/tools/sift.ts:216-216 (registration)Registers the list_sift_investigations ToolDefinition with the MCP server inside registerSiftTools function.server.registerTool(listSiftInvestigations);
- src/tools/sift.ts:34-57 (helper)Helper function used by the handler to create an Axios client instance configured for Sift API with proper auth and base URL.function createSiftClient(config: any) { const headers: any = { 'User-Agent': 'mcp-grafana/1.0.0', 'Content-Type': 'application/json', }; if (config.serviceAccountToken) { headers['Authorization'] = `Bearer ${config.serviceAccountToken}`; } else if (config.apiKey) { headers['Authorization'] = `Bearer ${config.apiKey}`; } // Sift uses a different base URL pattern const baseUrl = config.url.replace(/\/$/, ''); const siftUrl = baseUrl.includes('grafana.net') ? baseUrl.replace('grafana.net', 'sift.grafana.net') : `${baseUrl}/api/plugins/grafana-sift-app/resources`; return axios.create({ baseURL: siftUrl, headers, timeout: 60000, // Longer timeout for investigations }); }
- src/cli.ts:126-126 (registration)Invocation of registerSiftTools in the main CLI entrypoint, conditionally enabling and registering Sift tools including list_sift_investigations.registerSiftTools(server);