generate_sfc_client
Generate Vue.js single-file components (SFC) for frontend development using predefined templates. Input template file path and workspace directory to create Vue SFC pages quickly and accurately.
Instructions
使用 sfc 模板生成 vue 列表组件 / Generate vue sfc component page.Examples: For file only returns vue sfc pages, default file name: 'template.js'
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| dir | Yes | workspace dir | |
| source | Yes | sfc 模板文件路径 / sfc template file path |
Implementation Reference
- src/index.ts:215-241 (handler)The main handler for the generate_sfc_client tool. It destructures source and dir from arguments, determines the file path, calls Template2ListOutput to generate SFC files in the .lists subdirectory of the workspace dir, and returns success or throws an error.case 'generate_sfc_client': { const { source, dir } = args try { // 判断 source 是否是文件路径 const isFilePath = source.startsWith('/') const filePath = isFilePath ? `/${source}` : source const dirPath = path.join(dir, '.lists') await Template2ListOutput({ source: filePath, dir: dirPath }) return { content: [ { type: 'text', text: 'SFC files generated successfully.', }, ], } } catch (error) { console.error('Error while generating SFC files:', error) throw new McpError(ErrorCode.InternalError, 'Failed to generate SFC files', { code: ErrorCode.InternalError, message: 'Failed to generate SFC files', }) } }
- src/index.ts:51-69 (schema)The schema definition for the generate_sfc_client tool, including name, description, and inputSchema specifying required 'source' and 'dir' properties.{ name: 'generate_sfc_client', description: "使用 sfc 模板生成 vue 列表组件 / Generate vue sfc component page.Examples: For file only returns vue sfc pages, default file name: 'template.js'", inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'sfc 模板文件路径 / sfc template file path', }, dir: { type: 'string', description: 'workspace dir', }, }, required: ['source', 'dir'], }, },
- src/index.ts:51-69 (registration)The tool is registered in the TOOLS array, which is returned by the listTools handler.{ name: 'generate_sfc_client', description: "使用 sfc 模板生成 vue 列表组件 / Generate vue sfc component page.Examples: For file only returns vue sfc pages, default file name: 'template.js'", inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'sfc 模板文件路径 / sfc template file path', }, dir: { type: 'string', description: 'workspace dir', }, }, required: ['source', 'dir'], }, },