Skip to main content
Glama

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
NameRequiredDescriptionDefault
templateNameYes模板文件名(不包含扩展名),必须使用 get_template_list 返回的 templates 中的 templateName

Implementation Reference

  • 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,
        };
      }
    }
  • 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,
    },
Install Server

Other 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