Skip to main content
Glama

get_kpi

Retrieve detailed metadata for specific Swedish public sector KPIs using their unique identifiers. Access publication dates, gender breakdowns, and comprehensive statistical information for analysis and comparison.

Instructions

Hämta detaljerad information om ett specifikt nyckeltal (KPI) via dess ID. Returnerar fullständig metadata inklusive publiceringsdatum och könsuppdelning.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
kpi_idYesKPI-ID (t.ex. "N15033")

Implementation Reference

  • The async handler function that implements the core logic of the get_kpi tool: validates kpi_id, fetches KPI details from Kolada API, handles errors, and returns formatted JSON response.
    handler: async (args: z.infer<typeof getKpiSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { kpi_id } = args; logger.toolCall('get_kpi', { kpi_id }); try { validateKpiId(kpi_id); const response = await koladaClient.request<KPI>(`/kpi/${kpi_id}`); if (response.values.length === 0) { const error = ERROR_MESSAGES.KPI_NOT_FOUND(kpi_id); throw createMcpError(KoladaErrorType.NOT_FOUND, error.message, { suggestion: error.suggestion, }); } logger.toolResult('get_kpi', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify(response.values[0], null, 2), }, ], }; } catch (error) { logger.toolResult('get_kpi', false, Date.now() - startTime); handleApiError(error, `get_kpi(${kpi_id})`); }
  • Zod input schema for the get_kpi tool, defining the required kpi_id parameter as a string.
    const getKpiSchema = z.object({ kpi_id: z.string().describe('KPI-ID (t.ex. "N15033")'), });
  • Registration of all tools including get_kpi (via spread of kpiTools) into the central allTools object used by MCP server handlers for tool listing and execution.
    export const allTools = { ...kpiTools, ...municipalityTools, ...ouTools, ...dataTools, ...analysisTools, };
  • Tool definition and local registration within kpiTools export, including description, schema reference, annotations, and handler.
    get_kpi: { description: 'Hämta detaljerad information om ett specifikt nyckeltal (KPI) via dess ID. Returnerar fullständig metadata inklusive publiceringsdatum och könsuppdelning.', inputSchema: getKpiSchema, annotations: READ_ONLY_ANNOTATIONS, handler: async (args: z.infer<typeof getKpiSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { kpi_id } = args; logger.toolCall('get_kpi', { kpi_id }); try { validateKpiId(kpi_id); const response = await koladaClient.request<KPI>(`/kpi/${kpi_id}`); if (response.values.length === 0) { const error = ERROR_MESSAGES.KPI_NOT_FOUND(kpi_id); throw createMcpError(KoladaErrorType.NOT_FOUND, error.message, { suggestion: error.suggestion, }); } logger.toolResult('get_kpi', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify(response.values[0], null, 2), }, ], }; } catch (error) { logger.toolResult('get_kpi', false, Date.now() - startTime); handleApiError(error, `get_kpi(${kpi_id})`); } },

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