@leeguoo/yapi-mcp 0.3.21 → 0.3.23
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 +25 -14
- package/dist/config.d.ts +2 -0
- package/dist/config.js +22 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/server.d.ts +1 -0
- package/dist/server.js +5 -1
- package/dist/server.js.map +1 -1
- package/dist/services/yapi/api.d.ts +14 -0
- package/dist/services/yapi/api.js +154 -57
- package/dist/services/yapi/api.js.map +1 -1
- package/dist/services/yapi/authCache.d.ts +1 -0
- package/dist/services/yapi/authCache.js +7 -0
- package/dist/services/yapi/authCache.js.map +1 -1
- package/dist/yapi-cli.js +251 -20
- package/dist/yapi-cli.js.map +1 -1
- package/package.json +3 -2
- package/skill-template/SKILL.md +58 -80
package/skill-template/SKILL.md
CHANGED
|
@@ -5,108 +5,86 @@ description: Query and sync YApi interface documentation. Use when user mentions
|
|
|
5
5
|
|
|
6
6
|
# YApi interface docs
|
|
7
7
|
|
|
8
|
-
##
|
|
8
|
+
## Command policy
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
Prefer `yapi` command. If missing, fallback to one-shot npx without forcing global install:
|
|
11
11
|
|
|
12
|
-
1. Read config to get base_url:
|
|
13
12
|
```bash
|
|
14
|
-
|
|
13
|
+
yapi -h
|
|
14
|
+
# fallback:
|
|
15
|
+
npx -y @leeguoo/yapi-mcp -h
|
|
15
16
|
```
|
|
16
17
|
|
|
17
|
-
|
|
18
|
-
- Extract `project_id` from URL path (e.g., `/project/123/...` → project_id=123)
|
|
19
|
-
- Extract `api_id` from URL path (e.g., `.../api/456` → api_id=456)
|
|
20
|
-
- Use `yapi --path /api/interface/get --query id=<api_id>` to fetch details
|
|
21
|
-
|
|
22
|
-
3. Example URL patterns:
|
|
23
|
-
- `https://yapi.example.com/project/123/interface/api/456` → project=123, api=456
|
|
24
|
-
- `https://yapi.example.com/project/123/interface/api/cat_789` → project=123, category=789
|
|
18
|
+
In command examples below, `yapi` can be replaced by `npx -y @leeguoo/yapi-mcp`.
|
|
25
19
|
|
|
26
|
-
##
|
|
20
|
+
## Quick workflow
|
|
21
|
+
1. If user gives a YApi URL, verify it belongs to configured `base_url`.
|
|
22
|
+
2. Confirm auth (`yapi whoami`), then run `yapi login --browser` when needed (open base URL, finish login in browser, then press Enter to sync cookie).
|
|
23
|
+
3. Resolve target by `api_id` / keyword / category.
|
|
24
|
+
4. Fetch raw JSON first, then summarize: method, path, headers, params, body, response schema/examples.
|
|
25
|
+
5. For docs sync tasks, do `--dry-run` first, then real sync.
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
```bash
|
|
30
|
-
yapi --version
|
|
31
|
-
```
|
|
27
|
+
## URL detection
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
1. Read configured `base_url` from `~/.yapi/config.toml`.
|
|
34
30
|
```bash
|
|
35
|
-
|
|
36
|
-
# or
|
|
37
|
-
pnpm add -g @leeguoo/yapi-mcp
|
|
31
|
+
rg -n "^base_url\\s*=" ~/.yapi/config.toml
|
|
38
32
|
```
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
2. If URL origin matches `base_url`, extract IDs from path:
|
|
34
|
+
- `/project/123/...` -> `project_id=123`
|
|
35
|
+
- `.../api/456` -> `api_id=456`
|
|
36
|
+
- `.../api/cat_789` -> `catid=789`
|
|
37
|
+
3. Prefer direct lookup when `api_id` exists:
|
|
41
38
|
```bash
|
|
42
|
-
yapi
|
|
39
|
+
yapi --path /api/interface/get --query id=<api_id>
|
|
43
40
|
```
|
|
44
41
|
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
yapi login
|
|
48
|
-
```
|
|
49
|
-
This will prompt for:
|
|
50
|
-
- YApi base URL (e.g., https://yapi.example.com)
|
|
51
|
-
- Email
|
|
52
|
-
- Password
|
|
53
|
-
|
|
54
|
-
Config is saved to `~/.yapi/config.toml`.
|
|
55
|
-
|
|
56
|
-
## Workflow
|
|
57
|
-
1. If user provides a YApi URL, check if it matches configured `base_url` in `~/.yapi/config.toml`.
|
|
58
|
-
2. Ensure yapi CLI is installed (prompt user to install globally if missing).
|
|
59
|
-
3. Check login status with `yapi whoami`; if not logged in, run `yapi login`.
|
|
60
|
-
4. Load config from `~/.yapi/config.toml` (base_url, auth_mode, email/password or token, optional project_id).
|
|
61
|
-
5. Identify the target interface by id, URL, or keyword; ask for project/category ids if needed.
|
|
62
|
-
6. Call YApi endpoints with the CLI (see examples below) to fetch raw JSON.
|
|
63
|
-
7. Summarize method, path, headers, query/body schema, response schema, and examples.
|
|
64
|
-
|
|
65
|
-
## CLI Usage
|
|
66
|
-
- Config location: `~/.yapi/config.toml`
|
|
67
|
-
- Auth cache: `~/.yapi-mcp/auth-*.json`
|
|
42
|
+
## Common commands
|
|
68
43
|
|
|
69
|
-
### Common commands
|
|
70
44
|
```bash
|
|
71
|
-
#
|
|
45
|
+
# version/help
|
|
72
46
|
yapi --version
|
|
73
|
-
|
|
74
|
-
# Show help
|
|
75
47
|
yapi -h
|
|
76
48
|
|
|
77
|
-
#
|
|
49
|
+
# auth
|
|
78
50
|
yapi whoami
|
|
51
|
+
yapi login --browser
|
|
52
|
+
yapi login --login-url https://your-yapi-domain.com/
|
|
53
|
+
yapi logout
|
|
79
54
|
|
|
80
|
-
#
|
|
81
|
-
yapi
|
|
82
|
-
|
|
83
|
-
# Search interfaces
|
|
84
|
-
yapi search --q keyword
|
|
85
|
-
|
|
86
|
-
# Get interface by ID
|
|
55
|
+
# search / fetch
|
|
56
|
+
yapi search --q keyword --project-id 310
|
|
87
57
|
yapi --path /api/interface/get --query id=123
|
|
88
|
-
|
|
89
|
-
# List interfaces in category
|
|
90
58
|
yapi --path /api/interface/list_cat --query catid=123
|
|
91
59
|
```
|
|
92
60
|
|
|
61
|
+
Config cache locations:
|
|
62
|
+
- Config: `~/.yapi/config.toml`
|
|
63
|
+
- Auth cache: `~/.yapi-mcp/auth-*.json`
|
|
64
|
+
|
|
65
|
+
Browser login dependency:
|
|
66
|
+
```bash
|
|
67
|
+
agent-browser-stealth -V
|
|
68
|
+
# install once if missing browser runtime
|
|
69
|
+
agent-browser-stealth install
|
|
70
|
+
```
|
|
71
|
+
|
|
93
72
|
## Docs sync
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
-
|
|
104
|
-
-
|
|
105
|
-
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
-
|
|
112
|
-
- Keep request/response structures in `req_*` / `res_body` instead of stuffing them into `desc` or `markdown`.
|
|
73
|
+
|
|
74
|
+
Binding mode (recommended):
|
|
75
|
+
```bash
|
|
76
|
+
yapi docs-sync bind add --name projectA --dir docs/release-notes --project-id 267 --catid 3667
|
|
77
|
+
yapi docs-sync --binding projectA --dry-run
|
|
78
|
+
yapi docs-sync --binding projectA
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Notes:
|
|
82
|
+
- Binding file: `.yapi/docs-sync.json`
|
|
83
|
+
- Mapping outputs: `.yapi/docs-sync.links.json`, `.yapi/docs-sync.projects.json`, `.yapi/docs-sync.deployments.json`
|
|
84
|
+
- Default behavior syncs changed files only; use `--force` for full sync.
|
|
85
|
+
- Compatible with directory `.yapi.json` config as fallback (without binding).
|
|
86
|
+
- Mermaid/PlantUML/Graphviz/D2 rendering depends on local tool availability; missing tools do not block basic sync.
|
|
87
|
+
|
|
88
|
+
## Interface creation guardrails
|
|
89
|
+
- Always set `req_body_type` (use `json` if unsure) and provide `res_body` (prefer JSON Schema) when creating/updating interfaces.
|
|
90
|
+
- Put structured request/response fields in `req_*` / `res_body`, not only in free-text `desc`/`markdown`.
|