get_subject_and_course_codes
Retrieve all available subject and course codes from Swedish educational data to explore curriculum offerings, identify correct codes for searches, and build educational overviews.
Instructions
Hämta alla tillgängliga ämnes- och kurskoder.
ANVÄNDNINGSFALL:
Utforska hela kursutbudet
Hitta rätt kod för sökning
Bygga översikter
RETURNERAR: Komplett lista över alla koder med typ (subject/course).
OBS: Stor datamängd, kan ta tid att ladda.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/syllabus/valuestore.ts:86-113 (handler)The primary handler function for the 'get_subject_and_course_codes' tool. It calls the syllabus API, processes the response with counts for subjects and courses, and returns a formatted MCP content response or error.export async function getSubjectAndCourseCodes() { try { const codes = await syllabusApi.getSubjectAndCourseCodes(); return { content: [ { type: 'text' as const, text: JSON.stringify({ codes: codes, total: codes.length, subjects: codes.filter(c => c.type === 'SUBJECT').length, courses: codes.filter(c => c.type === 'COURSE').length }, null, 2) } ] }; } catch (error) { return { content: [ { type: 'text' as const, text: `Fel vid hämtning av ämnes- och kurskoder: ${error instanceof Error ? error.message : String(error)}` } ], isError: true }; }
- src/http-server.ts:65-69 (registration)Registration of the tool 'get_subject_and_course_codes' in the HTTP server's tools registry, mapping the snake_case name to the camelCase handler function.get_school_types: getSchoolTypes, get_types_of_syllabus: getTypesOfSyllabus, get_subject_and_course_codes: getSubjectAndCourseCodes, get_study_path_codes: getStudyPathCodes, get_api_info: getApiInfo,
- src/api/syllabus-client.ts:138-145 (helper)Helper method in the Syllabus API client that fetches subject and course codes from Skolverket's valuestore endpoint with 24-hour caching.async getSubjectAndCourseCodes(): Promise<SubjectAndCourseCode[]> { const response = await this.getCached<{ codes: SubjectAndCourseCode[] }>( '/v1/valuestore/subjectandcoursecodes', undefined, 86400000 // 24 timmar cache ); return response.codes || []; }