get_municipality_group
Retrieve detailed information about a specific Swedish municipality group including all member municipalities for statistical analysis and comparisons of similar municipalities.
Instructions
Hämta detaljerad information om en specifik kommungrupp inklusive alla medlemskommuner. Användbar för att analysera grupper av liknande kommuner.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| group_id | Yes | Kommungrupp-ID |
Implementation Reference
- src/tools/municipality-tools.ts:207-245 (handler)The main handler function that executes the tool logic: fetches municipality group details from Kolada API using group_id, handles not found errors, logs execution.handler: async (args: z.infer<typeof getMunicipalityGroupSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { group_id } = args; logger.toolCall('get_municipality_group', { group_id }); try { const response = await koladaClient.request<MunicipalityGroup>(`/municipality_groups/${group_id}`); if (response.values.length === 0) { logger.toolResult('get_municipality_group', false, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify({ error: 'NOT_FOUND', message: `Kommungrupp med ID "${group_id}" hittades inte`, suggestion: 'Använd get_municipality_groups för att hitta giltiga grupp-ID:n', }), }, ], isError: true, }; } logger.toolResult('get_municipality_group', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify(response.values[0], null, 2), }, ], }; } catch (error) { logger.toolResult('get_municipality_group', false, Date.now() - startTime); throw error; }
- Zod input schema validating the 'group_id' parameter.const getMunicipalityGroupSchema = z.object({ group_id: z.string().describe('Kommungrupp-ID'), });
- src/server/handlers.ts:32-38 (registration)Registration of municipalityTools (containing get_municipality_group) into the central allTools object used by MCP server for tool listing and calling.export const allTools = { ...kpiTools, ...municipalityTools, ...ouTools, ...dataTools, ...analysisTools, };
- src/server/handlers.ts:12-12 (registration)Import of municipalityTools module containing the tool definition.import { municipalityTools } from '../tools/municipality-tools.js';