openapi-docs-mcp 0.1.0 → 0.1.2

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 (2) hide show
  1. package/README.md +119 -15
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -17,41 +17,84 @@
17
17
  - Node.js 20 或更高版本
18
18
  - 开发时建议使用 pnpm 11 或更高版本
19
19
 
20
- ## 安装与构建
20
+ ## 快速开始
21
+
22
+ 包已经发布到 npm:[openapi-docs-mcp](https://www.npmjs.com/package/openapi-docs-mcp)。
23
+
24
+ ### 使用 npx(推荐)
25
+
26
+ 不需要安装,直接下载并运行指定版本:
21
27
 
22
28
  ```bash
23
- pnpm install
24
- pnpm build
29
+ npx -y openapi-docs-mcp@0.1.2 \
30
+ --source https://api.example.com/v3/api-docs \
31
+ --timeout 30000
32
+ ```
33
+
34
+ 建议在 MCP 配置中固定版本,例如 `openapi-docs-mcp@0.1.2`,避免新版本自动升级后改变行为。
35
+
36
+ 如果希望始终使用最新版本:
37
+
38
+ ```bash
39
+ npx -y openapi-docs-mcp@latest \
40
+ --source https://api.example.com/v3/api-docs
25
41
  ```
26
42
 
27
- 构建产物位于 `dist/`。
43
+ ### 使用 pnpm dlx
28
44
 
29
- ## 启动服务
45
+ ```bash
46
+ pnpm dlx openapi-docs-mcp@0.1.2 \
47
+ --source https://api.example.com/v3/api-docs \
48
+ --timeout 30000
49
+ ```
50
+
51
+ ### 全局安装
52
+
53
+ ```bash
54
+ npm install --global openapi-docs-mcp@0.1.2
55
+ ```
56
+
57
+ 安装后可以直接执行:
58
+
59
+ ```bash
60
+ openapi-docs-mcp \
61
+ --source https://api.example.com/v3/api-docs \
62
+ --timeout 30000
63
+ ```
64
+
65
+ 升级全局版本:
66
+
67
+ ```bash
68
+ npm install --global openapi-docs-mcp@latest
69
+ ```
70
+
71
+ ## 启动参数示例
30
72
 
31
73
  ### 加载本地文档
32
74
 
33
75
  支持 OpenAPI/Swagger JSON 和 YAML 文件:
34
76
 
35
77
  ```bash
36
- node dist/cli.js --source ./openapi.json
78
+ npx -y openapi-docs-mcp@0.1.2 --source ./openapi.json
37
79
  ```
38
80
 
39
81
  也可以直接使用位置参数:
40
82
 
41
83
  ```bash
42
- node dist/cli.js ./openapi.yaml
84
+ npx -y openapi-docs-mcp@0.1.2 ./openapi.yaml
43
85
  ```
44
86
 
45
87
  ### 加载远程文档
46
88
 
47
89
  ```bash
48
- node dist/cli.js --source https://api.example.com/v3/api-docs
90
+ npx -y openapi-docs-mcp@0.1.2 \
91
+ --source https://api.example.com/v3/api-docs
49
92
  ```
50
93
 
51
94
  默认远程加载超时时间为 10 秒,可以通过 `--timeout` 修改:
52
95
 
53
96
  ```bash
54
- node dist/cli.js \
97
+ npx -y openapi-docs-mcp@0.1.2 \
55
98
  --source https://api.example.com/v3/api-docs \
56
99
  --timeout 20000
57
100
  ```
@@ -61,7 +104,7 @@ node dist/cli.js \
61
104
  可以重复使用 `--header`,格式为 `NAME=VALUE`:
62
105
 
63
106
  ```bash
64
- node dist/cli.js \
107
+ npx -y openapi-docs-mcp@0.1.2 \
65
108
  --source https://api.example.com/v3/api-docs \
66
109
  --header Authorization="Bearer token" \
67
110
  --header X-Tenant-Id=tenant-1
@@ -84,14 +127,77 @@ node dist/cli.js \
84
127
 
85
128
  ## MCP Client 配置
86
129
 
87
- 构建完成后,可以在任意支持 stdio MCP Server 的 Client 中添加配置。
88
-
89
- 路径建议使用绝对路径:
130
+ 可以在任意支持 stdio MCP Server 的 Client 中通过 `npx` 启动,无需克隆或构建本项目:
90
131
 
91
132
  ```json
92
133
  {
93
134
  "mcpServers": {
94
135
  "project-api-docs": {
136
+ "command": "npx",
137
+ "args": [
138
+ "-y",
139
+ "openapi-docs-mcp@0.1.2",
140
+ "--source",
141
+ "https://api.example.com/v3/api-docs",
142
+ "--timeout",
143
+ "30000"
144
+ ]
145
+ }
146
+ }
147
+ }
148
+ ```
149
+
150
+ 同一个 npm 包可以使用不同 OpenAPI 文档启动多个实例,因此不同项目之间不会冲突。
151
+
152
+ ### 同时配置多个实例
153
+
154
+ 每个实例使用不同的 MCP Server 名称和 `--source`:
155
+
156
+ ```json
157
+ {
158
+ "mcpServers": {
159
+ "safety-api-docs": {
160
+ "command": "npx",
161
+ "args": [
162
+ "-y",
163
+ "openapi-docs-mcp@0.1.2",
164
+ "--source",
165
+ "https://safety.example.com/v3/api-docs",
166
+ "--timeout",
167
+ "30000"
168
+ ]
169
+ },
170
+ "mall-api-docs": {
171
+ "command": "npx",
172
+ "args": [
173
+ "-y",
174
+ "openapi-docs-mcp@0.1.2",
175
+ "--source",
176
+ "https://mall.example.com/v3/api-docs",
177
+ "--timeout",
178
+ "30000"
179
+ ]
180
+ }
181
+ }
182
+ }
183
+ ```
184
+
185
+ ### 使用本地源码构建
186
+
187
+ 参与开发时才需要克隆源码并构建:
188
+
189
+ ```bash
190
+ pnpm install
191
+ pnpm build
192
+ node dist/cli.js --source ./openapi.json
193
+ ```
194
+
195
+ 本地 MCP 配置需要使用 `dist/cli.js` 的绝对路径:
196
+
197
+ ```json
198
+ {
199
+ "mcpServers": {
200
+ "local-api-docs": {
95
201
  "command": "node",
96
202
  "args": [
97
203
  "C:/absolute/path/openapi-docs-mcp/dist/cli.js",
@@ -103,8 +209,6 @@ node dist/cli.js \
103
209
  }
104
210
  ```
105
211
 
106
- 同一个 npm 包可以使用不同 OpenAPI 文档启动多个实例,因此不同项目之间不会冲突。
107
-
108
212
  ## MCP 工具
109
213
 
110
214
  ### `search_api`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openapi-docs-mcp",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "A vendor-neutral MCP server for searching and understanding OpenAPI documents.",
5
5
  "type": "module",
6
6
  "bin": {