@mastergo/magic-mcp 0.0.4-beta.1 → 0.0.4-beta.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +160 -0
- package/README.zh-CN.md +95 -2
- package/bin/cli.js +15 -2
- package/dist/index.js +424 -19
- package/package.json +1 -1
- package/readme.md +0 -67
package/README.md
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# MasterGo Magic MCP
|
|
2
|
+
|
|
3
|
+
MasterGo Magic MCP is a standalone MCP (Model Context Protocol) service designed to connect MasterGo design tools with AI models. It enables AI models to directly retrieve DSL data from MasterGo design files.
|
|
4
|
+
|
|
5
|
+
## Key Features
|
|
6
|
+
|
|
7
|
+
- Retrieves DSL data from MasterGo design files
|
|
8
|
+
- Runs directly with npx
|
|
9
|
+
- No external dependencies required, only Node.js environment needed
|
|
10
|
+
|
|
11
|
+
## Tutorial
|
|
12
|
+
|
|
13
|
+
- https://mastergo.com/file/155675508499265?page_id=158:0002
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
### Obtaining MG_MCP_TOKEN
|
|
18
|
+
|
|
19
|
+
1. Visit https://mastergo.com
|
|
20
|
+
2. Enter personal settings
|
|
21
|
+
3. Click the Security Settings tab
|
|
22
|
+
4. Find the personal access token
|
|
23
|
+
5. Click to generate the token
|
|
24
|
+
|
|
25
|
+
### Command Line Options
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
npx @mastergo/magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME] [--debug]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### Parameters:
|
|
32
|
+
|
|
33
|
+
- `--token=YOUR_TOKEN` (required): MasterGo API token for authentication
|
|
34
|
+
- `--url=API_URL` (optional): API base URL, defaults to http://localhost:3000
|
|
35
|
+
- `--rule=RULE_NAME` (optional): Add design rules to apply, can be used multiple times
|
|
36
|
+
- `--debug` (optional): Enable debug mode for detailed error information
|
|
37
|
+
|
|
38
|
+
You can also use space-separated format for parameters:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
npx @mastergo/magic-mcp --token YOUR_TOKEN --url API_URL --rule RULE_NAME --debug
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### LINGMA Usage
|
|
45
|
+
|
|
46
|
+
Search for LINGMA in the VSCode extension marketplace and install it.
|
|
47
|
+
|
|
48
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174245589.png" alt="image-20250507174245589" style="zoom:25%;" />
|
|
49
|
+
|
|
50
|
+
After logging in, click on [MCP tools] in the chat box.
|
|
51
|
+
|
|
52
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174511910.png" alt="image-20250507174511910" style="zoom:25%;" />
|
|
53
|
+
|
|
54
|
+
Click on [MCP Square] at the top to enter the MCP marketplace, find the MasterGo design collaboration tool and install it.
|
|
55
|
+
|
|
56
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174840456.png" alt="image-20250507174840456" style="zoom:25%;" />
|
|
57
|
+
|
|
58
|
+
After installation, go back to [MCP Servers], and edit our MCP service to replace it with your own MasterGo token.
|
|
59
|
+
|
|
60
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507175005364.png" alt="image-20250507175005364" style="zoom:25%;" />
|
|
61
|
+
|
|
62
|
+
Finally, switch the chat mode to agent mode in the chat interface.
|
|
63
|
+
|
|
64
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507175107044.png" alt="image-20250507175107044" style="zoom:25%;" />
|
|
65
|
+
|
|
66
|
+
### cursor Usage
|
|
67
|
+
|
|
68
|
+
Cursor Mcp usage guide reference: https://docs.cursor.com/context/model-context-protocol#using-mcp-tools-in-agent
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"mcpServers": {
|
|
73
|
+
"mastergo-magic-mcp": {
|
|
74
|
+
"command": "npx",
|
|
75
|
+
"args": [
|
|
76
|
+
"-y",
|
|
77
|
+
"@mastergo/magic-mcp",
|
|
78
|
+
"--token=<MG_MCP_TOKEN>",
|
|
79
|
+
"--url=https://mastergo.com"
|
|
80
|
+
],
|
|
81
|
+
"env": {}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### cline Usage
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"mcpServers": {
|
|
92
|
+
"@master/mastergo-magic-mcp": {
|
|
93
|
+
"command": "npx",
|
|
94
|
+
"args": [
|
|
95
|
+
"-y",
|
|
96
|
+
"@mastergo/magic-mcp",
|
|
97
|
+
"--token=<MG_MCP_TOKEN>",
|
|
98
|
+
"--url=https://mastergo.com"
|
|
99
|
+
],
|
|
100
|
+
"env": {}
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## Project Structure
|
|
107
|
+
|
|
108
|
+
### src Directory
|
|
109
|
+
|
|
110
|
+
The `src` directory contains the core implementation of the MasterGo Magic MCP service:
|
|
111
|
+
|
|
112
|
+
- `index.ts`: Entry point of the application that initializes the MCP server and registers all tools
|
|
113
|
+
- `http-util.ts`: Utility for handling HTTP requests to the MasterGo API
|
|
114
|
+
- `types.d.ts`: TypeScript type definitions for the project
|
|
115
|
+
|
|
116
|
+
#### src/tools
|
|
117
|
+
|
|
118
|
+
Contains implementations of MCP tools:
|
|
119
|
+
|
|
120
|
+
- `base-tool.ts`: Base class for all MCP tools
|
|
121
|
+
- `get-dsl.ts`: Tool for retrieving DSL (Domain Specific Language) data from MasterGo design files
|
|
122
|
+
- `get-component-link.ts`: Tool for retrieving component documentation from links
|
|
123
|
+
- `get-meta.ts`: Tool for retrieving metadata information
|
|
124
|
+
- `get-component-workflow.ts`: Tool providing structured component development workflow for Vue and React components, generating workflow files and component specifications
|
|
125
|
+
|
|
126
|
+
#### src/markdown
|
|
127
|
+
|
|
128
|
+
Contains markdown files with additional documentation:
|
|
129
|
+
|
|
130
|
+
- `meta.md`: Documentation about metadata structure and usage
|
|
131
|
+
- `component-workflow.md`: Component development workflow documentation guiding structured component development process
|
|
132
|
+
|
|
133
|
+
## Local Development
|
|
134
|
+
|
|
135
|
+
1. Run `yarn` and `yarn build` to install dependencies and build the code
|
|
136
|
+
2. Find the absolute path of `bin/cli.js`
|
|
137
|
+
3. Add local MCP configuration with your token
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
"mastergo-mcp-local": {
|
|
141
|
+
"command": "node",
|
|
142
|
+
"args": [
|
|
143
|
+
"absolute/path/to/bin/cli.js",
|
|
144
|
+
"--token=mg_xxxxxx",
|
|
145
|
+
"--url=https://mastergo.com",
|
|
146
|
+
"--debug"
|
|
147
|
+
],
|
|
148
|
+
"env": {}
|
|
149
|
+
},
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
4. Restart your editor to ensure the local MCP is enabled
|
|
153
|
+
|
|
154
|
+
After successful execution, you can debug based on the local running results. You can build your own MCP service based on your modifications.
|
|
155
|
+
|
|
156
|
+
We welcome your code contributions and look forward to building MasterGo's MCP service together.
|
|
157
|
+
|
|
158
|
+
## License
|
|
159
|
+
|
|
160
|
+
ISC
|
package/README.zh-CN.md
CHANGED
|
@@ -8,7 +8,7 @@ MasterGo Magic MCP 是一个独立的 MCP(Model Context Protocol)服务,
|
|
|
8
8
|
- 可直接通过 npx 运行
|
|
9
9
|
- 仅需 Node.js 环境,无需其他外部依赖
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
## 教程
|
|
12
12
|
|
|
13
13
|
- https://mastergo.com/file/155675508499265?page_id=158:0002
|
|
14
14
|
|
|
@@ -22,6 +22,47 @@ MasterGo Magic MCP 是一个独立的 MCP(Model Context Protocol)服务,
|
|
|
22
22
|
4. 找到个人访问令牌
|
|
23
23
|
5. 点击生成令牌
|
|
24
24
|
|
|
25
|
+
### 命令行选项
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
npx @mastergo/magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME] [--debug]
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
#### 参数:
|
|
32
|
+
|
|
33
|
+
- `--token=YOUR_TOKEN` (必需): MasterGo API 认证令牌
|
|
34
|
+
- `--url=API_URL` (可选): API 基础 URL,默认为 http://localhost:3000
|
|
35
|
+
- `--rule=RULE_NAME` (可选): 添加要应用的设计规则,可多次使用
|
|
36
|
+
- `--debug` (可选): 启用调试模式,提供详细错误信息
|
|
37
|
+
|
|
38
|
+
你也可以使用空格分隔的参数格式:
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
npx @mastergo/magic-mcp --token YOUR_TOKEN --url API_URL --rule RULE_NAME --debug
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### LINGMA 使用方法
|
|
45
|
+
|
|
46
|
+
在 vscode 拓展市场中搜索 LINGMA -> 然后安装该拓展
|
|
47
|
+
|
|
48
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174245589.png" alt="image-20250507174245589" style="zoom:25%;" />
|
|
49
|
+
|
|
50
|
+
登录后 -> 在聊天框中点击 [MCP tools]
|
|
51
|
+
|
|
52
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174511910.png" alt="image-20250507174511910" style="zoom:25%;" />
|
|
53
|
+
|
|
54
|
+
点击顶部 [MCP Sqaure] 进入mcp市场,在市场中找到 Mastergo设计协作工具并安装
|
|
55
|
+
|
|
56
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174840456.png" alt="image-20250507174840456" style="zoom:25%;" />
|
|
57
|
+
|
|
58
|
+
安装完成后,需要回到 [MCP Servers], 并编辑我们的mcp服务,将自己的mastergo token 替换上去
|
|
59
|
+
|
|
60
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507175005364.png" alt="image-20250507175005364" style="zoom:25%;" />
|
|
61
|
+
|
|
62
|
+
最后在聊天界面中将聊天模式切换为agent模式。
|
|
63
|
+
|
|
64
|
+
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507175107044.png" alt="image-20250507175107044" style="zoom:25%;" />
|
|
65
|
+
|
|
25
66
|
### Cursor 使用方法
|
|
26
67
|
|
|
27
68
|
Cursor Mcp 使用指南参考:https://docs.cursor.com/context/model-context-protocol#using-mcp-tools-in-agent
|
|
@@ -62,6 +103,58 @@ Cursor Mcp 使用指南参考:https://docs.cursor.com/context/model-context-pr
|
|
|
62
103
|
}
|
|
63
104
|
```
|
|
64
105
|
|
|
106
|
+
## 项目结构
|
|
107
|
+
|
|
108
|
+
### src 目录
|
|
109
|
+
|
|
110
|
+
`src` 目录包含 MasterGo Magic MCP 服务的核心实现:
|
|
111
|
+
|
|
112
|
+
- `index.ts`:应用程序入口点,初始化 MCP 服务器并注册所有工具
|
|
113
|
+
- `http-util.ts`:处理与 MasterGo API 通信的 HTTP 请求工具
|
|
114
|
+
- `types.d.ts`:项目的 TypeScript 类型定义
|
|
115
|
+
|
|
116
|
+
#### src/tools
|
|
117
|
+
|
|
118
|
+
包含 MCP 工具的实现:
|
|
119
|
+
|
|
120
|
+
- `base-tool.ts`:所有 MCP 工具的基类
|
|
121
|
+
- `get-dsl.ts`:从 MasterGo 设计文件中获取 DSL(领域特定语言)数据的工具
|
|
122
|
+
- `get-component-link.ts`:从链接中获取组件文档的工具
|
|
123
|
+
- `get-meta.ts`:获取元数据信息的工具
|
|
124
|
+
- `get-component-workflow.ts`:提供结构化的组件开发工作流工具,支持 Vue 和 React 组件开发,生成所需的工作流文件和组件规范
|
|
125
|
+
|
|
126
|
+
#### src/markdown
|
|
127
|
+
|
|
128
|
+
包含附加文档的 markdown 文件:
|
|
129
|
+
|
|
130
|
+
- `meta.md`:关于元数据结构和用法的文档
|
|
131
|
+
- `component-workflow.md`:组件开发工作流程文档,指导结构化组件开发过程
|
|
132
|
+
|
|
133
|
+
## 本地开发
|
|
134
|
+
|
|
135
|
+
1. 运行 `yarn` 和 `yarn build`,安装依赖并构建代码
|
|
136
|
+
2. 查看 `bin/cli.js` 的绝对路径
|
|
137
|
+
3. 在 MCP 配置中添加本地 MCP 配置,其中 token 为您获取的 token
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
"mastergo-mcp-local": {
|
|
141
|
+
"command": "node",
|
|
142
|
+
"args": [
|
|
143
|
+
"bin/cli.js绝对路径地址",
|
|
144
|
+
"--token=mg_xxxxxx",
|
|
145
|
+
"--url=https://mastergo.com",
|
|
146
|
+
"--debug"
|
|
147
|
+
],
|
|
148
|
+
"env": {}
|
|
149
|
+
},
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
4. 重启编辑器,确认本地 MCP 已开启
|
|
153
|
+
|
|
154
|
+
运行成功后,就可以基于本地运行的结果进行调试。您可以基于自己的修改构建自己的 MCP 服务。
|
|
155
|
+
|
|
156
|
+
欢迎您为我们提供代码贡献,并期待大家一起共建 MasterGo 的 MCP 服务。
|
|
157
|
+
|
|
65
158
|
## 许可证
|
|
66
159
|
|
|
67
|
-
ISC
|
|
160
|
+
ISC
|
package/bin/cli.js
CHANGED
|
@@ -9,6 +9,8 @@ const args = process.argv.slice(2);
|
|
|
9
9
|
let token = "";
|
|
10
10
|
let baseUrl = "http://localhost:3000";
|
|
11
11
|
let debug = false;
|
|
12
|
+
// Array to collect rules
|
|
13
|
+
let rules = [];
|
|
12
14
|
|
|
13
15
|
// Parse arguments
|
|
14
16
|
for (let i = 0; i < args.length; i++) {
|
|
@@ -24,6 +26,12 @@ for (let i = 0; i < args.length; i++) {
|
|
|
24
26
|
baseUrl = args[i].split("=")[1];
|
|
25
27
|
} else if (args[i] === "--debug") {
|
|
26
28
|
debug = true;
|
|
29
|
+
// Add support for --rule parameter
|
|
30
|
+
} else if (args[i] === "--rule" && i + 1 < args.length) {
|
|
31
|
+
rules.push(args[i + 1]);
|
|
32
|
+
i++;
|
|
33
|
+
} else if (args[i].startsWith("--rule=")) {
|
|
34
|
+
rules.push(args[i].split("=")[1]);
|
|
27
35
|
}
|
|
28
36
|
}
|
|
29
37
|
|
|
@@ -31,7 +39,7 @@ for (let i = 0; i < args.length; i++) {
|
|
|
31
39
|
if (!token) {
|
|
32
40
|
console.error("Error: Missing MasterGo API Token");
|
|
33
41
|
console.error(
|
|
34
|
-
"Usage: npx mastergo-magic-mcp --token=YOUR_TOKEN [--url=API_URL]"
|
|
42
|
+
"Usage: npx mastergo-magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME]"
|
|
35
43
|
);
|
|
36
44
|
console.error("Use --help or -h for more information");
|
|
37
45
|
process.exit(1);
|
|
@@ -43,6 +51,8 @@ const env = {
|
|
|
43
51
|
MASTERGO_API_TOKEN: token,
|
|
44
52
|
API_BASE_URL: baseUrl,
|
|
45
53
|
DEBUG: debug ? "true" : "false",
|
|
54
|
+
// Add RULES environment variable as stringified array
|
|
55
|
+
RULES: JSON.stringify(rules),
|
|
46
56
|
};
|
|
47
57
|
|
|
48
58
|
// Get package path
|
|
@@ -51,7 +61,9 @@ const indexPath = path.join(packageDir, "index.js");
|
|
|
51
61
|
|
|
52
62
|
// Check if file exists
|
|
53
63
|
if (!fs.existsSync(indexPath)) {
|
|
54
|
-
console.error(
|
|
64
|
+
console.error(
|
|
65
|
+
"Error: Executable file not found. Please ensure the package is correctly installed."
|
|
66
|
+
);
|
|
55
67
|
process.exit(1);
|
|
56
68
|
}
|
|
57
69
|
|
|
@@ -60,6 +72,7 @@ if (debug) {
|
|
|
60
72
|
console.log(`Package path: ${indexPath}`);
|
|
61
73
|
console.log(`Token: ${token ? "set" : "not set"}`);
|
|
62
74
|
console.log(`API URL: ${baseUrl}`);
|
|
75
|
+
console.log(`Rules: ${rules.length > 0 ? rules.join(", ") : "none"}`);
|
|
63
76
|
console.log(`Debug mode: ${debug ? "enabled" : "disabled"}`);
|
|
64
77
|
}
|
|
65
78
|
|