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
@@ -164,6 +164,42 @@ describe('run raw escape hatch — original params as 3rd arg', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('toJsonSchema / inputSchema (for the MCP)', () => {
|
||||
it('emits a JSON Schema fragment per coercer', () => {
|
||||
expect(f.uint().toJsonSchema()).toEqual({ type: 'integer', minimum: 1 });
|
||||
expect(f.messageId().toJsonSchema()).toEqual({ type: 'integer', not: { const: 0 } });
|
||||
expect(f.int({ min: 0 }).default(1800).toJsonSchema()).toEqual({ type: 'integer', minimum: 0, default: 1800 });
|
||||
expect(f.string({ allowEmpty: false }).toJsonSchema()).toEqual({ type: 'string', minLength: 1 });
|
||||
expect(f.bool().toJsonSchema()).toEqual({ type: 'boolean' });
|
||||
expect(f.enum('a', 'b').toJsonSchema()).toEqual({ enum: ['a', 'b'] });
|
||||
expect(f.array(f.uint()).nonEmpty().toJsonSchema()).toEqual({
|
||||
type: 'array',
|
||||
items: { type: 'integer', minimum: 1 },
|
||||
minItems: 1,
|
||||
});
|
||||
expect(f.uint().describe('群号').toJsonSchema()).toEqual({ type: 'integer', minimum: 1, description: '群号' });
|
||||
});
|
||||
|
||||
it('composes an action inputSchema (object + required + defaults)', () => {
|
||||
const spec = groupUserAction({
|
||||
name: 'set_group_ban',
|
||||
params: { duration: f.int({ min: 0 }).default(1800) },
|
||||
run: () => okResponse(),
|
||||
});
|
||||
const { inputSchema } = spec.describe();
|
||||
expect(inputSchema).toMatchObject({
|
||||
type: 'object',
|
||||
additionalProperties: true,
|
||||
required: ['group_id', 'user_id'],
|
||||
properties: {
|
||||
group_id: { type: 'integer', minimum: 1 },
|
||||
user_id: { type: 'integer', minimum: 1 },
|
||||
duration: { type: 'integer', minimum: 0, default: 1800 },
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('describe — doc metadata for self-generated docs (D4)', () => {
|
||||
const spec = groupUserAction({
|
||||
name: ['set_group_ban', 'ban'],
|
||||
|
||||
Reference in new issue
Block a user