Skip to main content
Glama

m8-generator-mcp

M8 框架智能辅助工具 - 基于 MCP (Model Context Protocol) 协议

专门为 M8 移动端开发框架设计的 AI 辅助工具集,集成了开发规范、代码生成、规范检查等核心能力。支持通过 Cursor、Windsurf 等 AI 编辑器无缝调用。

✨ 核心功能

  • 🚀 一站式页面生成 (create_page): 只需描述需求,自动完成规范加载、代码生成(Vue/SCSS/JS)、Mock 数据创建,并输出规范检查报告。

  • 🧩 IOC 组件生成 (create_ioc_page): 专为低码平台设计,自动生成符合 IOC 规范的组件结构(Config/Mock/Vue/Plugin)。

  • 🔍 规范自动验证 (validate_code_standards): 实时检查代码是否符合 M8 开发规范(文件头注释、全局变量使用、样式穿透语法等)。

  • 🤖 AI 配置助手 (get_prompt): 获取最佳 System Prompt,让你的 AI 助手瞬间变身 M8 专家。

Related MCP server: shadcn-vue-mcp

🛠️ 安装与配置

在 IDE (Cursor/VSCode/Windsurf) 的 MCP 配置文件中添加:

{
  "mcpServers": {
    "m8-codex-mcp": {
      "command": "npx",
      "args": ["-y", "m8-codex-mcp@latest"]
    }
  }
}

🧰 工具详解

1. create_page (创建页面)

一站式生成符合 M8 规范的业务页面。

参数说明:

  • module_name (必填): 模块名称(小写下划线,如 user_list)

  • vue_version (必填): Vue 版本,"2" 或 "3"

  • description (必填): 页面功能描述

  • page_name: 页面名称,默认为 index

  • page_type: 页面类型 (form | list | detail | custom),默认为 custom

  • requirements: 具体需求细节(如:包含搜索框、下拉刷新等)

  • components: 需要使用的组件列表(如 ['em-button', 'em-field'])

示例:

"使用 create_page 工具创建请假申请页面:

  • module_name: "leave_apply"

  • vue_version: "2"

  • page_type: "form"

  • description: "请假申请"

  • requirements: "请假类型(单选:事假/病假/年假)、开始日期(日期选择)、结束日期(日期选择)、请假原因(textarea)、提交按钮"

2. create_ioc_page (创建低码组件)

生成符合 M8 低码平台 (IOC) 规范的组件结构。

参数说明:

  • component_name (必填): 组件名 (PascalCase,如 ProductCard)

  • display_name (必填): 中文显示名

  • description (必填): 功能描述

  • config_options: 自定义属性配置列表

  • custom_events: 自定义事件列表

示例:

"使用 create_ioc_page 工具创建商品卡片组件:

  • component_name: "ProductCard"

  • display_name: "商品卡片"

  • description: "展示商品图片、名称、价格,支持点击跳转"

  • config_options: [{"name": "titleColor", "displayName": "标题颜色", "type": "color"}, {"name": "showPrice", "displayName": "显示价格", "type": "boolean", "defaultValue": true}]

  • custom_events: [{"name": "onBuyClick", "displayName": "点击购买"}]

💡 组件复用:开发时优先使用 M8 组件库(em-*)

"查询 em-field 组件用法"
"em-popup 有哪些 Props"

3. validate_code_standards (规范验证)

检查已有代码是否符合 M8 规范。

支持检查项:

  • ✅ 全局变量 (Util/Config) 禁止 import

  • ✅ Vue2/Vue3 样式穿透语法 (::v-deep vs :deep())

  • ✅ Vue3 <script setup> 语法强制

  • ✅ 文件头部注释完整性

  • ✅ 样式文件分离 (@import scss)

4. get_prompt (获取 AI 配置)

获取专为 M8 开发优化的 System Prompt。 建议将返回的内容复制到项目的 .cursorrules 或 .windsurfrules 文件中,以提升 AI 的编码准确率。

📚 包含的知识库

  • UI 组件库: 70+ 组件文档(直接问 AI "查询 em-xxx 用法" 即可)

  • 开发规范: 完整的 M8 前端开发规范 (01-project 到 07-router)

  • 最佳实践: Vue2/Vue3 差异化处理方案

Development

# Install dependencies
npm install

# Build the project
npm run build

# Watch for changes
npm run watch

License

MIT

Available Tools

4 tools
create_ioc_pageA

【低码组件生成】生成符合 M8 低码平台规范的组件代码。

🔴 重要:此工具会自动在项目根目录执行 npm run ioc create 命令创建组件!

⚠️ 【最重要】优先使用 em-组件库!:

  • 轮播/走马灯:必须使用 em-swipe + em-swipe-item,禁止自行实现轮播

  • 图片展示:必须使用 em-image(支持懒加载、失败占位)

  • 列表/单元格:使用 em-cell / em-cell-group

  • 按钮:使用 em-button

  • 弹窗:使用 em-popup / em-dialog

  • 标签:使用 em-tag

  • 下拉刷新:使用 em-minirefresh

  • 只有在组件库没有匹配组件时,才允许自定义实现!

📋 使用前必读 - 开发流程:

  1. 指定项目路径:必须提供 project_path 参数,指向包含 package.json 的项目根目录

  2. 自动创建组件:工具会在项目目录下执行 npm run ioc create ComponentName 创建组件目录结构

  3. 返回生成代码:返回完善后的代码内容,由 AI 助手覆盖写入对应文件

  4. ⚠️ 必须检查 base.js:确保 module_name 与组件文件夹名一致,name 为组件中文名

📁 生成的目录结构(自动创建):

  • js/base.js(🔴 必须检查:name 中文名、module_name 必须=目录名、version)

  • js/config.js(属性/事件配置 - 含详细可配置项)

  • mock/data.js(模拟数据 - 需与 index.vue 的数据结构匹配)

  • index.vue(组件主文件 - 🔴 必须使用 em- 组件库)

  • css/index.scss(样式)

  • plugin/eventgenerate/index.js(事件生成插件)

  • plugin/boxoptions/config.js(容器配置插件)

  • index.js(组件注册入口)

📌 支持的配置项类型:

  • text: 文本输入

  • boolean: 开关

  • color: 颜色选择器

  • number: 数字输入

  • image: 图片URL

  • uploadimage: 图片上传(推荐)

  • select: 下拉选择

  • array: 数组配置(配合 dynamic:true 和 template)

💡 配置设计建议:

  • 布局类:showTitle, showIcon, showBorder, layout, columns

  • 样式类:backgroundColor, titleColor, titleSize, borderRadius

  • 交互类:clickable, disabled, loading

  • 数据类:使用 array 类型支持动态列表

Inputs: project_path (required), component_name (required), display_name (required), description (required), +4 more.

create_pageB

【推荐使用】一站式 M8 页面生成工具。自动完成:1.加载完整规范 2.生成代码 3.验证规范。用户只需描述页面需求即可,无需手动调用其他工具。

Inputs: module_name (required), vue_version (required), description (required), page_name, +5 more.

get_promptA

获取配置给 AI (Cursor/Windsurf) 的最佳 System Prompt,包含核心规范和工具调用指令。建议将其复制到 .cursorrules 或 .windsurfrules 文件中。

Inputs: no named parameters.

validate_code_standardsB

验证给定的代码片段是否符合 M8 开发规范,返回不符合规范的问题列表和修改建议。

Inputs: code (required), file_type (required), vue_version.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 4 tools

    Disambiguation5/5

    Each tool has a distinct, non-overlapping purpose: create_ioc_page generates component code, create_page generates full pages, get_prompt provides system prompts, and validate_code_standards checks code compliance. The descriptions clearly differentiate their roles, with no ambiguity in selection.

    Naming Consistency5/5

    All tool names follow a consistent snake_case pattern with clear verb_noun structures: create_ioc_page, create_page, get_prompt, validate_code_standards. This uniformity makes the set predictable and easy to understand.

    Tool Count4/5

    With 4 tools, the count is reasonable for a code generation and validation server, covering key workflows. It might feel slightly thin for broader development tasks, but it's well-scoped for its M8 platform focus, with no redundant tools.

    Completeness4/5

    The tools cover core M8 development needs: component creation, page generation, prompt setup, and code validation. Minor gaps exist, such as lacking tools for updating or deleting components, but the set supports essential workflows without dead ends.

    Maintenance

    ActivityInactive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      B
      quality
      D
      maintenance
      Shadcn-vue MCP Server is a powerful AI-driven tool that helps developers instantly create beautiful, modern UI components through natural language descriptions. It integrates the shadcn-vue component library and tailwindcss, seamlessly connects with mainstream IDEs, and provides a streamlined UI dev
      5
      108
      Apache 2.0
    • A
      license
      B
      quality
      D
      maintenance
      Enables AI-driven frontend component design and code generation from natural language requirements. Supports Vue, React, and Angular with intelligent component decomposition, API design, and complete project generation.
      4
      3
      MIT
    • A
      license
      B
      quality
      B
      maintenance
      A comprehensive development toolkit with 23 tools covering code quality analysis, development efficiency, and project management. Enables AI-assisted code review, test generation, performance analysis, SQL generation, UI component creation, and automated project documentation.
      8
      29
      137 npm
      41
      MIT