Skip to main content
Glama
sifue
by sifue

get-list-of-all-subjects

Retrieve all courses from ZEN University's syllabus with essential details like name, grade requirements, quarters offered, and credits to help students plan their curriculum.

Instructions

Retrieve a simplified list of all courses from the ZEN University syllabus, containing only the essential properties (name, enrollmentGrade, quarters, credit).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • Handler function that fetches all subjects using fetchAllPages, simplifies the data, formats it to text using helper functions, and returns as text content.
    async () => { try { const result = await fetchAllPages(); // Extract only the required properties from each subject const simplifiedSubjects = result.subjects.map(subject => ({ // code: subject.code, name: subject.name, // description: subject.description, // thumbnailUrl: subject.thumbnailUrl, openingYear: subject.openingYear, metadata: { enrollmentGrade: subject.metadata.enrollmentGrade, teachingMethod: subject.metadata.teachingMethod, subjectRequirement: subject.metadata.subjectRequirement, evaluationSystem: subject.metadata.evaluationSystem, credit: subject.metadata.credit, quarters: subject.metadata.quarters, objective: subject.metadata.objective, specialNotes: subject.metadata.specialNotes, coursePlans: subject.metadata.coursePlans || [] }, subjectCategoryIds: subject.subjectCategoryIds || [] })); // テキスト形式に変換 const formattedText = formatSimplifiedSubjectsToText(simplifiedSubjects); return { content: [ { type: "text", text: formattedText, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${error}`, }, ], }; } },
  • src/index.ts:212-264 (registration)
    Registration of the get-list-of-all-subjects tool with server.tool, including name, description, empty input schema, and handler function.
    server.tool( "get-list-of-all-subjects", "Retrieve a simplified list of all courses from the ZEN University syllabus, containing only the essential properties (name, enrollmentGrade, quarters, credit).", {}, async () => { try { const result = await fetchAllPages(); // Extract only the required properties from each subject const simplifiedSubjects = result.subjects.map(subject => ({ // code: subject.code, name: subject.name, // description: subject.description, // thumbnailUrl: subject.thumbnailUrl, openingYear: subject.openingYear, metadata: { enrollmentGrade: subject.metadata.enrollmentGrade, teachingMethod: subject.metadata.teachingMethod, subjectRequirement: subject.metadata.subjectRequirement, evaluationSystem: subject.metadata.evaluationSystem, credit: subject.metadata.credit, quarters: subject.metadata.quarters, objective: subject.metadata.objective, specialNotes: subject.metadata.specialNotes, coursePlans: subject.metadata.coursePlans || [] }, subjectCategoryIds: subject.subjectCategoryIds || [] })); // テキスト形式に変換 const formattedText = formatSimplifiedSubjectsToText(simplifiedSubjects); return { content: [ { type: "text", text: formattedText, }, ], }; } catch (error) { return { content: [ { type: "text", text: `Error: ${error}`, }, ], }; } }, );
  • Core helper function fetchAllPages that fetches all pages from the syllabus API, merges subjects from all pages.
    async function fetchAllPages(options?: FetchOptions) { // まず最初のページを取得 const firstPageUrl = createUrl(0, options); const firstResponse = await fetch(firstPageUrl); if (!firstResponse.ok) { throw new Error(`APIリクエストに失敗しました: ${firstResponse.status} ${firstResponse.statusText}`); } const firstData = (await firstResponse.json()) as ApiResponse; const allSubjects = [...firstData.subjects]; const { totalPages, totalCount, pageSize, relatedTags } = firstData; // 2ページ目以降を順次取得 (page=1 ~ totalPages-1) for (let page = 1; page < totalPages; page++) { const url = createUrl(page, options); const response = await fetch(url); if (!response.ok) { throw new Error(`APIリクエストに失敗しました: ${response.status} ${response.statusText}`); } const data = (await response.json()) as ApiResponse; allSubjects.push(...data.subjects); } // 単一のオブジェクトとしてまとめる const mergedData = { totalCount, pageSize, page: 0, // 全ページのデータを結合した結果なので、page=0 とする totalPages, relatedTags, subjects: allSubjects, }; return mergedData; }
  • Helper function to format the list of simplified subjects into a readable text string.
    function formatSimplifiedSubjectsToText(subjects: any[]): string { let text = `検索結果: ${subjects.length}件の科目が見つかりました\n\n`; // 科目名と想定年次のリスト const subjectList = subjects.map(subject => formatSimplifiedSubjectToText(subject)); // 1行に1科目ずつ表示 text += subjectList.join('\n'); return text; }
  • Helper function to get category names from subject category IDs.
    function getCategoryName(categoryIds: string[]): string { if (!categoryIds || categoryIds.length === 0) { return "未分類"; } const categoryMap: Record<string, string> = { "basic": "導入科目", "applied_informatics": "基盤リテラシー科目 (情報)", "mathematical_sciences": "基盤リテラシー科目 (数理)", "multilingual_information_understanding": "多言語情報理解科目", "culture_and_thoughts": "世界理解科目 (文化・思想)", "society_and_networks": "世界理解科目 (社会・ネットワーク)", "economy_and_markets": "世界理解科目 (経済・マーケット)", "digital_industr": "世界理解科目 (デジタル産業)", "social_connection": "社会接続科目", "graduation_project": "卒業プロジェクト科目", "free": "自由科目" }; // カテゴリーIDに対応する分類名を取得 const categoryNames = categoryIds.map(id => categoryMap[id] || "未分類"); // 重複を排除 return [...new Set(categoryNames)].join(", "); }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/sifue/zen-syllabus-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server