get_school_units_by_status
Filter Swedish school units by operational status to find active, discontinued, or dormant educational institutions for analysis and reporting.
Instructions
Filtrera skolenheter efter status.
ANVÄNDNINGSFALL:
Hitta aktiva skolor
Lista nedlagda skolor
Spåra vilande enheter
Statistik och analys
RETURNERAR: Skolenheter med angiven status.
STATUS: AKTIV, UPPHORT (nedlagd), VILANDE.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| status | Yes | ||
| limit | No |
Implementation Reference
- src/tools/school-units/search.ts:108-142 (handler)The main tool handler function that fetches school units by status from the API client, applies optional limit, formats JSON response with metadata, and handles errors.
export async function getSchoolUnitsByStatus(params: { status: 'AKTIV' | 'UPPHORT' | 'VILANDE'; limit?: number; }) { try { const units = await schoolUnitsApi.getSchoolUnitsByStatus(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({ status: params.status, totalFound: units.length, showing: limitedUnits.length, schoolUnits: limitedUnits }, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text' as const, text: `Fel vid hämtning av skolenheter efter status: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } } - Zod schema for input validation: required status enum and optional limit with default 50.
export const getSchoolUnitsByStatusSchema = { status: z.enum(['AKTIV', 'UPPHORT', 'VILANDE']).describe('Status att filtrera på'), limit: z.number().optional().default(50).describe('Maximalt antal resultat att returnera') }; - src/http-server.ts:74-74 (registration)Tool registration in the HTTP server's tools registry, mapping 'get_school_units_by_status' to the handler function.
get_school_units_by_status: getSchoolUnitsByStatus, - src/api/school-units-client.ts:79-82 (helper)API client helper method that retrieves school units filtered by status using client-side search.
async getSchoolUnitsByStatus(status: 'AKTIV' | 'UPPHORT' | 'VILANDE' | 'PLANERAD'): Promise<any[]> { return this.searchSchoolUnits({ status }); }