Vue 3 + Element Plus + Spring Boot 全栈代码生成器 MCP Server
Project description
Admin Gen MCP
Vue 3 + Element Plus 前端 & Spring Boot + MyBatis-Plus 后端 全栈代码生成器,基于 MCP 协议。
功能
- 前端生成:api.ts, options.ts, index.vue, form.vue
- 后端生成:Entity, Controller, Service, ServiceImpl, Mapper, Mapper.xml
- 全栈生成:一份 JSON 配置同时生成前端 + 后端(自动类型映射)
- 支持主表 + 多子表
- 支持字典配置
- 代码直接保存到磁盘,返回文件路径列表
- 调用阿里云 qwen3-max 模型生成代码
快速开始
前提条件
安装 uv(如果选择 uvx 方式)
# Windows (PowerShell)
powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex"
# macOS / Linux
curl -LsSf https://astral.sh/uv/install.sh | sh
# 或通过 pip
pip install uv
安装包(如果选择 pip 方式)
pip install admin-gen-mcp
IDE 配置
所有 IDE 的 MCP 配置中都需要设置 DASHSCOPE_API_KEY 环境变量。将 your-api-key 替换为你的阿里云 DashScope API Key。
Trae IDE
Trae 主界面 → AI 面板 → 右上角设置 → MCP → 添加 → 手动配置:
uvx 方式(推荐):
{
"mcpServers": {
"admin-gen": {
"command": "uvx",
"args": ["admin-gen-mcp"],
"env": {
"DASHSCOPE_API_KEY": "your-api-key"
}
}
}
}
pip 方式:
{
"mcpServers": {
"admin-gen": {
"command": "cmd",
"args": ["/c", "admin-gen-mcp"],
"env": {
"DASHSCOPE_API_KEY": "your-api-key"
}
}
}
}
配置保存后选择智能体 Builder with MCP。
详细使用文档见 TRAE_GUIDE.md
Claude Code
# uvx 方式(推荐)
claude mcp add admin-gen -- uvx admin-gen-mcp
# 然后设置环境变量 DASHSCOPE_API_KEY
# pip 方式
claude mcp add-json admin-gen '{"type":"stdio","command":"admin-gen-mcp","env":{"DASHSCOPE_API_KEY":"your-api-key"}}'
Cursor
设置 → MCP → 添加,粘贴与 Trae 相同的 JSON 配置。
VS Code (Copilot)
在项目根目录创建 .vscode/mcp.json,内容与上方 JSON 配置相同。
Windsurf
设置 → MCP → 添加配置,内容与上方 JSON 配置相同。
命令行工具
# 从 JSON 配置文件生成前端代码
admin-gen --config fields/example.json
# 交互模式
admin-gen -i
Python API
from admin_gen_mcp.generator import CodeGenerator
gen = CodeGenerator(api_key="your-api-key")
config = gen.load_config("fields/example.json")
# 全栈生成
results = gen.generate_fullstack(config)
print(results["frontend"]) # 前端 4 个文件
print(results["backend"]) # 后端 6~9 个文件
MCP 工具列表
| 工具 | 说明 |
|---|---|
generate_admin_page |
前端代码生成(直接传字段参数) |
generate_from_config |
前端代码生成(JSON 配置文件路径) |
generate_backend_code |
后端代码生成(直接传字段参数) |
generate_fullstack |
前后端一体生成(JSON 配置文件路径) |
配置文件格式
{
"功能名称": "员工培训申请",
"模块路径": "hr/trainApplication",
"权限前缀": "hr_trainapplication",
"输出目录": "src/views",
"主表字段": [
{
"label": "培训主题",
"key": "trainTitle",
"type": "input",
"required": true,
"show": true,
"alwaysHide": false,
"smart": true,
"width": "200"
}
],
"子表配置": [
{
"名称": "参训人员明细",
"标识": "detail",
"实体名称": "TrainApplicationDetail",
"字段列表": [...]
}
],
"字典配置": [
{ "key": "trainType", "dict": "hr_train_type", "import": "/@/enums/dict" }
]
}
字段类型映射
| 前端 type | 前端组件 | Java 类型 |
|---|---|---|
| input | el-input | String |
| textarea | el-input[textarea] | String |
| select | el-select | String |
| date | el-date-picker | LocalDate |
| datetime | el-date-picker | LocalDateTime |
| number | microme-operator | BigDecimal |
| upload | upload-file | String |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file admin_gen_mcp-0.1.3.tar.gz.
File metadata
- Download URL: admin_gen_mcp-0.1.3.tar.gz
- Upload date:
- Size: 36.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1eb5a652ccd671af26687f24f43883cca9046a2f718b59cf7caedb779357fe3f
|
|
| MD5 |
8037f71a6a9557c0f90413e4977f5ada
|
|
| BLAKE2b-256 |
f23ab3576d76b02bc4c3859b787b323eed9e00348c457b2020c3cdfcbc7d097d
|
File details
Details for the file admin_gen_mcp-0.1.3-py3-none-any.whl.
File metadata
- Download URL: admin_gen_mcp-0.1.3-py3-none-any.whl
- Upload date:
- Size: 46.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d9ea47ae697d14b0f8675f97d07fba059c8b44b1aa2470fe5fac17b51024fb1
|
|
| MD5 |
2f3008b13a5f053608e0677da337069f
|
|
| BLAKE2b-256 |
8681eb4c551a7a20ad76fe7e9f4d3405fd9d18c8ef4577755bc7feb48829c2ac
|