feat(mcp): @snowluma/mcp — read-only MCP server for the OneBot action catalog
A new published package that exposes every OneBot action's docs + a ready-to-use JSON Schema to LLM clients over stdio. Tools: list_actions / get_action / search_actions / list_categories, plus the whole catalog as a resource. The catalog is a build-time snapshot generated from @snowluma/onebot's live action specs (collectActionDocs()) — so it auto-tracks action add/remove and the published package carries zero runtime dependency on the private onebot package. action-kit enrichment (the data source): - Field.toJsonSchema() per coercer (uint→integer/minimum:1, messageId→integer/ not-const-0, int→min/max, string→minLength/maxLength, array→items, enum→enum). - describe() composes a per-action inputSchema; ActionDoc gains inputSchema + category. action-docs.ts tags each doc with its domain category. Wiring: onebot exports ./action-kit + ./action-docs; root build:all includes mcp; mcp-npm-publish.yml mirrors the sdk/ui publish workflows (triggers on changes under packages/mcp/** or packages/onebot/**, since the catalog derives from it). onebot typecheck + 318 tests green; mcp typecheck/build/smoke green; the 142 registered OneBot action names are unchanged.
This commit is contained in:
16 files changed
+7012
-33
No files matched your search
@@ -0,0 +1,32 @@
|
||||
// Catalog generator. Runs under vitest (so @snowluma/onebot/action-docs resolves
|
||||
// via the proton plugin, exactly as onebot's own tests do) and writes a build-time
|
||||
// snapshot of the OneBot action catalog into src/generated/catalog.ts.
|
||||
//
|
||||
// This is the whole "auto-track Action 增减" mechanic: the snapshot is regenerated
|
||||
// from the live specs on every build, so it can never describe a stale action set.
|
||||
import { mkdirSync, writeFileSync } from 'node:fs';
|
||||
import { it, expect } from 'vitest';
|
||||
import { collectActionDocs, collectCategories } from '@snowluma/onebot/action-docs';
|
||||
|
||||
it('generates src/generated/catalog.ts from the live action specs', () => {
|
||||
const actions = collectActionDocs();
|
||||
const categories = collectCategories();
|
||||
|
||||
expect(actions.length).toBeGreaterThan(100);
|
||||
// every action must carry a composed input schema (the MCP's payoff)
|
||||
for (const a of actions) {
|
||||
expect(a.inputSchema).toBeTypeOf('object');
|
||||
expect(a.name).toBeTruthy();
|
||||
}
|
||||
|
||||
const body =
|
||||
'// GENERATED by scripts/gen-catalog.test.ts — do not edit. Run `pnpm gen`.\n' +
|
||||
'/* eslint-disable */\n' +
|
||||
"import type { CatalogAction, CatalogCategory } from '../types.js';\n\n" +
|
||||
`export const ACTIONS: CatalogAction[] = ${JSON.stringify(actions, null, 2)};\n\n` +
|
||||
`export const CATEGORIES: CatalogCategory[] = ${JSON.stringify(categories, null, 2)};\n`;
|
||||
|
||||
const dir = new URL('../src/generated/', import.meta.url);
|
||||
mkdirSync(dir, { recursive: true });
|
||||
writeFileSync(new URL('../src/generated/catalog.ts', import.meta.url), body);
|
||||
});
|
||||
Reference in new issue
Block a user