search_school_units
Search for Swedish school units using filters to find schools by name, status (active, closed, dormant), and build school registries for planning and analysis purposes.
Instructions
Sök efter skolenheter med filter.
ANVÄNDNINGSFALL:
Hitta skolor i ett område
Filtrera efter status (aktiva, nedlagda, vilande)
Bygga skolregister
Planering och analys
RETURNERAR: Lista över skolenheter med kod, namn och status.
EXEMPEL: Sök aktiva skolor med status="AKTIV".
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | No | ||
| status | No | ||
| limit | No |
Implementation Reference
- src/tools/school-units/search.ts:30-67 (handler)Main handler function executing the tool logic: searches school units via API, limits results, formats JSON response with error handling.export async function searchSchoolUnits(params: { name?: string; status?: 'AKTIV' | 'UPPHORT' | 'VILANDE'; limit?: number; }) { try { const units = await schoolUnitsApi.searchSchoolUnits({ name: params.name, status: params.status }); // Begränsa antal resultat const limitedUnits = params.limit ? units.slice(0, params.limit) : units.slice(0, 50); return { content: [ { type: 'text' as const, text: JSON.stringify({ totalFound: units.length, showing: limitedUnits.length, schoolUnits: limitedUnits }, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text' as const, text: `Fel vid sökning av skolenheter: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- Zod schema defining input parameters for the search_school_units tool.export const searchSchoolUnitsSchema = { name: z.string().optional().describe('Sök efter skolenhet med namn (delmatchning)'), status: z.enum(['AKTIV', 'UPPHORT', 'VILANDE']).optional().describe('Filtrera på status (AKTIV, UPPHORT, VILANDE)'), limit: z.number().optional().default(50).describe('Maximalt antal resultat att returnera') };
- src/http-server.ts:27-27 (registration)Import statement bringing the searchSchoolUnits handler into the HTTP server module.import { searchSchoolUnits, getSchoolUnitDetails, getSchoolUnitsByStatus, searchSchoolUnitsByName } from './tools/school-units/search.js';
- src/http-server.ts:72-72 (registration)Registration of the tool under the name 'search_school_units' in the tools registry object used by the server.search_school_units: searchSchoolUnits,