generate_sfc_client
Generate Vue.js single-file components from SFC templates to create list components and pages for frontend development.
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 |
|---|---|---|---|
| source | Yes | sfc 模板文件路径 / sfc template file path | |
| dir | Yes | workspace dir |
Implementation Reference
- src/index.ts:215-241 (handler)The handler function for the 'generate_sfc_client' tool. It destructures source and dir from arguments, determines if source is a file path, constructs paths, calls Template2ListOutput to generate SFC files in the '.lists' subdirectory, and returns a success message or throws an MCP error on failure.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 (registration)Registration of the 'generate_sfc_client' tool in the TOOLS array, including its name, description, and input schema used for listing tools.{ 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:55-68 (schema)Input schema definition for the 'generate_sfc_client' tool, specifying properties for source (template file path) and dir (workspace directory).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:96-105 (registration)Registration of the 'generate_sfc_client' prompt in the PROMPTS array.name: 'generate_sfc_client', description: '使用 swiftcode sfc 模板生成 vue 列表组件', arguments: [ { name: 'sfc', description: '', required: false, }, ], },