Skip to content

Commit fa68b5c

Browse files
Seann0824sean0824
andauthored
refactor: remove bin directory and CLI script, update build process t… (#46)
* refactor: remove bin directory and CLI script, update build process to use dist/index.js directly - Deleted the `bin/cli.js` file and removed references to the `bin` directory. - Updated `package.json` to point the `bin` entry to `dist/index.js`. - Modified build script to reflect changes in file structure and ensure executable permissions are set correctly. - Adjusted command examples in the build output to use the new entry point. * feat: add --no-rule option to command line arguments and update related functionality - Introduced a new command line argument `--no-rule` to allow users to disable rules. - Updated the `parserArgs` function to parse the new `noRule` argument. - Modified debug output to include the status of the `noRule` option. - Adjusted the `createHttpUtil` function to return an empty rules array when `noRule` is enabled. * docs: update README and README.zh-CN to include new command line options and environment variable configurations - Added `--no-rule` option to command line usage in both English and Chinese documentation. - Included instructions for using environment variables as an alternative to command line arguments. - Enhanced sections on command line options and local development for clarity and completeness. --------- Co-authored-by: sean0824 <[email protected]>
1 parent 82a968a commit fa68b5c

File tree

13 files changed

+401
-373
lines changed

13 files changed

+401
-373
lines changed

README.md

Lines changed: 67 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,57 @@
11
# MasterGo Magic MCP
2+
23
[![Ask DeepWiki](https://deepwiki.com/badge.svg)](https://deepwiki.com/mastergo-design/mastergo-magic-mcp)
34

45
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.
56

67
## Key Features
8+
79
- Retrieves DSL data from MasterGo design files
810
- Runs directly with npx
911
- No external dependencies required, only Node.js environment needed
1012

1113
## Tutorial
14+
1215
- https://mastergo.com/file/155675508499265?page_id=158:0002
1316

1417
## Usage
1518

1619
### Obtaining MG_MCP_TOKEN
20+
1721
1. Visit https://mastergo.com
1822
2. Enter personal settings
1923
3. Click the Security Settings tab
2024
4. Find the personal access token
2125
5. Click to generate the token
2226

2327
### Command Line Options
28+
2429
```
25-
npx @mastergo/magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME] [--debug]
30+
npx @mastergo/magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME] [--debug] [--no-rule]
2631
```
2732

2833
#### Parameters:
34+
2935
- `--token=YOUR_TOKEN` (required): MasterGo API token for authentication
3036
- `--url=API_URL` (optional): API base URL, defaults to http://localhost:3000
3137
- `--rule=RULE_NAME` (optional): Add design rules to apply, can be used multiple times
3238
- `--debug` (optional): Enable debug mode for detailed error information
39+
- `--no-rule` (optional): Disable default rules
3340

3441
You can also use space-separated format for parameters:
42+
3543
```
3644
npx @mastergo/magic-mcp --token YOUR_TOKEN --url API_URL --rule RULE_NAME --debug
3745
```
3846

47+
#### Environment Variables
48+
49+
Alternatively, you can use environment variables instead of command line arguments:
50+
51+
- `MG_MCP_TOKEN` or `MASTERGO_API_TOKEN`: MasterGo API token
52+
- `API_BASE_URL`: API base URL
53+
- `RULES`: JSON array of rules (e.g., `'["rule1", "rule2"]'`)
54+
3955
### Installing via Smithery
4056

4157
To install MasterGo Magic for Claude Desktop automatically via [Smithery](https://smithery.ai/server/@mastergo-design/mastergo-magic-mcp):
@@ -45,6 +61,7 @@ npx -y @smithery/cli install @mastergo-design/mastergo-magic-mcp --client claude
4561
```
4662

4763
### LINGMA Usage
64+
4865
Search for LINGMA in the VSCode extension marketplace and install it.
4966

5067
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507174245589.png" alt="image-20250507174245589" style="zoom:25%;" />
@@ -66,8 +83,13 @@ Finally, switch the chat mode to agent mode in the chat interface.
6683
<img src="https://github.com/mastergo-design/mastergo-magic-mcp/blob/main/images/image-20250507175107044.png" alt="image-20250507175107044" style="zoom:25%;" />
6784

6885
### cursor Usage
86+
6987
Cursor Mcp usage guide reference: https://docs.cursor.com/context/model-context-protocol#using-mcp-tools-in-agent
7088

89+
You can configure the MCP server using either command line arguments or environment variables:
90+
91+
**Option 1: Using command line arguments**
92+
7193
```json
7294
{
7395
"mcpServers": {
@@ -85,7 +107,27 @@ Cursor Mcp usage guide reference: https://docs.cursor.com/context/model-context-
85107
}
86108
```
87109

110+
**Option 2: Using environment variables**
111+
112+
```json
113+
{
114+
"mcpServers": {
115+
"mastergo-magic-mcp": {
116+
"command": "npx",
117+
"args": ["-y", "@mastergo/magic-mcp"],
118+
"env": {
119+
"MG_MCP_TOKEN": "<YOUR_TOKEN>",
120+
"API_BASE_URL": "https://mastergo.com"
121+
}
122+
}
123+
}
124+
}
125+
```
126+
88127
### cline Usage
128+
129+
**Option 1: Using command line arguments**
130+
89131
```json
90132
{
91133
"mcpServers": {
@@ -103,15 +145,35 @@ Cursor Mcp usage guide reference: https://docs.cursor.com/context/model-context-
103145
}
104146
```
105147

148+
**Option 2: Using environment variables**
149+
150+
```json
151+
{
152+
"mcpServers": {
153+
"@master/mastergo-magic-mcp": {
154+
"command": "npx",
155+
"args": ["-y", "@mastergo/magic-mcp"],
156+
"env": {
157+
"MG_MCP_TOKEN": "<YOUR_TOKEN>",
158+
"API_BASE_URL": "https://mastergo.com"
159+
}
160+
}
161+
}
162+
}
163+
```
164+
106165
## Project Structure
166+
107167
### src Directory
168+
108169
The `src` directory contains the core implementation of the MasterGo Magic MCP service:
109170

110171
- `index.ts`: Entry point of the application that initializes the MCP server and registers all tools
111172
- `http-util.ts`: Utility for handling HTTP requests to the MasterGo API
112173
- `types.d.ts`: TypeScript type definitions for the project
113174

114175
#### src/tools
176+
115177
Contains implementations of MCP tools:
116178

117179
- `base-tool.ts`: Base class for all MCP tools
@@ -121,12 +183,14 @@ Contains implementations of MCP tools:
121183
- `get-component-workflow.ts`: Tool providing structured component development workflow for Vue and React components, generating workflow files and component specifications
122184

123185
#### src/markdown
186+
124187
Contains markdown files with additional documentation:
125188

126189
- `meta.md`: Documentation about metadata structure and usage
127190
- `component-workflow.md`: Component development workflow documentation guiding structured component development process
128191

129192
## Local Development
193+
130194
1. Run `yarn` and `yarn build` to install dependencies and build the code
131195
2. Find the absolute path of `bin/cli.js`
132196
3. Add local MCP configuration with your token
@@ -143,11 +207,13 @@ Contains markdown files with additional documentation:
143207
"env": {}
144208
},
145209
```
210+
146211
4. Restart your editor to ensure the local MCP is enabled
147212

148213
After successful execution, you can debug based on the local running results. You can build your own MCP service based on your modifications.
149214

150215
We welcome your code contributions and look forward to building MasterGo's MCP service together.
151216

152217
## License
218+
153219
ISC

README.zh-CN.md

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ MasterGo Magic MCP 是一个独立的 MCP(Model Context Protocol)服务,
2727
### 命令行选项
2828

2929
```
30-
npx @mastergo/magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME] [--debug]
30+
npx @mastergo/magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME] [--debug] [--no-rule]
3131
```
3232

3333
#### 参数:
@@ -36,13 +36,22 @@ npx @mastergo/magic-mcp --token=YOUR_TOKEN [--url=API_URL] [--rule=RULE_NAME] [-
3636
- `--url=API_URL` (可选): API 基础 URL,默认为 http://localhost:3000
3737
- `--rule=RULE_NAME` (可选): 添加要应用的设计规则,可多次使用
3838
- `--debug` (可选): 启用调试模式,提供详细错误信息
39+
- `--no-rule` (可选): 禁用默认规则
3940

4041
你也可以使用空格分隔的参数格式:
4142

4243
```
4344
npx @mastergo/magic-mcp --token YOUR_TOKEN --url API_URL --rule RULE_NAME --debug
4445
```
4546

47+
#### 环境变量
48+
49+
您也可以使用环境变量代替命令行参数:
50+
51+
- `MG_MCP_TOKEN``MASTERGO_API_TOKEN`: MasterGo API 令牌
52+
- `API_BASE_URL`: API 基础 URL
53+
- `RULES`: 规则的 JSON 数组 (例如: `'["rule1", "rule2"]'`)
54+
4655
### LINGMA 使用方法
4756

4857
在 vscode 拓展市场中搜索 LINGMA -> 然后安装该拓展
@@ -69,6 +78,10 @@ npx @mastergo/magic-mcp --token YOUR_TOKEN --url API_URL --rule RULE_NAME --debu
6978

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

81+
您可以使用命令行参数或环境变量来配置 MCP 服务:
82+
83+
**方式一:使用命令行参数**
84+
7285
```json
7386
{
7487
"mcpServers": {
@@ -86,8 +99,27 @@ Cursor Mcp 使用指南参考:https://docs.cursor.com/context/model-context-pr
8699
}
87100
```
88101

102+
**方式二:使用环境变量**
103+
104+
```json
105+
{
106+
"mcpServers": {
107+
"mastergo-magic-mcp": {
108+
"command": "npx",
109+
"args": ["-y", "@mastergo/magic-mcp"],
110+
"env": {
111+
"MG_MCP_TOKEN": "<YOUR_TOKEN>",
112+
"API_BASE_URL": "https://mastergo.com"
113+
}
114+
}
115+
}
116+
}
117+
```
118+
89119
### cline 使用方法
90120

121+
**方式一:使用命令行参数**
122+
91123
```json
92124
{
93125
"mcpServers": {
@@ -105,6 +137,23 @@ Cursor Mcp 使用指南参考:https://docs.cursor.com/context/model-context-pr
105137
}
106138
```
107139

140+
**方式二:使用环境变量**
141+
142+
```json
143+
{
144+
"mcpServers": {
145+
"@master/mastergo-magic-mcp": {
146+
"command": "npx",
147+
"args": ["-y", "@mastergo/magic-mcp"],
148+
"env": {
149+
"MG_MCP_TOKEN": "<YOUR_TOKEN>",
150+
"API_BASE_URL": "https://mastergo.com"
151+
}
152+
}
153+
}
154+
}
155+
```
156+
108157
## 项目结构
109158

110159
### src 目录

bin/cli.js

Lines changed: 0 additions & 108 deletions
This file was deleted.

0 commit comments

Comments
 (0)