@mastergo/magic-mcp 0.0.4-beta.1 → 0.0.4-beta.3

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.zh-CN.md CHANGED
@@ -22,6 +22,25 @@ 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
+
25
44
  ### Cursor 使用方法
26
45
 
27
46
  Cursor Mcp 使用指南参考:https://docs.cursor.com/context/model-context-protocol#using-mcp-tools-in-agent
@@ -64,4 +83,4 @@ Cursor Mcp 使用指南参考:https://docs.cursor.com/context/model-context-pr
64
83
 
65
84
  ## 许可证
66
85
 
67
- ISC
86
+ 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("Error: Executable file not found. Please ensure the package is correctly installed.");
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
 
package/dist/index.js CHANGED
@@ -30,7 +30,7 @@
30
30
  console.log(componentLink);
31
31
  }
32
32
  \`\`\`
33
- `]}}catch(n){throw n}}async request(e){try{return(await this.httpClient(e)).data}catch(a){throw a}}};var Zt=class{register(e){e.tool(this.name,this.description,this.schema.shape,this.execute.bind(this))}};var ox="mcp__getDsl",cx=`
33
+ `,...JSON.parse(process.env.RULES??"[]")]}}catch(n){throw n}}async request(e){try{return(await this.httpClient(e)).data}catch(a){throw a}}};var Zt=class{register(e){e.tool(this.name,this.description,this.schema.shape,this.execute.bind(this))}};var ox="mcp__getDsl",cx=`
34
34
  "Use this tool to retrieve the DSL (Domain Specific Language) data from MasterGo design files and the rules you must follow when generating code.
35
35
  This tool is useful when you need to analyze the structure of a design, understand component hierarchy, or extract design properties.
36
36
  You must provide a fileId and layerId to identify the specific design element.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mastergo/magic-mcp",
3
- "version": "0.0.4-beta.1",
3
+ "version": "0.0.4-beta.3",
4
4
  "description": "MasterGo MCP standalone service",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
package/readme.md CHANGED
@@ -22,6 +22,25 @@ MasterGo Magic MCP is a standalone MCP (Model Context Protocol) service designed
22
22
  4. Find the personal access token
23
23
  5. Click to generate the token
24
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
+
25
44
  ### cursor Usage
26
45
 
27
46
  Cursor Mcp usage guide reference: https://docs.cursor.com/context/model-context-protocol#using-mcp-tools-in-agent