search_teachers_advanced
Filter and sort teachers on Manalink by subject, grade level, teaching features, desired period, and criteria like certification or ratings for precise tutor matching.
Instructions
科目、学年、特徴、ソート順、指導期間を指定して先生を検索します
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| course_feature_id | No | 特徴ID | |
| desired_teaching_period | No | 指導期間 (monthly: 長期, once: 短期) | |
| grade_ids | No | 学年IDの配列 | |
| sort | No | ソート順 | |
| subject_ids | No | 科目IDの配列 |
Input Schema (JSON Schema)
{
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"course_feature_id": {
"description": "特徴ID",
"type": "number"
},
"desired_teaching_period": {
"description": "指導期間 (monthly: 長期, once: 短期)",
"enum": [
"monthly",
"once"
],
"type": "string"
},
"grade_ids": {
"description": "学年IDの配列",
"items": {
"type": "number"
},
"type": "array"
},
"sort": {
"description": "ソート順",
"enum": [
"pr",
"certification",
"rating",
"lesson_count",
"latest"
],
"type": "string"
},
"subject_ids": {
"description": "科目IDの配列",
"items": {
"type": "number"
},
"type": "array"
}
},
"type": "object"
}
Implementation Reference
- src/utils/api.ts:137-188 (handler)Core handler function that implements the advanced teacher search by building query parameters, fetching HTML from manalink.jp, extracting body content, and converting to Markdown.export async function searchTeachers(params: TeacherSearchParams): Promise<{ bodyContent: string, markdown: string, url: string }> { try { // URLパラメータを構築 const queryParams = new URLSearchParams(); // 各パラメータを適切に設定 if (params.grade_ids && params.grade_ids.length > 0) { queryParams.set('target_grade', params.grade_ids[0].toString()); } if (params.subject_ids && params.subject_ids.length > 0) { queryParams.set('subject_ids', params.subject_ids.join(',')); } if (params.course_feature_id) { queryParams.set('course_feature_id', params.course_feature_id.toString()); } if (params.sort) { queryParams.set('sort', params.sort); } if (params.desired_teaching_period) { queryParams.set('desired_teaching_period', params.desired_teaching_period); } // 必ずwithout_fully_booked=true queryParams.set('without_fully_booked', 'true'); // 検索URLを構築 const searchUrl = `${MANALINK_BASE_URL}/teacher/search/filter?${queryParams.toString()}`; // HTMLを取得 const html = await fetchHTML(searchUrl); // bodyタグの内容を抽出 const bodyContent = extractBodyContent(html); // HTMLをMarkdownに変換 const markdown = convertHtmlToMarkdown(bodyContent); // bodyコンテンツとURLとMarkdownを返す return { bodyContent, markdown, url: searchUrl }; } catch (error) { console.error('先生検索に失敗しました:', error); throw new Error('先生検索に失敗しました'); } }
- src/utils/api.ts:107-113 (schema)TypeScript interface defining the input parameters for the searchTeachers function, matching the tool's input schema.export interface TeacherSearchParams { subject_ids?: number[]; grade_ids?: number[]; course_feature_id?: number; sort?: 'pr' | 'certification' | 'rating' | 'lesson_count' | 'latest'; desired_teaching_period?: 'monthly' | 'once'; }
- src/server.ts:79-109 (registration)MCP tool registration including name, description, Zod input schema validation, and handler that calls searchTeachers and returns markdown content.server.tool( "search_teachers_advanced", "科目、学年、特徴、ソート順、指導期間を指定して先生を検索します", { subject_ids: z.array(z.number()).optional().describe("科目IDの配列"), grade_ids: z.array(z.number()).optional().describe("学年IDの配列"), course_feature_id: z.number().optional().describe("特徴ID"), sort: z.enum(['pr', 'certification', 'rating', 'lesson_count', 'latest']).optional().describe("ソート順"), desired_teaching_period: z.enum(['monthly', 'once']).optional().describe("指導期間 (monthly: 長期, once: 短期)") }, async (params) => { try { const result = await searchTeachers(params as TeacherSearchParams); return { content: [{ type: "text" as const, text: result.markdown.slice(0, 30000) }] }; } catch (error) { console.error('先生検索に失敗しました:', error); return { content: [{ type: "text" as const, text: `エラーが発生しました: ${error instanceof Error ? error.message : '不明なエラー'}` }], isError: true }; } } );