plugin-worma-docs weekly downloads statistics
By Leadgq (2 listings) · npm · Webpack plugins
Vite/Webpack OpenAPI handbook generator and read-only MCP server for API discovery and request/response schemas.
plugin-worma-docs has 32 recorded weekly downloads on npm, a decrease of 88.5% over the past 30 days, ranking #2883 of 3,247 tracked listings.
About plugin-worma-docs
plugin-worma-docs
将 Swagger / OpenAPI 转为本地接口手册,或通过 MCP 让 AI 按需查询接口。可选生成 Axios、Fetch、Ky 请求实现及类型声明,默认关闭。
同一个 npm 包提供三个入口:
| 使用方式 | 入口 | 默认行为 |
|---|---|---|
| Vite 插件 | plugin-worma-docs | 在构建钩子中生成 Markdown 接口手册 |
| Webpack 5 插件 | plugin-worma-docs/webpack | 在运行钩子中生成 Markdown 接口手册 |
| stdio MCP | worma-docs-mcp 命令 | 只读查询接口,不生成 Markdown 或请求代码 |
请求代码根据 Swagger/OpenAPI 生成,不依赖 Markdown。MCP 可以独立使用,不需要安装或接入 Vite / Webpack 插件。
目录
- 安装与环境
- MCP:单个与多个 Swagger
- Vite:单个与多个 Swagger
- Webpack:单个与多个 Swagger
- 请求代码配置与继承规则
- 全部配置项
- MCP 工具与只读范围
- 本地开发、测试与发布
安装与环境
要求 Node.js 18.18+;构建插件支持的 Vite / Webpack 版本以 package.json 的 peerDependencies 为准。
使用构建插件时安装:
pnpm add -D plugin-worma-docs
只使用 MCP 时可通过 npx 运行,无需将本包安装到业务项目:
npx --yes --package=plugin-worma-docs worma-docs-mcp --config /absolute/path/worma-mcp.json
生成 Axios / Ky 客户端时,业务项目还需安装对应运行依赖:
pnpm add axios
# 或者使用 Ky 模板:
pnpm add ky
Fetch 模板使用运行环境提供的 Fetch API。生成器不会自动安装依赖。
MCP:单个与多个 Swagger
MCP 配置是一个 JSON 文件,例如项目根目录的 worma-mcp.json。即使只有一个 Swagger,也使用 sources 数组。
单个 Swagger:只查询,不生成代码
{
"sources": [
{
"name": "knowledgebase",
"swagger": "https://example.com/knowledgebase/openapi.json"
}
]
}
省略 generateClient 等同于 false。也可以显式填写 "generateClient": false。
Swagger 更新与刷新
默认每个来源的快照有效期为 60 秒。列表、搜索和详情工具在查询时检查是否过期,过期后重新读取 Swagger / 本地文件,再返回结果;没有查询时不做后台轮询。
{
"refreshIntervalSeconds": 60,
"sources": [
{
"name": "knowledgebase",
"swagger": "https://example.com/knowledgebase/openapi.json",
"refreshIntervalSeconds": 15
},
{
"name": "orders",
"swagger": "./specs/orders.yaml"
}
]
}
来源级设置覆盖顶层间隔:上例 knowledgebase 为 15 秒,orders 为 60 秒。范围为 0–86400 秒;0 关闭自动刷新,仍可手动刷新。后端刚更新、尚未到期时,可让 AI 调用 refresh_apis,传入 source: "knowledgebase" 只刷新一个来源,或省略 source 刷新全部。
列表/搜索的 sources[]、详情的 freshness 以及刷新工具的 sources[] 都包含:
| 字段 | 含义 |
|---|---|
| lastLoadedAt | 上一次成功读取并建立索引的时间,ISO 8601 UTC;不代表后端修改时间 |
| lastRefreshAttemptAt | 最近一次读取尝试的时间 |
| refreshIntervalSeconds | 该来源实际采用的刷新间隔 |
| automaticRefreshEnabled | 是否开启查询时自动刷新 |
| stale | 快照是否已过期或最近一次刷新失败;关闭自动刷新并不保证后端未变化 |
| lastRefreshError | 最近一次刷新错误,成功时为 null |
同一来源的并发刷新会合并为一次读取。读取或解析失败时保留上一次成功的接口数据,标记 stale 和错误,不清空接口;自动失败后按该来源间隔退避,手动刷新可立即重试。多来源分别更新,某来源失败不丢失其他来源的数据。refresh_apis 的 success 为 false 时,MCP 返回 isError,并附带各来源状态。
刷新仅重新读取配置中允许的文档,不修改 Swagger、不执行业务接口,也不会重新生成请求代码。需要更新已生成的请求代码时仍需重启服务或重新运行生成流程。修改来源 URL、标签、生成配置或刷新间隔等配置文件内容后,需要重启服务才能生效。
单个 Swagger:查询并生成请求代码
{
"generateClient": true,
"client": {
"output": "src/api/generated/knowledgebase",
"library": "axios",
"type": "module",
"nameStyle": "camelCase"
},
"sources": [
{
"name": "knowledgebase",
"swagger": "https://example.com/knowledgebase/openapi.json",
"tags": ["AiKnowledge", "KnowledgeBase"]
}
]
}
服务启动时先读取文档,再生成代码,成功后提供 MCP 工具。上例仅查询和生成所选标签的接口;删除 tags 可处理全部接口。
多个 Swagger:只查询,不生成代码
{
"sources": [
{
"name": "knowledgebase",
"swagger": "https://example.com/knowledgebase/openapi.json"
},
{
"name": "orders",
"swagger": "./specs/orders.yaml",
"tags": ["Order"]
}
]
}
每个 name 必须唯一。支持 HTTP(S) 文档地址,以及本地 JSON / YAML 文件;本地相对路径基于配置文件所在目录解析。
多个 Swagger:公共默认配置 + 各来源覆盖
{
"generateClient": true,
"client": {
"library": "axios",
"type": "module",
"nameStyle": "camelCase"
},
"sources": [
{
"name": "knowledgebase",
"swagger": "https://example.com/knowledgebase/openapi.json",
"client": {
"output": "src/api/generated/knowledgebase"
}
},
{
"name": "orders",
"swagger": "https://example.com/orders/openapi.json",
"client": {
"output": "src/api/generated/orders",
"library": "fetch",
"type": "typescript"
}
},
{
"name": "audit",
"swagger": "./specs/audit.json",
"generateClient": false
}
]
}
| 来源 | 是否生成请求 | 输出目录 | 请求库 | 格式 | 方法名 |
|---|---|---|---|---|---|
| knowledgebase | 是 | src/api/generated/knowledgebase | Axios | ESM JavaScript | camelCase |
| orders | 是 | src/api/generated/orders | Fetch | TypeScript | camelCase |
| audit | 否,仍可通过 MCP 查询 | — | — | — | — |
多个 Swagger:每个来源完全独立配置
不需要公共默认值时,可以完全省略顶层的 generateClient 和 client:
{
"sources": [
{
"name": "knowledgebase",
"swagger": "https://example.com/knowledgebase/openapi.json",
"generateClient": true,
"client": {
"output": "generated/knowledgebase",
"library": "axios",
"type": "module",
"nameStyle": "camelCase"
}
},
{
"name": "orders",
"swagger": "./specs/orders.yaml",
"generateClient": true,
"client": {
"output": "generated/orders",
"library": "ky",
"type": "typescript",
"nameStyle": "camelCase"
}
}
]
}
接入 MCP 客户端
在支持 stdio MCP 的客户端中添加服务。下面是通用 JSON 示例,具体配置位置由客户端决定;将路径替换为实际的配置文件绝对路径:
{
"mcpServers": {
"worma-docs": {
"command": "npx",
"args": [
"--yes",
"--package=plugin-worma-docs",
"worma-docs-mcp",
"--config",
"D:/your-project/worma-mcp.json"
]
}
}
}
需要固定版本时,将包参数改为 --package=plugin-worma-docs@你的版本号。升级后应更新固定版本号并重启服务。首次下载包、读取文档和生成代码可能较慢,可在客户端中适当增加启动超时。
客户端负责启动服务,无需另外手动运行一份。stdio 服务启动后等待协议消息,没有普通终端输出是正常现象。
CLI 只有以下选项,生成配置写在 JSON 文件中:
| 参数 | 说明 |
|---|---|
--config <path> | 必填,JSON 配置文件路径;推荐使用绝对路径 |
--help / -h | 显示命令说明 |
Vite:单个与多个 Swagger
单个 Swagger:生成接口手册
import { defineConfig } from 'vite'
import { wormaDocs } from 'plugin-worma-docs'…
Description from the npm listing.
- vite
- vite-plugin
- webpack
- webpack-plugin
- openapi
- swagger
- worma
- api-docs
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (592)Similar npm Webpack plugins plugins
All 20 plugin-worma-docs alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/plugin-worma-docs. First seen Oct 16, 2026; last successful collection Dec 6, 2026. See the methodology.