list_operating_areas
Explore available Swedish public sector data categories by listing all operating areas (like Education, Healthcare) with their KPI counts to identify relevant datasets for analysis.
Instructions
Lista alla verksamhetsområden (t.ex. Utbildning, Vård och omsorg) med antal KPIs per område. Ger överblick över vilka typer av data som finns tillgänglig.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/analysis-tools.ts:542-597 (handler)Full tool definition including the handler function that lists all operating areas by counting KPIs from the cached catalog, sorting by count, and returning a structured JSON response.list_operating_areas: { description: 'Lista alla verksamhetsområden (t.ex. Utbildning, Vård och omsorg) med antal KPIs per område. Ger överblick över vilka typer av data som finns tillgänglig.', inputSchema: listOperatingAreasSchema, annotations: READ_ONLY_ANNOTATIONS, handler: async (): Promise<ToolResult> => { const startTime = Date.now(); logger.toolCall('list_operating_areas', {}); try { // Use cached KPI catalog const kpis = await dataCache.getOrFetch( 'kpi-catalog-full', () => koladaClient.fetchAllData<KPI>('/kpi'), 86400000 ); // Count KPIs per operating area const areaCounts: Record<string, number> = {}; for (const kpi of kpis) { const area = kpi.operating_area || 'Övrigt'; areaCounts[area] = (areaCounts[area] || 0) + 1; } // Sort by count descending const sortedAreas = Object.entries(areaCounts) .sort((a, b) => b[1] - a[1]) .map(([name, count]) => ({ name, kpi_count: count })); logger.toolResult('list_operating_areas', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify( { total_kpis: kpis.length, operating_areas_count: sortedAreas.length, operating_areas: sortedAreas, usage_tip: 'Använd get_kpis_by_operating_area med ett områdesnamn för att se KPIs inom det området.', }, null, 2 ), }, ], }; } catch (error) { logger.toolResult('list_operating_areas', false, Date.now() - startTime); throw error; } }, },
- src/tools/analysis-tools.ts:51-51 (schema)Input schema for the list_operating_areas tool, which takes no parameters.const listOperatingAreasSchema = z.object({});
- src/server/handlers.ts:32-38 (registration)Registration of all tools by spreading analysisTools (containing list_operating_areas) into the central allTools object used by MCP handlers.export const allTools = { ...kpiTools, ...municipalityTools, ...ouTools, ...dataTools, ...analysisTools, };
- src/server/handlers.ts:15-15 (registration)Import of analysisTools module containing the list_operating_areas tool.import { analysisTools } from '../tools/analysis-tools.js';