Skip to main content
Glama

generate_resume_from_text

Convert resume text into professional PDF resumes with customizable templates. Provide your resume content to generate formatted PDF files without manual JSON processing.

Instructions

一键将简历文本转换为精美PDF简历,支持多种模板。只需提供简历文本内容,系统会自动进行格式转换并生成专业PDF文件,无需手动处理JSON数据。可选择不同简历模板和定制选项。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resumeTextYes
templateNameNo
optionsNo

Implementation Reference

  • Main handler function for 'generate_resume_from_text' tool. Converts resume text to JSON Resume format using NovaCVService, extracts the data, then generates PDF resume, and returns the result.
    async ({ resumeText, templateName = "elite", options = {} }, extra) => {
      if (!resumeText) {
        throw new Error("简历文本是必需的");
      }
      
      try {
        // 第一步:将文本转换为JSON Resume格式
        const convertResult = await novaCVService.convertTextToJsonResume(resumeText);
        
        // 调试输出API响应结构
        console.log("转换API响应:", JSON.stringify(convertResult, null, 2));
        
        if (!convertResult || convertResult.error) {
          return {
            content: [
              {
                type: "text",
                text: `转换简历文本失败: ${convertResult?.error?.message || convertResult?.message || "未知错误"}`
              }
            ],
          };
        }
        
        // 根据实际API响应结构获取简历数据
        // 尝试多种可能的路径
        let resumeData = null;
        if (convertResult.data && convertResult.data.resumeData) {
          resumeData = convertResult.data.resumeData;
        } else if (convertResult.data && convertResult.data.jsonResume) {
          // 处理API返回的jsonResume路径
          resumeData = convertResult.data.jsonResume;
        } else if (convertResult.resumeData) {
          resumeData = convertResult.resumeData;
        } else if (convertResult.jsonResume) {
          resumeData = convertResult.jsonResume;
        } else if (typeof convertResult === 'object' && Object.keys(convertResult).length > 0) {
          // 如果响应本身就是简历数据对象
          if (convertResult.basics || convertResult.work || convertResult.education) {
            resumeData = convertResult;
          }
        }
        
        // 检查是否获取到简历数据
        if (!resumeData) {
          // 输出完整响应以帮助调试
          return {
            content: [
              {
                type: "text",
                text: `转换成功但无法获取简历数据。API响应:\n${JSON.stringify(convertResult, null, 2)}`
              }
            ],
          };
        }
        
        // 第二步:使用JSON Resume数据生成PDF
        console.log("使用以下数据生成PDF:", JSON.stringify(resumeData, null, 2));
        const generateResult = await novaCVService.generateResume(resumeData, templateName, options);
        
        return {
          content: [
            {
              type: "text",
              text: safeStringify(generateResult)
            }
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `错误: ${error.message || "未知错误"}`
            }
          ],
        };
      }
    }
  • Zod input schema for the tool: resumeText (required string), optional templateName (string), optional options (object).
    {
      resumeText: z.string(),
      templateName: z.string().optional(),
      options: z.object({}).optional()
    },
  • src/index.ts:113-199 (registration)
    Registration of the 'generate_resume_from_text' tool using server.tool(), including description, schema, and inline handler.
    server.tool(
      "generate_resume_from_text",
      "一键将简历文本转换为精美PDF简历,支持多种模板。只需提供简历文本内容,系统会自动进行格式转换并生成专业PDF文件,无需手动处理JSON数据。可选择不同简历模板和定制选项。",
      {
        resumeText: z.string(),
        templateName: z.string().optional(),
        options: z.object({}).optional()
      },
      async ({ resumeText, templateName = "elite", options = {} }, extra) => {
        if (!resumeText) {
          throw new Error("简历文本是必需的");
        }
        
        try {
          // 第一步:将文本转换为JSON Resume格式
          const convertResult = await novaCVService.convertTextToJsonResume(resumeText);
          
          // 调试输出API响应结构
          console.log("转换API响应:", JSON.stringify(convertResult, null, 2));
          
          if (!convertResult || convertResult.error) {
            return {
              content: [
                {
                  type: "text",
                  text: `转换简历文本失败: ${convertResult?.error?.message || convertResult?.message || "未知错误"}`
                }
              ],
            };
          }
          
          // 根据实际API响应结构获取简历数据
          // 尝试多种可能的路径
          let resumeData = null;
          if (convertResult.data && convertResult.data.resumeData) {
            resumeData = convertResult.data.resumeData;
          } else if (convertResult.data && convertResult.data.jsonResume) {
            // 处理API返回的jsonResume路径
            resumeData = convertResult.data.jsonResume;
          } else if (convertResult.resumeData) {
            resumeData = convertResult.resumeData;
          } else if (convertResult.jsonResume) {
            resumeData = convertResult.jsonResume;
          } else if (typeof convertResult === 'object' && Object.keys(convertResult).length > 0) {
            // 如果响应本身就是简历数据对象
            if (convertResult.basics || convertResult.work || convertResult.education) {
              resumeData = convertResult;
            }
          }
          
          // 检查是否获取到简历数据
          if (!resumeData) {
            // 输出完整响应以帮助调试
            return {
              content: [
                {
                  type: "text",
                  text: `转换成功但无法获取简历数据。API响应:\n${JSON.stringify(convertResult, null, 2)}`
                }
              ],
            };
          }
          
          // 第二步:使用JSON Resume数据生成PDF
          console.log("使用以下数据生成PDF:", JSON.stringify(resumeData, null, 2));
          const generateResult = await novaCVService.generateResume(resumeData, templateName, options);
          
          return {
            content: [
              {
                type: "text",
                text: safeStringify(generateResult)
              }
            ],
          };
        } catch (error: any) {
          return {
            content: [
              {
                type: "text",
                text: `错误: ${error.message || "未知错误"}`
              }
            ],
          };
        }
      }
    );
  • Helper method in NovaCVService that calls the API to convert plain resume text to structured JSON Resume format.
    async convertTextToJsonResume(resumeText: string): Promise<any> {
      try {
        console.log("开始转换简历文本为JSON格式");
        const response = await this.client.post('/api/v1/resumes/convert-text', {
          resumeText
        });
        console.log("转换API响应状态码:", response.status);
        console.log("转换API响应头:", JSON.stringify(response.headers, null, 2));
        console.log("转换API响应数据类型:", typeof response.data);
        
        // 如果直接返回简历数据,自动包装为标准格式
        if (response.data && typeof response.data === 'object') {
          // 检查是否缺少标准响应结构
          if (!response.data.success && !response.data.data && !response.data.error) {
            // 检查是否是简历数据结构
            if (response.data.basics || response.data.work || response.data.education) {
              return {
                success: true,
                data: {
                  jsonResume: response.data
                }
              };
            }
          } 
          // 标准化响应 - 确保jsonResume数据在一致的位置
          else if (response.data.success && response.data.data) {
            // 如果有data.resumeData但没有data.jsonResume,复制数据
            if (response.data.data.resumeData && !response.data.data.jsonResume) {
              response.data.data.jsonResume = response.data.data.resumeData;
            }
            // 如果有data.jsonResume但没有data.resumeData,复制数据
            else if (response.data.data.jsonResume && !response.data.data.resumeData) {
              response.data.data.resumeData = response.data.data.jsonResume;
            }
          }
        }
        
        return response.data;
      } catch (error) {
        console.error("转换简历文本失败:", error);
        this._handleError(error);
        throw error;
      }
    }
  • Helper method in NovaCVService that calls the API to generate PDF resume from JSON Resume data using specified template.
    async generateResume(
      resumeData: any, 
      templateName: string = 'elite', 
      options: any = {}
    ): Promise<any> {
      try {
        // 基本检查,确保数据不为空
        if (!resumeData) {
          throw new Error("resumeData 不能为空");
        }
        
        // 确保resumeData是对象格式
        let processedResumeData: any;
        if (typeof resumeData === 'string') {
          try {
            processedResumeData = JSON.parse(resumeData);
          } catch (e: any) {
            throw new Error(`无法解析resumeData字符串为JSON: ${e.message}`);
          }
        } else {
          processedResumeData = resumeData;
        }
        
        // 构建请求数据对象
        const requestData = {
          resumeData: processedResumeData,
          templateName,
          options
        };
        
        // 发送请求到NovaCV API
        const response = await this.client.post('/api/v1/resumes/generate', requestData);
        
        return response.data;
      } catch (error) {
        this._handleError(error);
        throw error;
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It mentions the tool generates PDF files and supports templates, but lacks critical details: whether this is a read-only or write operation (implied write but not confirmed), authentication requirements, rate limits, error handling, or what happens to the input text. For a tool with no annotations and 3 parameters, this is insufficient.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, stating the core purpose in the first sentence. It uses two sentences to cover key features (template support, no manual JSON processing), with minimal redundancy. However, it could be slightly more structured by separating usage notes from functionality.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity (3 parameters, no annotations, no output schema), the description is incomplete. It doesn't explain the output (e.g., PDF file format, return type), error conditions, or behavioral nuances. For a tool that generates files and has sibling tools, more context is needed to ensure correct usage by an AI agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 0%, so the description must compensate. It mentions '简历文本内容' (resume text content) for 'resumeText', '多种模板' (multiple templates) and '简历模板' (resume templates) for 'templateName', and '定制选项' (customization options) for 'options'. However, it doesn't explain parameter formats, constraints, or examples (e.g., what template names are valid, what 'options' object contains). With 3 parameters and low coverage, this adds only basic meaning.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose: '将简历文本转换为精美PDF简历' (convert resume text to beautiful PDF resume). It specifies the verb (convert), resource (resume text), and output format (PDF). However, it doesn't explicitly differentiate from sibling tools like 'convert_resume_text' or 'analyze_resume_text', which likely have different functions.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides minimal guidance on when to use this tool. It mentions '支持多种模板' (supports multiple templates) and '可选择不同简历模板和定制选项' (can choose different resume templates and customization options), but doesn't clarify when to use this vs. alternatives like 'convert_resume_text' or 'get_templates'. No explicit exclusions or prerequisites are stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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/HireTechUpUp/mcp-server-novacv'

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