Skip to content

Commit c82fad1

Browse files
authored
Merge pull request #15 from mastergo-design/feature_meta
update readme & add version
2 parents 4f0d826 + d32befe commit c82fad1

File tree

5 files changed

+127
-1
lines changed

5 files changed

+127
-1
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,54 @@ Cursor Mcp usage guide reference: https://docs.cursor.com/context/model-context-
8181
}
8282
```
8383

84+
## Project Structure
85+
86+
### src Directory
87+
88+
The `src` directory contains the core implementation of the MasterGo Magic MCP service:
89+
90+
- `index.ts`: Entry point of the application that initializes the MCP server and registers all tools
91+
- `http-util.ts`: Utility for handling HTTP requests to the MasterGo API
92+
- `types.d.ts`: TypeScript type definitions for the project
93+
94+
#### src/tools
95+
96+
Contains implementations of MCP tools:
97+
98+
- `base-tool.ts`: Base class for all MCP tools
99+
- `get-dsl.ts`: Tool for retrieving DSL (Domain Specific Language) data from MasterGo design files
100+
- `get-component-link.ts`: Tool for retrieving component documentation from links
101+
- `get-meta.ts`: Tool for retrieving metadata information
102+
103+
#### src/markdown
104+
105+
Contains markdown files with additional documentation:
106+
107+
- `meta.md`: Documentation about metadata structure and usage
108+
109+
## Local Development
110+
111+
1. Run `yarn` and `yarn build` to install dependencies and build the code
112+
2. Find the absolute path of `bin/cli.js`
113+
3. Add local MCP configuration with your token
114+
```json
115+
"mastergo-mcp-local": {
116+
"command": "node",
117+
"args": [
118+
"absolute/path/to/bin/cli.js",
119+
"--token=mg_xxxxxx",
120+
"--url=https://mastergo.com",
121+
"--debug"
122+
],
123+
"env": {}
124+
},
125+
```
126+
4. Restart your editor to ensure the local MCP is enabled
127+
128+
After successful execution, you can debug based on the local running results. You can build your own MCP service based on your modifications.
129+
130+
We welcome your code contributions and look forward to building MasterGo's MCP service together.
131+
84132
## License
85133

86134
ISC

README.zh-CN.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,54 @@ Cursor Mcp 使用指南参考:https://docs.cursor.com/context/model-context-pr
8181
}
8282
```
8383

84+
## 项目结构
85+
86+
### src 目录
87+
88+
`src` 目录包含 MasterGo Magic MCP 服务的核心实现:
89+
90+
- `index.ts`:应用程序入口点,初始化 MCP 服务器并注册所有工具
91+
- `http-util.ts`:处理与 MasterGo API 通信的 HTTP 请求工具
92+
- `types.d.ts`:项目的 TypeScript 类型定义
93+
94+
#### src/tools
95+
96+
包含 MCP 工具的实现:
97+
98+
- `base-tool.ts`:所有 MCP 工具的基类
99+
- `get-dsl.ts`:从 MasterGo 设计文件中获取 DSL(领域特定语言)数据的工具
100+
- `get-component-link.ts`:从链接中获取组件文档的工具
101+
- `get-meta.ts`:获取元数据信息的工具
102+
103+
#### src/markdown
104+
105+
包含附加文档的 markdown 文件:
106+
107+
- `meta.md`:关于元数据结构和用法的文档
108+
109+
## 本地运行
110+
111+
1. 运行`yarn``yarn build`。安装依赖并构建代码
112+
2. 查看`bin/cli.js`的绝对路径
113+
3. 在MCP配置中添加本地MCP配置,其中token为您换区的token
114+
```json
115+
"mastergo-mcp-local": {
116+
"command": "node",
117+
"args": [
118+
"bin/cli.js绝对路径地址",
119+
"--token=mg_xxxxxx",
120+
"--url=https://mastergo.com",
121+
"--debug"
122+
],
123+
"env": {}
124+
},
125+
```
126+
4. 重启编辑器,确认本地mcp已开启
127+
128+
运行成功后,就可以基于本地运行的结果进行调试。您可以基于自己的修改构建自己的MCP服务。
129+
130+
欢迎您为我们提供代码贡献,并期待大家一起共建MasterGo的MCP服务。
131+
84132
## 许可证
85133

86134
ISC

src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { HttpUtil } from "./http-util";
66
import { GetDslTool } from "./tools/get-dsl";
77
import { GetComponentLinkTool } from "./tools/get-component-link";
88
import { GetMetaTool } from "./tools/get-meta";
9+
import { GetVersionTool } from "./tools/get-version";
910

1011
// Logging function, only outputs when the DEBUG environment variable is true
1112
const log = (message: string) => {
@@ -39,6 +40,7 @@ function main() {
3940
const httpUtil = new HttpUtil(baseUrl, token);
4041

4142
// Register tools
43+
new GetVersionTool().register(server);
4244
new GetDslTool(httpUtil).register(server);
4345
new GetComponentLinkTool(httpUtil).register(server);
4446
new GetMetaTool(httpUtil).register(server);

src/markdown/meta.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ The data might be:
6464
}
6565
```
6666

67-
f you find that the node data of page 0:1 contains the `interactive` field with id 0:3, write the 0:3 page and add the navigation information:
67+
if you find that the node data of page 0:1 contains the `interactive` field with id 0:3, write the 0:3 page and add the navigation information:
6868
```markdown
6969

7070
## Page List:

src/tools/get-version.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { z } from "zod";
2+
import { BaseTool } from "./base-tool";
3+
import packageJson from "../../package.json";
4+
5+
const VERSION_TOOL_NAME = `version_${packageJson.version}`;
6+
const VERSION_TOOL_DESCRIPTION = `the current version is ${packageJson.version}`;
7+
8+
export class GetVersionTool extends BaseTool {
9+
name = VERSION_TOOL_NAME;
10+
description = VERSION_TOOL_DESCRIPTION;
11+
12+
constructor() {
13+
super();
14+
}
15+
16+
schema = z.object({});
17+
18+
async execute({}: z.infer<typeof this.schema>) {
19+
return {
20+
content: [
21+
{
22+
type: "text" as const,
23+
text: JSON.stringify(packageJson.version),
24+
},
25+
],
26+
};
27+
}
28+
}

0 commit comments

Comments
 (0)