MasterGo Magic MCP 是一个独立的 MCP(模型上下文协议)服务,旨在连接 MasterGo 设计工具与 AI 模型。它使 AI 模型能够直接从 MasterGo 设计文件中检索 DSL 数据。
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_TOKEN 或 MASTERGO_API_TOKEN:MasterGo API 令牌API_BASE_URL:API 基础 URLRULES:规则的 JSON 数组(例如,'["rule1", "rule2"]')要通过 Smithery 自动安装 MasterGo Magic for Claude Desktop:
npx -y @smithery/cli install @mastergo-design/mastergo-magic-mcp --client claude
在 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 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"
}
}
}
}
选项 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 目录包含 MasterGo Magic MCP 服务的核心实现:
index.ts:应用程序的入口点,初始化 MCP 服务器并注册所有工具http-util.ts:处理对 MasterGo API 的 HTTP 请求的实用程序types.d.ts:项目的 TypeScript 类型定义包含 MCP 工具的实现:
base-tool.ts:所有 MCP 工具的基础类get-dsl.ts:从 MasterGo 设计文件中检索 DSL(领域特定语言)数据的工具get-component-link.ts:从链接中检索组件文档的工具get-meta.ts:检索元数据信息的工具get-component-workflow.ts:提供 Vue 和 React 组件的结构化组件开发工作流,生成工作流文件和组件规范包含附加文档的 Markdown 文件:
meta.md:关于元数据结构和使用的文档component-workflow.md:组件开发工作流文档,指导结构化的组件开发过程yarn 和 yarn build 来安装依赖项并构建代码dist/index.js 的绝对路径"mastergo-mcp-local": {
"command": "node",
"args": [
"absolute/path/to/dist/index.js",
"--token=mg_xxxxxx",
"--url=https://mastergo.com",
"--debug"
],
"env": {}
},
成功执行后,您可以根据本地运行结果进行调试。您可以基于您的修改构建自己的 MCP 服务。
我们欢迎您的代码贡献,并期待共同构建 MasterGo 的 MCP 服务。
ISC