get_organizational_unit
Retrieve detailed information about a specific organizational unit using its ID to access Swedish municipal and regional data for analysis and comparisons.
Instructions
Hämta detaljerad information om en specifik organisationsenhet via dess ID.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| ou_id | Yes | Organisationsenhet-ID |
Implementation Reference
- src/tools/ou-tools.ts:102-145 (handler)Full tool definition including the handler function that executes the core logic: fetches OU details from Kolada API via koladaClient.request(`/ou/${ou_id}`), handles not found cases, logs execution, and returns JSON-formatted response or error.get_organizational_unit: { description: 'Hämta detaljerad information om en specifik organisationsenhet via dess ID.', inputSchema: getOuSchema, annotations: READ_ONLY_ANNOTATIONS, handler: async (args: z.infer<typeof getOuSchema>): Promise<ToolResult> => { const startTime = Date.now(); const { ou_id } = args; logger.toolCall('get_organizational_unit', { ou_id }); try { const response = await koladaClient.request<OrganizationalUnit>(`/ou/${ou_id}`); if (response.values.length === 0) { logger.toolResult('get_organizational_unit', false, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify({ error: 'NOT_FOUND', message: `Organisationsenhet med ID "${ou_id}" hittades inte`, suggestion: 'Använd search_organizational_units för att hitta giltiga OU-ID:n', }), }, ], isError: true, }; } logger.toolResult('get_organizational_unit', true, Date.now() - startTime); return { content: [ { type: 'text', text: JSON.stringify(response.values[0], null, 2), }, ], }; } catch (error) { logger.toolResult('get_organizational_unit', false, Date.now() - startTime); throw error; } },
- src/tools/ou-tools.ts:27-29 (schema)Zod input schema for validating the 'ou_id' parameter required by the tool.const getOuSchema = z.object({ ou_id: z.string().describe('Organisationsenhet-ID'), });
- src/server/handlers.ts:32-38 (registration)Registration of ouTools (containing get_organizational_unit) into the central allTools object used by MCP server handlers for listing and calling tools.export const allTools = { ...kpiTools, ...municipalityTools, ...ouTools, ...dataTools, ...analysisTools, };