Skip to main content
Glama

get_template_detail

Retrieve detailed content of a specified template from the MCP server to create new development records. Ensures accuracy by using template names returned from get_template_list. Returns complete template data or an error if the template is missing.

Instructions

获取指定模板的详细内容。templateName 参数必须使用 get_template_list 返回的 templates 中的 templateName 值。这确保了参数的准确性和一致性。返回模板的完整内容,可用于创建新的开发记录文档。如果模板不存在,会返回明确的错误信息。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
templateNameYes模板文件名(不包含扩展名),必须使用 get_template_list 返回的 templates 中的 templateName

Implementation Reference

  • The main handler for get_template_detail tool inside the switch statement in CallToolRequestSchema handler. Validates input with GetTemplateDetailSchema, reads the template file from the template directory, and returns its content as JSON or error if not found.
    case "get_template_detail": { const parsed = GetTemplateDetailSchema.safeParse(args); if (!parsed.success) { throw new Error(`Invalid arguments for get_template_detail: ${parsed.error}`); } try { const { templateName } = parsed.data; const templateDir = getTemplateDir(); const templatePath = join(templateDir, `${templateName}.md`); if (!existsSync(templatePath)) { return { content: [ { type: "text", text: JSON.stringify({ success: false, error: `Template '${templateName}' does not exist`, templateName, suggestion: "Use get_template_list to see available templates" }, null, 2) } ], isError: true, }; } const content = await readFile(templatePath, "utf-8"); return { content: [ { type: "text", text: JSON.stringify({ success: true, templateName, content, description: getTemplateDescription(templateName), message: `Successfully retrieved template '${templateName}'` }, 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 detail: ${errorMessage}`, templateName: parsed.data?.templateName || "unknown" }, null, 2) } ], isError: true, }; } }
  • Zod schema for validating the input to get_template_detail tool, requiring a 'templateName' string.
    const GetTemplateDetailSchema = z.object({ templateName: z.string().describe("模板文件名(不包含扩展名),必须使用 get_template_list 返回的 templates 中的 templateName") });
  • src/index.ts:92-99 (registration)
    Registration of the get_template_detail tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    { name: "get_template_detail", description: "获取指定模板的详细内容。templateName 参数必须使用 get_template_list 返回的 templates 中的 templateName 值。" + "这确保了参数的准确性和一致性。返回模板的完整内容,可用于创建新的开发记录文档。" + "如果模板不存在,会返回明确的错误信息。", inputSchema: zodToJsonSchema(GetTemplateDetailSchema) as ToolInput, },
  • Helper function getTemplateDescription used in the handler to provide descriptions for templates.
    function getTemplateDescription(templateName: string): string { const descriptions: Record<string, string> = { "meeting-record": "会议记录模板 - 用于记录会议内容、决策和行动项", "project-summary": "项目总结模板 - 用于总结项目进展、问题和计划", "learning-notes": "学习笔记模板 - 用于记录学习内容和心得体会", "daily-standup": "每日站会模板 - 用于记录团队每日站会内容" }; return descriptions[templateName] || "通用记录模板"; }
  • Helper function getTemplateDir used in the handler to locate the template directory.
    function getTemplateDir(): string { // 如果在build目录中运行,需要回到上级目录找src/template const srcDir = __dirname.includes('build') ? join(__dirname, '..', 'src') : __dirname; return join(srcDir, "template"); }

Other Tools

Related Tools

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/seenbefore/DevRecord'

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