Skip to main content
Glama

convert_resume_text

Convert plain text resumes into structured JSON Resume format by automatically identifying sections like personal information, work experience, and education for easier editing and formatting.

Instructions

将纯文本格式的简历内容转换为标准JSON Resume格式。系统会智能识别简历中的各个部分(如个人信息、工作经历、教育背景等),并按照国际通用的JSON Resume标准进行结构化处理,方便后续编辑和格式转换。

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
resumeTextYes

Implementation Reference

  • The MCP tool handler function for 'convert_resume_text'. It validates the input resumeText, calls novaCVService.convertTextToJsonResume(), formats the response using safeStringify, and handles errors by returning structured content.
    async ({ resumeText }, extra) => {
      if (!resumeText) {
        throw new Error("简历文本是必需的");
      }
      
      try {
        const result = await novaCVService.convertTextToJsonResume(resumeText);
        return {
          content: [
            {
              type: "text",
              text: safeStringify(result)
            }
          ],
        };
      } catch (error: any) {
        return {
          content: [
            {
              type: "text",
              text: `错误: ${error.message || "未知错误"}`
            }
          ],
        };
      }
    }
  • Core helper method in NovaCVService that performs the actual API call to convert plain resume text to JSON Resume format via POST /api/v1/resumes/convert-text, normalizes the response structure, and handles errors.
    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;
      }
    }
  • src/index.ts:229-261 (registration)
    Registration of the 'convert_resume_text' tool with the MCP server using server.tool(), including name, description, input schema, and handler reference.
    server.tool(
      "convert_resume_text",
      "将纯文本格式的简历内容转换为标准JSON Resume格式。系统会智能识别简历中的各个部分(如个人信息、工作经历、教育背景等),并按照国际通用的JSON Resume标准进行结构化处理,方便后续编辑和格式转换。",
      {
        resumeText: z.string()
      },
      async ({ resumeText }, extra) => {
        if (!resumeText) {
          throw new Error("简历文本是必需的");
        }
        
        try {
          const result = await novaCVService.convertTextToJsonResume(resumeText);
          return {
            content: [
              {
                type: "text",
                text: safeStringify(result)
              }
            ],
          };
        } catch (error: any) {
          return {
            content: [
              {
                type: "text",
                text: `错误: ${error.message || "未知错误"}`
              }
            ],
          };
        }
      }
    );
  • Zod input schema for the tool: requires a single string parameter 'resumeText'.
    {
      resumeText: z.string()
    },
  • Utility function safeStringify used in tool handlers to safely convert API responses to displayable strings, handling errors and special cases.
    const safeStringify = (data: any): string => {
      try {
        // 特别处理API错误响应
        if (data && data.error) {
          return `API错误: ${data.error.message || JSON.stringify(data.error)}`;
        }
        
        // 处理标准成功响应
        if (data && data.success === true && data.data) {
          const responseData = data.data;
          if (responseData.fileUrl) {
            return `简历生成成功,下载地址: ${responseData.fileUrl}`;
          }
        }
        
        // 默认JSON字符串化
        return JSON.stringify(data, null, 2);
      } catch (err) {
        return "API返回了结果,但无法转换为字符串展示(可能包含循环引用)";
      }
    };

Tool Definition Quality

Score is being calculated. Check back soon.

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