get_template_list
Retrieve available development record templates with names and descriptions to identify templates for detailed content access.
Instructions
获取可用的开发记录模板列表。返回包含模板名称、文件名和描述的结构化数据。返回的 templates 数组中每个模板都有 templateName 字段,这是后续调用 get_template_detail 时必需的参数。使用此工具来发现可用的模板,然后使用返回的 templateName 来获取具体模板内容。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dummy | No | Dummy parameter for no-parameter tools |
Implementation Reference
- src/index.ts:110-163 (handler)Main execution logic for the get_template_list tool: validates input, reads template directory, filters .md files, constructs list with templateName, filename, and description, returns structured JSON response.case "get_template_list": { const parsed = GetTemplateListSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for get_template_list: ${parsed.error}`); } try { const templateDir = getTemplateDir(); const files = await readdir(templateDir); // 过滤出 .md 文件并构建模板信息 const templates = files .filter((file: string) => extname(file) === ".md") .map((file: string) => { const templateName = basename(file, ".md"); return { templateName, filename: file, description: getTemplateDescription(templateName) }; }); // 返回标准化格式,便于AI识别和使用 return { content: [ { type: "text", text: JSON.stringify({ success: true, templates, count: templates.length, message: `Found ${templates.length} available templates`, usage: "Use the 'templateName' field from any template to call get_template_detail" }, null, 2) } ] }; } catch (error) { const errorMessage = error instanceof Error ? error.message : String(error); return { content: [ { type: "text", text: JSON.stringify({ success: false, error: `Failed to get template list: ${errorMessage}`, templates: [] }, null, 2) } ], isError: true, }; } }
- src/index.ts:22-24 (schema)Zod input schema for get_template_list tool, allowing optional dummy parameter since it's a no-arg tool.const GetTemplateListSchema = z.object({ dummy: z.string().optional().describe("Dummy parameter for no-parameter tools") });
- src/index.ts:85-91 (registration)Tool registration in listTools handler, defining name, detailed description, and input schema.name: "get_template_list", description: "获取可用的开发记录模板列表。返回包含模板名称、文件名和描述的结构化数据。" + "返回的 templates 数组中每个模板都有 templateName 字段,这是后续调用 get_template_detail 时必需的参数。" + "使用此工具来发现可用的模板,然后使用返回的 templateName 来获取具体模板内容。", inputSchema: zodToJsonSchema(GetTemplateListSchema) as ToolInput, },
- src/index.ts:34-38 (helper)Helper function to resolve the path to the template directory, handling build vs src contexts.function getTemplateDir(): string { // 如果在build目录中运行,需要回到上级目录找src/template const srcDir = __dirname.includes('build') ? join(__dirname, '..', 'src') : __dirname; return join(srcDir, "template"); }
- src/index.ts:56-65 (helper)Helper function providing human-readable descriptions for each template by name.function getTemplateDescription(templateName: string): string { const descriptions: Record<string, string> = { "meeting-record": "会议记录模板 - 用于记录会议内容、决策和行动项", "project-summary": "项目总结模板 - 用于总结项目进展、问题和计划", "learning-notes": "学习笔记模板 - 用于记录学习内容和心得体会", "daily-standup": "每日站会模板 - 用于记录团队每日站会内容" }; return descriptions[templateName] || "通用记录模板"; }