get_kpi_groups
Retrieve thematic KPI groups to organize Swedish public sector performance indicators by topic, enabling structured analysis of municipal and regional data.
Instructions
Lista KPI-grupper (tematiska samlingar av nyckeltal) med valfri sökning. Grupper hjälper till att organisera KPIs efter ämne.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | No | Sökterm för att filtrera grupper efter titel |
Implementation Reference
- src/tools/kpi-tools.ts:222-259 (handler)Executes the get_kpi_groups tool: logs call, fetches KPI groups from Kolada API (/kpi_groups) with optional title filter, returns JSON with count and summarized groups (id, title, desc, member count), handles errors.handler: async (args: z.infer<typeof getKpiGroupsSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { query } = args; logger.toolCall('get_kpi_groups', { query }); try { const params: Record<string, string> = {}; if (query) params.title = query; const groups = await koladaClient.fetchAllData<KPIGroup>('/kpi_groups', params); logger.toolResult('get_kpi_groups', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify( { count: groups.length, groups: groups.map((g) => ({ id: g.id, title: g.title, description: g.description, member_count: g.members?.length || 0, })), }, null, 2 ), }, ], }; } catch (error) { logger.toolResult('get_kpi_groups', false, Date.now() - startTime); throw error; } },
- src/tools/kpi-tools.ts:45-47 (schema)Zod input schema: optional 'query' string to filter KPI groups by title.const getKpiGroupsSchema = z.object({ query: z.string().optional().describe('Sökterm för att filtrera grupper efter titel'), });
- src/tools/kpi-tools.ts:218-260 (registration)Local registration of get_kpi_groups tool within kpiTools object, including description, schema, annotations, and inline handler.get_kpi_groups: { description: 'Lista KPI-grupper (tematiska samlingar av nyckeltal) med valfri sökning. Grupper hjälper till att organisera KPIs efter ämne.', inputSchema: getKpiGroupsSchema, annotations: READ_ONLY_ANNOTATIONS, handler: async (args: z.infer<typeof getKpiGroupsSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { query } = args; logger.toolCall('get_kpi_groups', { query }); try { const params: Record<string, string> = {}; if (query) params.title = query; const groups = await koladaClient.fetchAllData<KPIGroup>('/kpi_groups', params); logger.toolResult('get_kpi_groups', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify( { count: groups.length, groups: groups.map((g) => ({ id: g.id, title: g.title, description: g.description, member_count: g.members?.length || 0, })), }, null, 2 ), }, ], }; } catch (error) { logger.toolResult('get_kpi_groups', false, Date.now() - startTime); throw error; } }, },
- src/server/handlers.ts:32-38 (registration)Global MCP tool registry: spreads kpiTools (containing get_kpi_groups) into allTools, used for tool listing and execution in server handlers.export const allTools = { ...kpiTools, ...municipalityTools, ...ouTools, ...dataTools, ...analysisTools, };