返回市场
主控魔力mcp

主控魔力mcp

作者:mastergo-design185 星标更新:2025-10-21

项目介绍

MasterGo Magic MCP

Ask DeepWiki

MasterGo Magic MCP 是一个独立的 MCP(模型上下文协议)服务,旨在连接 MasterGo 设计工具与 AI 模型。它使 AI 模型能够直接从 MasterGo 设计文件中检索 DSL 数据。

主要特性

  • 从 MasterGo 设计文件中检索 DSL 数据
  • 直接通过 npx 运行
  • 不需要外部依赖,仅需 Node.js 环境

教程

使用方法

获取 MG_MCP_TOKEN

  1. 访问 https://mastergo.com
  2. 进入个人设置
  3. 点击安全设置标签
  4. 查找个人访问令牌
  5. 点击生成令牌

命令行选项

npx @mastergo/magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME] [--debug] [--no-rule]

参数:

  • --token=YOUR_TOKEN(必需):用于身份验证的 MasterGo API 令牌
  • --url=API_URL(可选):API 基础 URL,默认为 http://localhost:3000
  • --rule=RULE_NAME(可选):添加设计规则以应用,可以多次使用
  • --debug(可选):启用调试模式以获取详细的错误信息
  • --no-rule(可选):禁用默认规则

您也可以使用空格分隔的参数格式:

npx @mastergo/magic-mcp --token YOUR_TOKEN --url API_URL --rule RULE_NAME --debug

环境变量

或者,您可以使用环境变量而不是命令行参数:

  • MG_MCP_TOKENMASTERGO_API_TOKEN:MasterGo API 令牌
  • API_BASE_URL:API 基础 URL
  • RULES:规则的 JSON 数组(例如,'["rule1", "rule2"]'

通过 Smithery 安装

要通过 Smithery 自动安装 MasterGo Magic for Claude Desktop:

npx -y @smithery/cli install @mastergo-design/mastergo-magic-mcp --client claude

LINGMA 使用

在 VSCode 扩展市场中搜索 LINGMA 并安装它。

<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174245589.png" alt="image-20250507174245589" style="zoom:25%;" />

登录后,在聊天框中点击 [MCP 工具]。

<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174511910.png" alt="image-20250507174511910" style="zoom:25%;" />

点击顶部的 [MCP 广场] 进入 MCP 市场,找到 MasterGo 设计协作工具并安装它。

<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174840456.png" alt="image-20250507174840456" style="zoom:25%;" />

安装完成后,返回到 [MCP 服务器],编辑我们的 MCP 服务,替换为您自己的 MasterGo 令牌。

<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507175005364.png" alt="image-20250507175005364" style="zoom:25%;" />

最后,在聊天界面中切换聊天模式为代理模式。

<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507175107044.png" alt="image-20250507175107044" style="zoom:25%;" />

cursor 使用

cursor Mcp 使用指南参考:https://docs.cursor.com/context/model-context-protocol#using-mcp-tools-in-agent

您可以使用命令行参数或环境变量来配置 MCP 服务器:

选项 1:使用命令行参数

{
  "mcpServers": {
    "mastergo-magic-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@mastergo/magic-mcp",
        "--token=<MG_MCP_TOKEN>",
        "--url=https://mastergo.com"
      ],
      "env": {}
    }
  }
}

选项 2:使用环境变量

{
  "mcpServers": {
    "mastergo-magic-mcp": {
      "command": "npx",
      "args": ["-y", "@mastergo/magic-mcp"],
      "env": {
        "MG_MCP_TOKEN": "<YOUR_TOKEN>",
        "API_BASE_URL": "https://mastergo.com"
      }
    }
  }
}

cline 使用

选项 1:使用命令行参数

{
  "mcpServers": {
    "@master/mastergo-magic-mcp": {
      "command": "npx",
      "args": [
        "-y",
        "@mastergo/magic-mcp",
        "--token=<MG_MCP_TOKEN>",
        "--url=https://mastergo.com"
      ],
      "env": {}
    }
  }
}

选项 2:使用环境变量

{
  "mcpServers": {
    "@master/mastergo-magic-mcp": {
      "command": "npx",
      "args": ["-y", "@mastergo/magic-mcp"],
      "env": {
        "MG_MCP_TOKEN": "<YOUR_TOKEN>",
        "API_BASE_URL": "https://mastergo.com"
      }
    }
  }
}

项目结构

src 目录

src 目录包含 MasterGo Magic MCP 服务的核心实现:

  • index.ts:应用程序的入口点,初始化 MCP 服务器并注册所有工具
  • http-util.ts:处理对 MasterGo API 的 HTTP 请求的实用程序
  • types.d.ts:项目的 TypeScript 类型定义

src/tools

包含 MCP 工具的实现:

  • base-tool.ts:所有 MCP 工具的基础类
  • get-dsl.ts:从 MasterGo 设计文件中检索 DSL(领域特定语言)数据的工具
  • get-component-link.ts:从链接中检索组件文档的工具
  • get-meta.ts:检索元数据信息的工具
  • get-component-workflow.ts:提供 Vue 和 React 组件的结构化组件开发工作流,生成工作流文件和组件规范

src/markdown

包含附加文档的 Markdown 文件:

  • meta.md:关于元数据结构和使用的文档
  • component-workflow.md:组件开发工作流文档,指导结构化的组件开发过程

本地开发

  1. 运行 yarnyarn build 来安装依赖项并构建代码
  2. 查找 dist/index.js 的绝对路径
  3. 添加带有您令牌的本地 MCP 配置
"mastergo-mcp-local": {
  "command": "node",
  "args": [
    "absolute/path/to/dist/index.js",
    "--token=mg_xxxxxx",
    "--url=https://mastergo.com",
    "--debug"
  ],
  "env": {}
},
  1. 重启您的编辑器以确保本地 MCP 已启用

成功执行后,您可以根据本地运行结果进行调试。您可以基于您的修改构建自己的 MCP 服务。

我们欢迎您的代码贡献,并期待共同构建 MasterGo 的 MCP 服务。

许可证

ISC