get_template_detail
Retrieve detailed template content from the MCP server to create new development records. Provide a template name to access complete document structure and formatting.
Instructions
获取指定模板的详细内容。templateName 参数必须使用 get_template_list 返回的 templates 中的 templateName 值。这确保了参数的准确性和一致性。返回模板的完整内容,可用于创建新的开发记录文档。如果模板不存在,会返回明确的错误信息。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| templateName | Yes | 模板文件名(不包含扩展名),必须使用 get_template_list 返回的 templates 中的 templateName |
Implementation Reference
- src/index.ts:165-225 (handler)Handler for the get_template_detail tool: validates input using GetTemplateDetailSchema, checks if template file exists, reads and returns the template content as JSON, or appropriate error messages.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, }; } }
- src/index.ts:26-28 (schema)Zod schema defining the input for get_template_detail: requires '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 ListToolsRequestHandler, including name, description, and inputSchema derived from GetTemplateDetailSchema.{ name: "get_template_detail", description: "获取指定模板的详细内容。templateName 参数必须使用 get_template_list 返回的 templates 中的 templateName 值。" + "这确保了参数的准确性和一致性。返回模板的完整内容,可用于创建新的开发记录文档。" + "如果模板不存在,会返回明确的错误信息。", inputSchema: zodToJsonSchema(GetTemplateDetailSchema) as ToolInput, },