apifox-mcp-server 0.0.1

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.
Files changed (3) hide show
  1. package/README.md +94 -0
  2. package/index.js +10673 -0
  3. package/package.json +25 -0
package/README.md ADDED
@@ -0,0 +1,94 @@
1
+ ## 环境要求
2
+
3
+ - NodeJS >= 18
4
+
5
+ ## 1. 准备 Apifox MCP 服务
6
+
7
+ ### 1.1 克隆 Apifox MCP 项目
8
+
9
+ ```shell
10
+ git clone https://github.com/Tzott/apifox-mcp-demo.git
11
+ ```
12
+
13
+ ### 1.2 创建环境变量
14
+
15
+ ```shell
16
+ cd apifox-mcp-demo
17
+ cp .env.example .env
18
+ ```
19
+
20
+ ### 1.3 在 Apifox 客户端中创建一个Access Token ,并写入到 .env 文件中
21
+
22
+ ![图片](./md/1.png)
23
+
24
+ ![图片](./md/9.png)
25
+
26
+ ### 1.4 启动 Apifox MCP 服务
27
+
28
+ ```shell
29
+ # 如果没有安装 pnpm,可先运行:npm i -g pnpm
30
+
31
+ pnpm i && pnpm build && pnpm start
32
+ ```
33
+
34
+ ### 1.5 看到启动成功日志
35
+
36
+ ```shell
37
+ > apifox-mcp-demo@0.0.1 start /Users/code/apifox-mcp-demo
38
+ > node lib/index.js
39
+
40
+ SSE endpoint: http://localhost:4444/sse
41
+ Message endpoint: http://localhost:4444/messages
42
+ HTTP server listening on port 4444
43
+ ```
44
+
45
+ ## 2. 准备 Cursor
46
+
47
+ ### 2.1 创建一个空白的 Nestjs 项目
48
+
49
+ ```shell
50
+ npm i -g @nestjs/cli
51
+ nest new nest-ai-demo
52
+ cd nest-ai-demo
53
+ ```
54
+
55
+ ### 2.2 添加一个 Cursor MCP 配置
56
+
57
+ 从 `apifox-mcp-demo` 项目中复制 `sse 的地址`,填到 `Server URL` 中。
58
+
59
+ ![图片](./md/2.png)
60
+
61
+ 可以看到MCP 服务连接成功
62
+
63
+ ![图片](./md/3.png)
64
+
65
+ ### 2.3 打开 Cursor Composer,并切换到 Agent 模式
66
+
67
+ ![图片](./md/4.png)
68
+
69
+ ### 2.4 复制一个 Apifox 接口的协作链接
70
+
71
+ ![图片](./md/5.png)
72
+
73
+ ### 2.5 粘贴到 Composer 中,并让其实现接口
74
+
75
+ ```plaintext
76
+ https://app.apifox.com/link/project/5898808/apis/api-263537040
77
+
78
+ 通过这个 Apifox 协作链接,获取其 OpenAPI 的定义,然后根据定义实现这个接口。
79
+
80
+ 注意:技术是:nestjs + typescript,项目我已经搭建了好了,直接实现即可。
81
+ ```
82
+
83
+ ### 2.6 Cursor Composer 实现完毕,并 Accepted 结果
84
+
85
+ ![图片](./md/6.png)
86
+
87
+ ### 2.7 启动 Nestjs服务,通过 Apifox 调用AI 写的接口,断言通过
88
+
89
+ ![图片](./md/7.png)
90
+
91
+ ## 3. 其他
92
+
93
+ 分页也简单实现了
94
+ ![图片](./md/8.png)