api2mcp 0.3.0 → 0.3.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.
package/README.md CHANGED
@@ -12,7 +12,23 @@
12
12
  ## 安装
13
13
 
14
14
  ```bash
15
- # 使用 pnpm
15
+ # 推荐使用 npx,无需安装
16
+ npx api2mcp --url https://petstore3.swagger.io/api/v3/openapi.json
17
+
18
+ # 或全局安装
19
+ npm install -g api2mcp
20
+ # 或
21
+ pnpm add -g api2mcp
22
+ ```
23
+
24
+ ## 从源码构建
25
+
26
+ ```bash
27
+ # 克隆仓库
28
+ git clone https://github.com/shenjingnan/api2mcp.git
29
+ cd api2mcp
30
+
31
+ # 安装依赖
16
32
  pnpm install
17
33
 
18
34
  # 构建
@@ -21,23 +37,40 @@ pnpm build
21
37
 
22
38
  ## 使用方法
23
39
 
24
- ### CLI
40
+ ### npx 快速使用(推荐)
41
+
42
+ 无需安装,直接使用 npx 运行:
25
43
 
26
44
  ```bash
27
45
  # 基本使用
28
- api2mcp --url https://petstore3.swagger.io/api/v3/openapi.json
46
+ npx api2mcp --url https://petstore3.swagger.io/api/v3/openapi.json
29
47
 
30
48
  # 指定基础 URL
31
- api2mcp --url ./openapi.json --base-url https://api.example.com
49
+ npx api2mcp --url ./openapi.json --base-url https://api.example.com
32
50
 
33
51
  # 带认证头
34
- api2mcp --url https://api.example.com/openapi.json --headers '{"Authorization":"Bearer xxx"}'
52
+ npx api2mcp --url https://api.example.com/openapi.json --headers '{"Authorization":"Bearer xxx"}'
35
53
 
36
54
  # 带工具前缀
37
- api2mcp --url https://api.example.com/openapi.json --prefix myapi
55
+ npx api2mcp --url https://api.example.com/openapi.json --prefix myapi
38
56
 
39
57
  # 调试模式
40
- api2mcp --url https://api.example.com/openapi.json --debug
58
+ npx api2mcp --url https://api.example.com/openapi.json --debug
59
+ ```
60
+
61
+ ### CLI
62
+
63
+ 如果需要全局安装:
64
+
65
+ ```bash
66
+ # 使用 pnpm 全局安装
67
+ pnpm add -g api2mcp
68
+
69
+ # 或使用 npm 全局安装
70
+ npm install -g api2mcp
71
+
72
+ # 然后直接运行
73
+ api2mcp --url https://petstore3.swagger.io/api/v3/openapi.json
41
74
  ```
42
75
 
43
76
  ### CLI 参数
@@ -84,7 +117,7 @@ api2mcp --url https://api.example.com/openapi.json --debug
84
117
 
85
118
  ### 在 Claude Desktop 中使用
86
119
 
87
- 在 Claude Desktop 配置文件中添加:
120
+ 在 Claude Desktop 配置文件中添加:
88
121
 
89
122
  **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
90
123
  **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
@@ -93,13 +126,15 @@ api2mcp --url https://api.example.com/openapi.json --debug
93
126
  {
94
127
  "mcpServers": {
95
128
  "api2mcp": {
96
- "command": "node",
97
- "args": ["/path/to/api2mcp/bin/api2mcp.js", "--url", "https://api.example.com/openapi.json"]
129
+ "command": "npx",
130
+ "args": ["-y", "api2mcp", "--url", "https://api.example.com/openapi.json"]
98
131
  }
99
132
  }
100
133
  }
101
134
  ```
102
135
 
136
+ > **注意**: 使用 `-y` 参数可以自动确认 npx 的安装提示,避免交互式确认。
137
+
103
138
  ## 配置优先级
104
139
 
105
140
  配置加载优先级 (从高到低):
package/dist/cli.js CHANGED
File without changes
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "api2mcp",
3
- "version": "0.3.0",
4
- "description": "Convert OpenAPI specifications to MCP tools dynamically",
3
+ "version": "0.3.2",
4
+ "description": " OpenAPI/Swagger 规范一键转换为 MCP 工具,让 AI 助手无缝调用您的 API",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "bin": {
8
- "api2mcp": "./bin/api2mcp.js"
8
+ "api2mcp": "./dist/cli.js"
9
9
  },
10
10
  "keywords": [
11
11
  "mcp",
@@ -43,6 +43,8 @@
43
43
  "@types/node": "^20.11.0",
44
44
  "@vitest/coverage-v8": "^4.1.1",
45
45
  "cspell": "^9.7.0",
46
+ "husky": "^9.1.7",
47
+ "lint-staged": "^16.4.0",
46
48
  "openapi-types": "^12.1.3",
47
49
  "release-it": "^19.0.0",
48
50
  "tsup": "^8.0.0",
@@ -51,11 +53,10 @@
51
53
  },
52
54
  "files": [
53
55
  "dist",
54
- "bin",
55
56
  "README.md"
56
57
  ],
57
58
  "scripts": {
58
- "build": "tsup && node scripts/add-shebang.js",
59
+ "build": "tsup",
59
60
  "dev": "tsup --watch",
60
61
  "start": "node dist/cli.js",
61
62
  "typecheck": "tsc --noEmit",
package/bin/api2mcp.js DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- require('../dist/cli.js');