Skip to main content
Glama

get_kpis_by_operating_area

Retrieve KPIs by operating area to filter Swedish public sector data for statistical analysis, comparisons, and trend tracking.

Instructions

Hämta alla KPIs inom ett specifikt verksamhetsområde. T.ex. alla utbildnings-KPIs eller alla vård-KPIs. Enklare än fritextsökning för att hitta relaterade nyckeltal.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operating_areaYesVerksamhetsområde att filtrera på (t.ex. "Utbildning", "Vård och omsorg")
limitNoMax antal KPIs att returnera (standard: 50)

Implementation Reference

  • The main handler function that fetches KPIs from cache, filters by operating area (case-insensitive partial match), limits results, and returns structured JSON with KPI details.
    handler: async (args: z.infer<typeof getKpisByOperatingAreaSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { operating_area, limit } = args; logger.toolCall('get_kpis_by_operating_area', { operating_area, limit }); try { // Use cached KPI catalog const kpis = await dataCache.getOrFetch( 'kpi-catalog-full', () => koladaClient.fetchAllData<KPI>('/kpi'), 86400000 ); // Filter by operating area (case-insensitive partial match) const areaLower = operating_area.toLowerCase(); const matchingKpis = kpis.filter((k) => k.operating_area?.toLowerCase().includes(areaLower)); const totalMatches = matchingKpis.length; const limitedKpis = matchingKpis.slice(0, limit); logger.toolResult('get_kpis_by_operating_area', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify( { operating_area, count: limitedKpis.length, total_matches: totalMatches, truncated: totalMatches > limit, kpis: limitedKpis.map((k) => ({ id: k.id, title: k.title, description: k.description, has_ou_data: k.has_ou_data, is_divided_by_gender: k.is_divided_by_gender, municipality_type: k.municipality_type, })), }, null, 2 ), }, ], }; } catch (error) { logger.toolResult('get_kpis_by_operating_area', false, Date.now() - startTime); throw error; } },
  • Zod schema defining input parameters: operating_area (string) and limit (number, 1-100, default 50).
    const getKpisByOperatingAreaSchema = z.object({ operating_area: z.string().describe('Verksamhetsområde att filtrera på (t.ex. "Utbildning", "Vård och omsorg")'), limit: z.number().min(1).max(100).default(50).describe('Max antal KPIs att returnera (standard: 50)'), });
  • Tool registration within analysisTools object, including description, inputSchema reference, annotations, and handler.
    get_kpis_by_operating_area: { description: 'Hämta alla KPIs inom ett specifikt verksamhetsområde. T.ex. alla utbildnings-KPIs eller alla vård-KPIs. Enklare än fritextsökning för att hitta relaterade nyckeltal.', inputSchema: getKpisByOperatingAreaSchema, annotations: READ_ONLY_ANNOTATIONS, handler: async (args: z.infer<typeof getKpisByOperatingAreaSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { operating_area, limit } = args; logger.toolCall('get_kpis_by_operating_area', { operating_area, limit }); try { // Use cached KPI catalog const kpis = await dataCache.getOrFetch( 'kpi-catalog-full', () => koladaClient.fetchAllData<KPI>('/kpi'), 86400000 ); // Filter by operating area (case-insensitive partial match) const areaLower = operating_area.toLowerCase(); const matchingKpis = kpis.filter((k) => k.operating_area?.toLowerCase().includes(areaLower)); const totalMatches = matchingKpis.length; const limitedKpis = matchingKpis.slice(0, limit); logger.toolResult('get_kpis_by_operating_area', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify( { operating_area, count: limitedKpis.length, total_matches: totalMatches, truncated: totalMatches > limit, kpis: limitedKpis.map((k) => ({ id: k.id, title: k.title, description: k.description, has_ou_data: k.has_ou_data, is_divided_by_gender: k.is_divided_by_gender, municipality_type: k.municipality_type, })), }, null, 2 ), }, ], }; } catch (error) { logger.toolResult('get_kpis_by_operating_area', false, Date.now() - startTime); throw error; } }, },

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/isakskogstad/Kolada-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server