search_subjects
Search for subjects in the Swedish National Agency for Education's curriculum to find courses by school type, compare subjects across time periods, and explore subject structure and content.
Instructions
Sök efter ämnen i Skolverkets läroplan.
ANVÄNDNINGSFALL:
Hitta ämnen för en specifik skoltyp (grundskola, gymnasium, etc.)
Jämföra ämnen över tid (senaste, historiska, alla versioner)
Utforska ämnens struktur och innehåll
RETURNERAR: Lista över ämnen med kod, namn, beskrivning och version.
EXEMPEL: För att hitta alla ämnen i gymnasiet, använd schooltype="GY" och timespan="LATEST".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schooltype | No | ||
| timespan | No | ||
| typeOfSyllabus | No |
Implementation Reference
- src/tools/syllabus/subjects.ts:28-75 (handler)The main handler function that executes the logic for the 'search_subjects' tool. It calls the syllabus API, limits results, formats the response as JSON, and handles errors.export async function searchSubjects(params: { schooltype?: string; timespan?: 'LATEST' | 'FUTURE' | 'EXPIRED' | 'MODIFIED'; typeOfSyllabus?: string; date?: string; limit?: number; }) { try { const result = await syllabusApi.searchSubjects(params); // Begränsa antal resultat för att undvika stora responses const maxResults = Math.min(params.limit || 50, 200); const limitedSubjects = result.subjects.slice(0, maxResults); const hasMore = result.totalElements > maxResults; return { content: [ { type: 'text' as const, text: JSON.stringify({ totalElements: result.totalElements, returned: limitedSubjects.length, hasMore: hasMore, message: hasMore ? `Visar ${limitedSubjects.length} av ${result.totalElements} ämnen. Använd mer specifika filter för att begränsa resultatet.` : undefined, subjects: limitedSubjects.map(s => ({ code: s.code, name: s.name, schoolType: s.schoolType, typeOfSyllabus: s.typeOfSyllabus, version: s.version, description: s.description?.substring(0, 150) + (s.description && s.description.length > 150 ? '...' : '') })) }, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text' as const, text: `Fel vid sökning av ämnen: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; } }
- src/tools/syllabus/subjects.ts:9-15 (schema)Zod schema defining the input parameters and descriptions for the search_subjects tool.export const searchSubjectsSchema = { schooltype: z.string().optional().describe('Skoltyp (t.ex. "GR" för grundskola, "GY" för gymnasium)'), timespan: z.enum(['LATEST', 'FUTURE', 'EXPIRED', 'MODIFIED']).default('LATEST').describe('Tidsperiod: LATEST (gällande), FUTURE (framtida), EXPIRED (utgångna), MODIFIED (ändrade)'), typeOfSyllabus: z.string().optional().describe('Typ av läroplan (t.ex. "SUBJECT_SYLLABUS", "COURSE_SYLLABUS")'), date: z.string().optional().describe('Datum i formatet YYYY-MM-DD för att hämta ämnen som var giltiga vid det datumet'), limit: z.number().optional().default(50).describe('Max antal resultat att returnera (default: 50, max: 200)') };
- src/http-server.ts:51-87 (registration)Registration of the 'search_subjects' tool in the HTTP server's tool registry, mapping the tool name to the imported searchSubjects handler function.const tools: Record<string, (args: any) => Promise<any>> = { // Syllabus API search_subjects: searchSubjects, get_subject_details: getSubjectDetails, get_subject_versions: getSubjectVersions, search_courses: searchCourses, get_course_details: getCourseDetails, get_course_versions: getCourseVersions, search_programs: searchPrograms, get_program_details: getProgramDetails, get_program_versions: getProgramVersions, search_curriculums: searchCurriculums, get_curriculum_details: getCurriculumDetails, get_curriculum_versions: getCurriculumVersions, get_school_types: getSchoolTypes, get_types_of_syllabus: getTypesOfSyllabus, get_subject_and_course_codes: getSubjectAndCourseCodes, get_study_path_codes: getStudyPathCodes, get_api_info: getApiInfo, // School Units API search_school_units: searchSchoolUnits, get_school_unit_details: getSchoolUnitDetails, get_school_units_by_status: getSchoolUnitsByStatus, search_school_units_by_name: searchSchoolUnitsByName, // Planned Education API search_adult_education: searchAdultEducation, get_adult_education_details: getAdultEducationDetails, filter_adult_education_by_distance: filterAdultEducationByDistance, filter_adult_education_by_pace: filterAdultEducationByPace, get_education_areas: getEducationAreas, get_directions: getDirections, // Diagnostics health_check: healthCheck, };