get_kpi_group
Retrieve detailed information about a specific KPI group including all constituent key performance indicators for Swedish municipalities and regions.
Instructions
Hämta detaljerad information om en specifik KPI-grupp inklusive alla ingående nyckeltal. Användbar för att utforska relaterade KPIs.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| group_id | Yes | KPI-grupp ID |
Implementation Reference
- src/tools/kpi-tools.ts:269-297 (handler)The async handler function that implements the core logic of the get_kpi_group tool: fetches the specific KPI group by ID from the Kolada API, handles errors, and returns the group details as JSON.handler: async (args: z.infer<typeof getKpiGroupSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { group_id } = args; logger.toolCall('get_kpi_group', { group_id }); try { const response = await koladaClient.request<KPIGroup>(`/kpi_groups/${group_id}`); if (response.values.length === 0) { const error = ERROR_MESSAGES.GROUP_NOT_FOUND(group_id, 'KPI'); throw createMcpError(KoladaErrorType.NOT_FOUND, error.message, { suggestion: error.suggestion, }); } logger.toolResult('get_kpi_group', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify(response.values[0], null, 2), }, ], }; } catch (error) { logger.toolResult('get_kpi_group', false, Date.now() - startTime); handleApiError(error, `get_kpi_group(${group_id})`); }
- src/tools/kpi-tools.ts:49-51 (schema)Zod input schema for the get_kpi_group tool, requiring a single 'group_id' string parameter.const getKpiGroupSchema = z.object({ group_id: z.string().describe('KPI-grupp ID'), });
- src/tools/kpi-tools.ts:265-299 (registration)Tool registration object within the exported kpiTools, defining description, input schema, annotations, and handler reference for get_kpi_group.get_kpi_group: { description: 'Hämta detaljerad information om en specifik KPI-grupp inklusive alla ingående nyckeltal. Användbar för att utforska relaterade KPIs.', inputSchema: getKpiGroupSchema, annotations: READ_ONLY_ANNOTATIONS, handler: async (args: z.infer<typeof getKpiGroupSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { group_id } = args; logger.toolCall('get_kpi_group', { group_id }); try { const response = await koladaClient.request<KPIGroup>(`/kpi_groups/${group_id}`); if (response.values.length === 0) { const error = ERROR_MESSAGES.GROUP_NOT_FOUND(group_id, 'KPI'); throw createMcpError(KoladaErrorType.NOT_FOUND, error.message, { suggestion: error.suggestion, }); } logger.toolResult('get_kpi_group', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify(response.values[0], null, 2), }, ], }; } catch (error) { logger.toolResult('get_kpi_group', false, Date.now() - startTime); handleApiError(error, `get_kpi_group(${group_id})`); } }, },