AsyncAPI CLI
$ asyncapi 基金会 低风险AsyncAPI 官方 CLI 用于校验、打包、比对、转换 AsyncAPI 2.x/3.x 事件驱动规范并生成代码或文档。Agent 可使用 asyncapi validate --diagnostics-format json 获取结构化检查结果,并用 asyncapi bundle -o 解析外部 $ref 引用。
brew install asyncapi 直接在本地运行 asyncapi validate --diagnostics-format json 与 asyncapi bundle 处理仓库规范,无需通过 MCP 上传 Schema。
Agent 友好度体检单
当前为静态评估(本机尚未安装或尚未运行探针)。可在本地运行 npm run data:probe 并提交 data/probes/ 升级为实测证据。
FCRS-1.0 六维评分拆解
validate --diagnostics-format json 可输出干净的 JSON 诊断且 bundle 支持无头运行,但需避开 asyncapi new 等交互子命令和会阻塞的 start studio。
--diagnostics-format jsonsupported onasyncapi validateasyncapi start studiolaunches a blocking local server
validate 为只读;bundle 与 generate 仅写入显式指定的 --output 路径。
- Clear separation between
validateand write commands
可通过 Homebrew、npm 与 npx @asyncapi/cli 在 macOS、Linux 与 Windows 安装。
- Distributed on both Homebrew and npm
集 AsyncAPI 2.x/3.x 校验、版本转换、打包与模板生成于一体的官方工具链。
- Covers validation, bundling, diffing, and code/doc generation
由 AsyncAPI Initiative / Linux Foundation(asyncapi/cli)维护的 Apache-2.0 官方项目。
- Official Linux Foundation / AsyncAPI organization
asyncapi.com/docs/tools/cli 提供完整的 CLI 文档及清晰的 --help 输出。
- Official docs at asyncapi.com/docs/tools/cli
安全边界、鉴权与放权指南
无需凭据;仅读取本地或公开 URL 的 AsyncAPI 规范文件。
100% 免费且遵循 Apache-2.0 开源协议。
# AsyncAPI CLI Agent Rules - Always pass `--diagnostics-format json` when running `asyncapi validate`. - Never run `asyncapi start studio` in a non-interactive agent turn (starts a blocking web UI server). - Pass `--output <file>` explicitly to `asyncapi bundle` and `asyncapi generate`.
Agent 高频安全命令配方
只读查询(安全推荐)
asyncapi validate asyncapi.yaml --diagnostics-format json
对 AsyncAPI 文档执行只读校验,并输出基于 Spectral 的 JSON 诊断结果。
受控写入与预演
asyncapi bundle asyncapi.yaml --output dist/asyncapi.bundled.yaml
解析外部 $ref 引用并将自包含的 AsyncAPI 规范写入 dist/asyncapi.bundled.yaml。
核心优势
- +
asyncapi validate --diagnostics-format json返回结构化校验错误。 - + Linux Foundation 官方工具,完整支持 AsyncAPI 2.x 与 3.x 规范。
- + 支持 Homebrew(
brew install asyncapi)或npx @asyncapi/cli便捷安装。
注意事项与踩坑点
- ! 执行
asyncapi start studio会启动持久化本地 Studio UI 服务并阻塞终端。 - !
asyncapi new等命令在缺少模板或文件参数时会触发交互提示。