@mastergo/magic-mcp 0.0.6 → 0.1.0

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/package.json CHANGED
@@ -1,14 +1,13 @@
1
1
  {
2
2
  "name": "@mastergo/magic-mcp",
3
- "version": "0.0.6",
3
+ "version": "0.1.0",
4
4
  "description": "MasterGo MCP standalone service",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
- "mastergo-magic-mcp": "bin/cli.js"
7
+ "mastergo-magic-mcp": "dist/index.js"
8
8
  },
9
9
  "files": [
10
10
  "dist/**/*",
11
- "bin/**/*",
12
11
  "!**/*.map",
13
12
  "!**/.DS_Store",
14
13
  "!**/.idea",
@@ -19,7 +18,7 @@
19
18
  },
20
19
  "scripts": {
21
20
  "build": "node build.js",
22
- "start": "node bin/cli.js --token=test --url=http://localhost:3000 --debug",
21
+ "start": "node dist/index.js --token=test --url=http://localhost:3000 --debug",
23
22
  "prepublishOnly": "npm run build"
24
23
  },
25
24
  "keywords": [
package/bin/cli.js DELETED
@@ -1,108 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- const { spawn } = require("child_process");
4
- const path = require("path");
5
- const fs = require("fs");
6
-
7
- // Get arguments
8
- const args = process.argv.slice(2);
9
- let token = "";
10
- let baseUrl = "http://localhost:3000";
11
- let debug = false;
12
- // Array to collect rules
13
- let rules = [];
14
-
15
- // Parse arguments
16
- for (let i = 0; i < args.length; i++) {
17
- if (args[i] === "--token" && i + 1 < args.length) {
18
- token = args[i + 1];
19
- i++;
20
- } else if (args[i] === "--url" && i + 1 < args.length) {
21
- baseUrl = args[i + 1];
22
- i++;
23
- } else if (args[i].startsWith("--token=")) {
24
- token = args[i].split("=")[1];
25
- } else if (args[i].startsWith("--url=")) {
26
- baseUrl = args[i].split("=")[1];
27
- } else if (args[i] === "--debug") {
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]);
35
- }
36
- }
37
-
38
- // Check required arguments
39
- if (!token && !process.env.MASTERGO_API_TOKEN) {
40
- console.error("Error: Missing MasterGo API Token");
41
- console.error(
42
- "Usage: npx mastergo-magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME]"
43
- );
44
- console.error("Use --help or -h for more information");
45
- process.exit(1);
46
- }
47
-
48
- // Set environment variables
49
- const env = {
50
- MASTERGO_API_TOKEN: token,
51
- ...process.env,
52
- API_BASE_URL: baseUrl,
53
- DEBUG: debug ? "true" : "false",
54
- // Add RULES environment variable as stringified array
55
- RULES: JSON.stringify(rules),
56
- };
57
-
58
- // Get package path
59
- const packageDir = path.resolve(__dirname, "../dist");
60
- const indexPath = path.join(packageDir, "index.js");
61
-
62
- // Check if file exists
63
- if (!fs.existsSync(indexPath)) {
64
- console.error(
65
- "Error: Executable file not found. Please ensure the package is correctly installed."
66
- );
67
- process.exit(1);
68
- }
69
-
70
- if (debug) {
71
- console.log("Debug information:");
72
- console.log(`Package path: ${indexPath}`);
73
- console.log(`Token: ${token ? "set" : "not set"}`);
74
- console.log(`API URL: ${baseUrl}`);
75
- console.log(`Rules: ${rules.length > 0 ? rules.join(", ") : "none"}`);
76
- console.log(`Debug mode: ${debug ? "enabled" : "disabled"}`);
77
- }
78
-
79
- try {
80
- // Directly run the compiled file
81
- if (debug) {
82
- console.log("Using node to run the compiled code...");
83
- }
84
-
85
- // Directly use node to run the file, passing environment variables
86
- const child = spawn("node", [indexPath], {
87
- env: env,
88
- stdio: "inherit",
89
- });
90
-
91
- child.on("error", (error) => {
92
- console.error("Startup error:", error);
93
- if (debug) {
94
- console.error("Detailed error information:", error.stack);
95
- }
96
- process.exit(1);
97
- });
98
-
99
- child.on("exit", (code) => {
100
- process.exit(code || 0);
101
- });
102
- } catch (error) {
103
- console.error("Runtime error:", error);
104
- if (debug) {
105
- console.error("Detailed error information:", error.stack);
106
- }
107
- process.exit(1);
108
- }