基于模板的代码生成器 MCP 服务,支持自定义规则解析。支持 Handlebars 和 Velocity 模板引擎,内置枚举、字典和忽略规则。
This MCP server provides 6 code generation tools with mostly complete schemas and descriptions. Tool names follow verb_noun convention (list_, get_, generate_, parse_). Descriptions are detailed but verbose (300-600+ chars, exceeding the 10-1024 optimal range and 194 char baseline). All tools have JSON Schema input definitions with typed properties. However, there are structural weaknesses: (1) descriptions contain example JSON output that LLMs may reuse literally rather than adapt; (2) parameter descriptions lack constraint details (ranges, patterns, valid formats); (3) output schemas are documented in prose but not in formal schema definitions; (4) some descriptions are in Chinese, limiting LLM readability; (5) error handling guidance is minimal. Tool annotations are present and correct (readOnlyHint, destructiveHint, idempotentHint). The server demonstrates competent schema design but misses LLM-optimization best practices.
根据模板和数据生成代码,保存到指定文件。 参数: - group: 分组名称(必填) - template: 模板名称(必填) - data: 模板数据(必填,JSON 对象) - outputPath: 输出文件路径(必填) 处理流程: 1. 根据 group 和 template 找到模板文件 2. 根据文件扩展名选择对应的模板引擎 3. 调用规则解析器解析 data 中的自定义规则 4. 使用解析后的数据渲染模板 5. 将生成的代码写入 outputPath 指定的文件 数据中的规则示例: { "className": "User", "fields": [ { "name": "gender", "comment": "性别 @enum(GENDER:male:男,female:女)" } ] } 返回: { "success": true/false, "outputPath": "输出路径", "message": "结果消息" }
根据简化的参数批量生成完整模块代码(PO、DTO、Form、Query、Mapper、Service、Controller、Converter、枚举等)。 参数: - group: 模板分组名称(必填),如 "atom" - basePackage: 基础包名(必填),如 "io.github.atom.ai.sales.module.project" - moduleName: 模块名(必填),小写,用于生成目录,如 "project" - className: 类名(必填),大驼峰,如 "AiProject" - tableName: 数据库表名(必填),如 "ai_project" - comment: 模块注释/描述(可选) - outputDir: 输出基础目录(必填),如 "/path/to/project/src/main/java" - resourcesDir: 资源目录(可选),用于XML等,如 "/path/to/project/src/main/resources" - fields: 字段列表(必填),简化结构: - name: 字段名(数据库列名或Java字段名) - type: 字段类型(可选,自动推断) - comment: 字段注释(可选,支持规则标记) - isPrimary: 是否主键(可选) - author: 作者(可选) - date: 日期(可选) - version: 版本号(可选) - email: 邮箱后缀(可选) - templates: 要生成的模板列表(可选,不传则生成全部) 字段注释支持的特殊标记: - Q@: 标记为查询字段 - 自定义枚举:类型:名称:值列表;: 定义枚举 - @dict(编码): 字典引用 - @ignore: 忽略字段 示例输入: { "group": "atom", "basePackage": "io.github.atom.ai.sales.module.project", "moduleName": "project", "className": "AiProject", "tableName": "ai_project", "comment": "AI项目", "outputDir": "/path/to/project/src/main/java", "fields": [ { "name": "id", "type": "bigint", "isPrimary": true }, { "name": "project_name", "type": "varchar", "comment": "Q@项目名称" }, { "name": "project_type", "type": "tinyint", "comment": "Q@自定义枚举:Integer:项目类型:1(1, \"硬件销售\"),2(2, \"综合项目\");" } ], "author": "haijun" } 返回: { "success": true/false, "results": [ { "template": "entity", "outputPath": "...", "success": true, "message": "生成成功" } ], "message": "生成完成: 成功 X 个,失败 Y 个" }
获取模板分组的配置信息。 参数: - group: 分组名称(必填) - template: 模板名称(可选,不传则返回整个分组配置) 返回配置信息,包含: - name: 分组名称 - description: 分组描述 - version: 版本号 - templates: 模板列表(包含详细定义) - rules: 规则列表(内置 + 自定义)
Descriptions contain example JSON output that LLMs may reuse literally. E.g., code_generator_list_groups shows '{ "groups": [...], "name": "atom", "templateCount": 2 }', LLMs frequently treat example values as template constraints and echo them verbatim in real calls.
Parameter descriptions lack constraint details. E.g., 'group' is described as 'template group name' with minLength=1, but the description does not state the allowed range, pattern, or valid group names. LLMs cannot infer constraints from JSON Schema alone.
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-22 | D | 53 | 2025-06-18+ | v2 |
| 2026-03-09 | F | 41 | - | v1 |
列出所有可用的模板分组。 返回分组列表,每个分组包含: - name: 分组名称 - templateCount: 该分组下的模板数量 示例输出: { "groups": [ { "name": "atom", "templateCount": 2 }, { "name": "java", "templateCount": 1 } ] }
列出指定分组下的所有模板。 参数: - group: 分组名称(必填) 返回模板列表,每个模板包含: - name: 模板名称 - file: 模板文件名 - type: 模板类型 (handlebars/velocity) - description: 模板描述 - inputParams: 输入参数定义 示例: { "group": "atom", "templates": [ { "name": "entity", "file": "entity.hbs", "type": "handlebars", "description": "生成实体类" } ] }
解析数据中的自定义规则(可单独调用预览解析结果)。 参数: - group: 分组名称(必填,用于加载该分组的规则定义) - data: 要解析的数据(必填) 支持的规则: - @enum(名称:值1:描述1,值2:描述2): 解析枚举定义 - @dict(字典编码): 解析字典引用 - @ignore: 标记字段忽略 示例输入: { "group": "atom", "data": { "comment": "性别 @enum(GENDER:male:男,female:女)" } } 示例输出: { "original": { "comment": "性别 @enum(GENDER:male:男,female:女)" }, "parsed": { "comment": "性别", "_rules": { "enum": { "name": "GENDER", "values": [...] } } }, "rules": { "enum": { "name": "GENDER", "values": [...] } } }
Descriptions are verbose (300-600+ chars) and exceed the optimal 10-1024 range with 194 char baseline. Long descriptions waste tokens and bury key decision points. E.g., code_generator_generate_module is 1800+ chars.
Descriptions are primarily in Chinese, limiting accessibility and LLM comprehension for non-Chinese-trained models. Best practice is English for MCP server tooling.
Output schemas are documented in prose (e.g., 'returns { success, outputPath, message }') but not provided as formal JSON Schema definitions. LLMs cannot parse prose output schemas to plan downstream calls or validate structure.
Error handling lacks recovery guidance. Code_generator_generate_code and code_generator_generate_module can fail, but error responses do not suggest next steps (e.g., 'Group not found. Call code_generator_list_groups() to see available groups').
code_generator_generate_module has complex nested field schema ('fields' array with 'atomEnum' and 'dict' objects). Documentation does not explain when/how these nested structures are used or what valid combinations exist. Undocumented parameter relationships cause agent misuse.