Skip to main content

Vue 3 + Element Plus + Spring Boot 鍏ㄦ爤浠g爜鐢熸垚鍣?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 模型生成代码

快速开始

前提条件

  • 阿里云 DashScope API Key(获取地址
  • 安装方式二选一:
    • uvx(推荐):需安装 uv,无需手动安装包
    • pip:需 Python >= 3.10

安装 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

admin_gen_mcp-0.1.5.tar.gz (38.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

admin_gen_mcp-0.1.5-py3-none-any.whl (49.0 kB view details)

Uploaded Python 3

File details

Details for the file admin_gen_mcp-0.1.5.tar.gz.

File metadata

  • Download URL: admin_gen_mcp-0.1.5.tar.gz
  • Upload date:
  • Size: 38.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for admin_gen_mcp-0.1.5.tar.gz
Algorithm Hash digest
SHA256 68da801c39f4cd5d5357a84b27113befa9123bd29286fdd860ec7cfd6224d577
MD5 49b3a4f0ff50e737a9cb47ba4abccec7
BLAKE2b-256 3e8a0b93d6079378e35c499a96adc4a8fac2a1151dbe73ed4dc414778227b45a

See more details on using hashes here.

File details

Details for the file admin_gen_mcp-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: admin_gen_mcp-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 49.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.2

File hashes

Hashes for admin_gen_mcp-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 234a91ec1bac1640a701d57e288952ba78f7e1a168c310c23baba524711585e8
MD5 21a4aa1527ec13664a65160187b20bf1
BLAKE2b-256 c5c91f5e2cccd31ee3547541768b94c6393e99cee550afa4929926bb619ccd68

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page