Skip to main content
Glama

get_kpis

Retrieve multiple Swedish municipal KPIs by their IDs in a single request, enabling efficient access to public sector performance data for analysis and comparison.

Instructions

Hämta flera nyckeltal (KPIs) via deras ID:n i en enda förfrågan. Accepterar upp till 25 KPI-ID:n per anrop.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kpi_idsYesLista med KPI-ID:n (max 25)

Implementation Reference

  • The main handler function for the get_kpis tool. Fetches multiple KPIs by their IDs using batch request to Kolada API, with validation and error handling.
    handler: async (args: z.infer<typeof getKpisSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { kpi_ids } = args; logger.toolCall('get_kpis', { kpi_ids, count: kpi_ids.length }); try { validateBatchSize(kpi_ids, 25); kpi_ids.forEach((id: string) => validateKpiId(id)); const kpis = await koladaClient.batchRequest<KPI>('/kpi', kpi_ids); logger.toolResult('get_kpis', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify( { requested: kpi_ids.length, found: kpis.length, kpis, }, null, 2 ), }, ], }; } catch (error) { logger.toolResult('get_kpis', false, Date.now() - startTime); handleApiError(error, 'get_kpis'); } },
  • Zod input schema for get_kpis tool, validating an array of 1-25 KPI IDs.
    const getKpisSchema = z.object({ kpi_ids: z.array(z.string()).min(1).max(25).describe('Lista med KPI-ID:n (max 25)'), });
  • Local registration of the get_kpis tool within the kpiTools object.
    get_kpis: { description: 'Hämta flera nyckeltal (KPIs) via deras ID:n i en enda förfrågan. Accepterar upp till 25 KPI-ID:n per anrop.', inputSchema: getKpisSchema, annotations: READ_ONLY_ANNOTATIONS, handler: async (args: z.infer<typeof getKpisSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { kpi_ids } = args; logger.toolCall('get_kpis', { kpi_ids, count: kpi_ids.length }); try { validateBatchSize(kpi_ids, 25); kpi_ids.forEach((id: string) => validateKpiId(id)); const kpis = await koladaClient.batchRequest<KPI>('/kpi', kpi_ids); logger.toolResult('get_kpis', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify( { requested: kpi_ids.length, found: kpis.length, kpis, }, null, 2 ), }, ], }; } catch (error) { logger.toolResult('get_kpis', false, Date.now() - startTime); handleApiError(error, 'get_kpis'); } }, },
  • Global tool registry where kpiTools (containing get_kpis) is spread into allTools used by the MCP server handlers.
    export const allTools = { ...kpiTools, ...municipalityTools, ...ouTools, ...dataTools, ...analysisTools, };
  • Import of kpiTools into the server handlers module.
    import { kpiTools } from '../tools/kpi-tools.js';

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