get_templates
Retrieve a list of available resume templates with details like template ID, name, and thumbnail, enabling users to select the most suitable style for their CV.
Instructions
获取所有可用的简历模板,返回模板列表及其详细信息,包括模板ID、名称、缩略图等。帮助用户选择最适合的简历风格。
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:201-227 (registration)Registration of the MCP tool 'get_templates' with description, empty input schema {}, and inline handler function that calls the service method and returns formatted content.server.tool( "get_templates", "获取所有可用的简历模板,返回模板列表及其详细信息,包括模板ID、名称、缩略图等。帮助用户选择最适合的简历风格。", {}, async (_, extra) => { try { const templates = await novaCVService.getTemplates(); return { content: [ { type: "text", text: safeStringify(templates) } ], }; } catch (error: any) { return { content: [ { type: "text", text: `错误: ${error.message || "未知错误"}` } ], }; } } );
- src/services/novacv.ts:125-133 (handler)Core handler logic in NovaCVService.getTemplates() that makes the API request to retrieve the list of available templates.async getTemplates(): Promise<any> { try { const response = await this.client.get('/api/v1/templates'); return response.data; } catch (error) { this._handleError(error); throw error; } }
- src/index.ts:90-110 (helper)Helper function safeStringify used in the tool handler to safely convert API responses to strings for MCP content.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返回了结果,但无法转换为字符串展示(可能包含循环引用)"; } };
- src/index.ts:204-204 (schema)Input schema for 'get_templates' tool: empty object indicating no parameters required.{},