Files
LangBot/skills/schemas/README.md
T
Junyan Chin e9dd584792 feat: MCP server + in-repo skills (agent-friendly platform) (#2269)
* feat(api): support global API key from config.yaml (api.global_api_key)

Accept a config-defined global API key anywhere a web-UI key is accepted
(X-API-Key / Bearer), with no login session and no DB record. Useful for
automated deployments and AI agents (HTTP API + MCP). Defaults to empty
(disabled); does not require the lbk_ prefix.

- templates/config.yaml: add api.global_api_key with security notes
- service/apikey.py: verify_api_key checks global key first (constant-time)
- docs/API_KEY_AUTH.md: document the global key + security guidance
- tests: cover global-key match, prefix-free, fallback-to-db, disabled

* feat(mcp): expose LangBot management as an MCP server at /mcp

Add an MCP (Model Context Protocol) server so external AI agents can manage a
LangBot instance. Reuses the same API-key auth as the HTTP API (including the
config.yaml global API key).

- pkg/api/mcp/server.py: FastMCP server wrapping the service layer; 21 curated
  tools across system/bots/pipelines/models/knowledge/mcp-servers/skills
- pkg/api/mcp/mount.py: ASGI dispatcher fronting Quart; authenticates /mcp
  requests with an API key, runs the streamable-HTTP session manager lifespan
- controller/main.py: serve the wrapped ASGI app via hypercorn (was run_task)
- web: new 'MCP' tab in the API integration dialog showing endpoint, auth, and
  client config; i18n for 8 locales
- tests/manual/mcp_smoke.py: e2e check (401 unauth, list tools, call tools)

Tool surface is intentionally curated (not all ~25 route groups) to keep the
agent surface small, safe, and maintainable. Extend deliberately.

* feat(skills): add in-repo skills/ as the single source of truth

Migrate the agent skills + QA/e2e test harness from the (now archived)
langbot-app/langbot-skills repo into LangBot/skills/, and add four new skills.

Migrated:
- langbot-plugin-dev, langbot-testing (e2e), langbot-env-setup,
  langbot-skills-maintenance, langbot-eba-adapter-dev
- the bin/lbs CLI (src/, test/, scripts/, schemas/, qa-agent-docs/)

New:
- langbot-dev      core backend + web development
- langbot-deploy   Docker/K8s deployment + config.yaml + global API key
- langbot-mcp-ops  operating the LangBot MCP server (/mcp)
- langbot-space-ops operating the Space marketplace MCP server

- src/cli.ts repoRoot(): recognize the skills assets root (skills.index.json +
  bin/lbs) so the CLI works when nested inside the LangBot repo
- README.md: unified skill catalog; skills.index.json regenerated

Parity with source verified: bin/lbs validate + node test suite match the
source repo (only the uncommitted .lbpkg build-artifact fixture differs).

* docs(agents): document agent-facing surfaces + API/MCP/skills sync rule

* docs(readme): add 'Built for AI Agents' section across all locales

Highlight MCP server, in-repo skills (single source of truth), AGENTS.md
sync rule, and llms.txt. Cross-link LangBot Space MCP marketplace.

* style(mcp): fix ruff format + prettier lint in MCP server and API panel

* style(web): prettier format MCP i18n locale entries

* docs(skills): note MCP instance control in dev/testing skills

All development-guidance skills now point to the LangBot instance MCP
server (/mcp) and the Space marketplace MCP server, reusing API keys.
2026-06-20 15:14:47 +08:00

2.9 KiB
Raw Blame History

Schemas

这个目录存放 LangBot skills 结构化资产的 JSON Schema。

它们不是测试脚本,也不会执行浏览器动作。它们的作用是定义 agent 和维护者后续新增资产时应该遵守的文件结构。

文件说明

  • skills/<skill>/fixtures/fixtures.json 不是 JSON Schema,但由 bin/lbs validate 校验。 它登记 deterministic fixture 文件、类型和关联 case,供 bin/lbs fixture check 做 readiness 检查。

  • case.schema.json 约束 skills/<skill>/cases/*.yaml 的格式。 Case 描述 agent-browser 或 probe QA 路径,包括前置条件、步骤、检查点、诊断手段和关联故障。

  • suite.schema.json 约束 skills/<skill>/suites/*.yaml 的格式。 Suite 只组织 case 集合,用于 smoke、regression 或 release gate 等测试入口。

  • troubleshooting.schema.json 约束 skills/<skill>/troubleshooting/*.yaml 的格式。 Troubleshooting 条目描述症状、日志/错误模式、可能原因、修复步骤和验证信号。

  • skill-index.schema.json 约束生成文件 skills.index.json 的格式。 这个索引用于让 agent 快速发现已有 skills、references、cases、suites 和 troubleshooting。

  • reports/evidence/<run-id>/result.json 不是 catalog schema,而是执行期最终裁定产物,由 bin/lbs test result 写入。 suite report 读取其中的 statusreason、起止时间和 evidence_collected 并用 evidence_missing 防止缺证据的 pass 被当作完整通过。

  • reports/evidence/<run-id>/automation-result.json 不是 catalog schema,而是浏览器自动化脚本的原始运行结论,供 bin/lbs test report 展示和推断日志扫描窗口。

为什么需要 schemas

Schemas 是基础设施护栏:

  • 防止 case、suite 和 troubleshooting 随着增长变得格式混乱
  • bin/lbs validate 能发现缺字段和错误结构
  • 为未来编辑器提示和 CI 校验留接口
  • 帮助 agent 新增资产时知道应该写哪些字段

当前校验方式

bin/lbs validate 做轻量、schema 对齐的校验,不引入额外依赖。它会检查必填字段、 枚举值、boolean 字段、重复列表项、automation 脚本存在性,以及 case、suite、skill、 troubleshooting 之间的交叉引用。这里的 schema 仍是格式契约;如果未来引入正式 JSON Schema validator,应继续保持这些本地交叉引用检查。

Case 里的 env / automation_env 表示所有列出的变量都需要配置。遇到二选一输入时, 使用 env_any / automation_env_any,每一项写成 LANGBOT_PIPELINE_URL|LANGBOT_PIPELINE_NAME 这类 one-of 组合,避免 agent 因为只配置了 URL 或 name 其中之一而误判未就绪。 setuppreconditions 是人工确认项,会让 readiness 进入 manual_check setup_automationtest run 可以自动执行的准备步骤,配合 setup_provides_env 声明它会生成的机器变量。