kibi-mcp 0.19.0 → 0.19.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/bin/kibi-mcp +1 -1
  2. package/dist/runtime/mcp-runtime.js +43 -0
  3. package/dist/server/docs.js +4 -4
  4. package/dist/server/json-schema-to-zod.js +73 -2
  5. package/dist/server/session.js +33 -15
  6. package/dist/server/tool-registration.js +35 -62
  7. package/dist/server/tools-runtime.js +52 -2
  8. package/dist/server/tools.js +19 -5
  9. package/dist/server/transport.js +9 -5
  10. package/dist/tools/autopilot-generate.js +37 -646
  11. package/dist/tools/autopilot-test-compat.js +88 -0
  12. package/dist/tools/autopilot-test-parsers.js +120 -0
  13. package/dist/tools/check.js +13 -106
  14. package/dist/tools/coverage.js +11 -25
  15. package/dist/tools/delete.js +5 -112
  16. package/dist/tools/discovery-adapter.js +23 -0
  17. package/dist/tools/entity-query.js +1 -111
  18. package/dist/tools/find-gaps.js +11 -26
  19. package/dist/tools/graph.js +11 -24
  20. package/dist/tools/model-requirement.js +8 -347
  21. package/dist/tools/mutation-context.js +28 -0
  22. package/dist/tools/query.js +5 -50
  23. package/dist/tools/relationship-validation.js +9 -116
  24. package/dist/tools/search.js +4 -37
  25. package/dist/tools/semantic-advisor.js +2 -40
  26. package/dist/tools/skills.js +17 -57
  27. package/dist/tools/sparql.js +12 -93
  28. package/dist/tools/status.js +5 -19
  29. package/dist/tools/suggest-predicates.js +11 -2448
  30. package/dist/tools/upsert.js +21 -816
  31. package/dist/tools/validate-upsert.js +12 -48
  32. package/dist/tools-config.js +75 -802
  33. package/package.json +4 -3
  34. package/dist/semantic-advisor/analyze-prose.js +0 -1392
  35. package/dist/semantic-advisor/prose-coverage-evaluator.js +0 -66
  36. package/dist/semantic-advisor/types.js +0 -1
@@ -15,809 +15,82 @@
15
15
  You should have received a copy of the GNU Affero General Public License
16
16
  along with this program. If not, see <https://www.gnu.org/licenses/>.
17
17
  */
18
+ import { getSpec } from "kibi-cli/operations";
18
19
  import { DIAGNOSTIC_MODE_ENABLED, DIAGNOSTIC_TELEMETRY_SCHEMA, } from "./diagnostics.js";
19
- const BASE_TOOLS = [
20
- // implements REQ-002
21
- {
22
- name: "kb_query",
23
- description: "Read entities from the KB with filters. Use for discovery and lookup before edits. Do not use for writes. No mutation side effects. Tags filter by metadata tags only, not entity IDs.",
24
- inputSchema: {
25
- type: "object",
26
- properties: {
27
- type: {
28
- type: "string",
29
- enum: [
30
- "req",
31
- "scenario",
32
- "test",
33
- "adr",
34
- "flag",
35
- "event",
36
- "symbol",
37
- "fact",
38
- ],
39
- description: "Optional entity type filter. Allowed: req, scenario, test, adr, flag, event, symbol, fact. Example: 'req'.",
40
- },
41
- id: {
42
- type: "string",
43
- description: "Optional exact entity ID. Example: 'REQ-001'. If omitted, returns matching entities by other filters.",
44
- },
45
- tags: {
46
- type: "array",
47
- items: { type: "string" },
48
- description: "Optional tag filter. Matches entities that contain any provided tag. Example: ['security','billing'].",
49
- },
50
- sourceFile: {
51
- type: "string",
52
- description: "Optional source-file substring filter. Example: 'src/auth/login.ts'. Uses KB source linkage, not file-system scanning.",
53
- },
54
- limit: {
55
- type: "number",
56
- default: 100,
57
- description: "Optional max rows to return after filtering. Default: 100 when omitted. Example: 25.",
58
- },
59
- offset: {
60
- type: "number",
61
- default: 0,
62
- description: "Optional zero-based pagination offset. Default: 0. Example: 50 to skip first 50 rows.",
63
- },
64
- },
65
- },
66
- },
67
- {
68
- name: "kb_search",
69
- description: "Search KB entities for discovery using metadata and markdown body text. Use for exploratory lookup before exact follow-up with kb_query. No mutation side effects.",
70
- inputSchema: {
71
- type: "object",
72
- required: ["query"],
73
- properties: {
74
- query: {
75
- type: "string",
76
- description: "Free-text query for metadata and markdown body discovery. Example: 'OAuth login flow'.",
77
- },
78
- type: {
79
- type: "string",
80
- enum: [
81
- "req",
82
- "scenario",
83
- "test",
84
- "adr",
85
- "flag",
86
- "event",
87
- "symbol",
88
- "fact",
89
- ],
90
- description: "Optional entity type filter to narrow discovery. Example: 'req'.",
91
- },
92
- limit: {
93
- type: "integer",
94
- default: 20,
95
- description: "Optional max rows to return after ranking. Default: 20.",
96
- },
97
- offset: {
98
- type: "integer",
99
- default: 0,
100
- description: "Optional zero-based pagination offset. Default: 0.",
101
- },
102
- },
103
- },
104
- },
105
- {
106
- name: "kb_status",
107
- description: "Report current branch, snapshot, and freshness metadata for the attached KB. Read-only status inspection with no mutation side effects.",
108
- inputSchema: {
109
- type: "object",
110
- properties: {},
111
- },
112
- },
113
- {
114
- name: "kb_skills_list",
115
- description: "List bundled Kibi agent skills available for progressive disclosure. Read-only; does not mutate the KB or require Prolog.",
116
- inputSchema: {
117
- type: "object",
118
- properties: {},
119
- },
120
- },
121
- {
122
- name: "kb_skills_load",
123
- description: "Load a bundled Kibi agent skill by ID, returning its manifest metadata, Markdown body, declared resources, content hash, and source type. Read-only; does not execute scripts or require Prolog.",
124
- inputSchema: {
125
- type: "object",
126
- required: ["id"],
127
- properties: {
128
- id: {
129
- type: "string",
130
- description: "Bundled skill ID to load. Example: 'kibi-usage'.",
131
- },
132
- },
133
- },
134
- },
135
- {
136
- name: "kb_skills_read",
137
- description: "Read a declared resource from a bundled Kibi agent skill. Resource paths are restricted to the skill manifest; arbitrary file paths are not exposed. Read-only; does not require Prolog.",
138
- inputSchema: {
139
- type: "object",
140
- required: ["id", "resource"],
141
- properties: {
142
- id: {
143
- type: "string",
144
- description: "Bundled skill ID. Example: 'kibi-usage'.",
145
- },
146
- resource: {
147
- type: "string",
148
- description: "Manifest-declared resource path to read. Example: 'resources/workflows.md'.",
149
- },
150
- },
151
- },
152
- },
153
- {
154
- name: "kb_find_gaps",
155
- description: "Run bulk missing/present relationship analysis over KB entities. Use for questions like which requirements lack scenarios or tests. No mutation side effects.",
156
- inputSchema: {
157
- type: "object",
158
- properties: {
159
- type: {
160
- type: "string",
161
- enum: [
162
- "req",
163
- "scenario",
164
- "test",
165
- "adr",
166
- "flag",
167
- "event",
168
- "symbol",
169
- "fact",
170
- ],
171
- },
172
- missingRelationships: {
173
- type: "array",
174
- items: { type: "string" },
175
- },
176
- presentRelationships: {
177
- type: "array",
178
- items: { type: "string" },
179
- },
180
- tags: {
181
- type: "array",
182
- items: { type: "string" },
183
- },
184
- sourceFile: {
185
- type: "string",
186
- },
187
- limit: {
188
- type: "integer",
189
- default: 100,
190
- },
191
- offset: {
192
- type: "integer",
193
- default: 0,
194
- },
195
- },
196
- },
197
- },
198
- {
199
- name: "kb_coverage",
200
- description: "Generate curated coverage reports for requirements, symbols, or grouped types. Read-only reporting with no mutation side effects.",
201
- inputSchema: {
202
- type: "object",
203
- properties: {
204
- by: {
205
- type: "string",
206
- enum: ["req", "symbol", "type"],
207
- default: "req",
208
- },
209
- tags: {
210
- type: "array",
211
- items: { type: "string" },
212
- },
213
- includePassing: {
214
- type: "boolean",
215
- default: false,
216
- },
217
- includeTransitive: {
218
- type: "boolean",
219
- default: true,
220
- },
221
- limit: {
222
- type: "integer",
223
- default: 100,
224
- },
225
- offset: {
226
- type: "integer",
227
- default: 0,
228
- },
229
- },
230
- },
231
- },
232
- {
233
- name: "kb_graph",
234
- description: "Run bounded graph traversal from one or more seed IDs across curated relationship types. No mutation side effects.",
235
- inputSchema: {
236
- type: "object",
237
- required: ["seedIds"],
238
- properties: {
239
- seedIds: {
240
- type: "array",
241
- items: { type: "string" },
242
- },
243
- relationships: {
244
- type: "array",
245
- items: { type: "string" },
246
- },
247
- direction: {
248
- type: "string",
249
- enum: ["outgoing", "incoming", "both"],
250
- default: "outgoing",
251
- },
252
- depth: {
253
- type: "integer",
254
- default: 1,
255
- minimum: 1,
256
- maximum: 5,
257
- },
258
- entityTypes: {
259
- type: "array",
260
- items: { type: "string" },
261
- },
262
- maxNodes: {
263
- type: "integer",
264
- default: 200,
265
- },
266
- maxEdges: {
267
- type: "integer",
268
- default: 500,
269
- },
270
- },
271
- },
272
- },
273
- {
274
- name: "kb_sparql_remote",
275
- description: "Opt-in remote SPARQL query tool for external HTTP(S) RDF endpoints. This does not query Kibi's local RDF store directly, stores no credentials, and depends on network availability.",
276
- inputSchema: {
277
- type: "object",
278
- required: ["endpoint", "query"],
279
- properties: {
280
- endpoint: {
281
- type: "string",
282
- description: "Remote SPARQL endpoint URL. Must start with http:// or https://.",
283
- },
284
- query: {
285
- type: "string",
286
- description: "SPARQL SELECT query to send to the remote endpoint.",
287
- },
288
- timeoutMs: {
289
- type: "number",
290
- description: "Optional positive timeout in milliseconds for the remote query.",
291
- },
292
- },
293
- },
294
- },
295
- {
296
- name: "kb_semantic_advisor",
297
- description: "Analyze requirement prose without mutating the KB and return semantic advisor receipts with modeling suggestions. Use before constructing kb_upsert payloads when prose may contain machine-checkable logic. Suggestions can include strict-property facts, predicate facts, ambiguity observations, or ontology-gap observations; all suggestions are advisory and reviewable.",
298
- inputSchema: {
299
- type: "object",
300
- required: ["text"],
301
- properties: {
302
- text: {
303
- type: "string",
304
- description: "Requirement prose to inspect for machine-checkable modeling suggestions.",
305
- },
306
- type: {
307
- type: "string",
308
- enum: ["req"],
309
- default: "req",
310
- description: "Entity type context for analysis. Currently requirement prose is supported.",
311
- },
312
- id: {
313
- type: "string",
314
- description: "Optional requirement ID used for deterministic draft relationship guidance.",
315
- },
316
- title: {
317
- type: "string",
318
- description: "Optional requirement title for draft apply plans.",
319
- },
320
- source: {
321
- type: "string",
322
- description: "Optional provenance for draft suggestions.",
323
- },
324
- status: {
325
- type: "string",
326
- description: "Optional requirement status for draft suggestions.",
327
- },
328
- },
329
- },
330
- },
331
- {
332
- name: "kb_upsert",
333
- description: "Create or update one entity and optional relationships. Use for KB mutations after validating intent; prefer kb_validate_upsert first because it returns semantic advisor receipts for prose-heavy requirements. Use kb_model_requirement before hand-writing strict property facts from prose, and kb_suggest_predicates before hand-writing ontology predicate facts. Use the `relationships` array for batch creation of multiple links in a single call (e.g., linking a requirement to multiple tests or facts). Prefer modeling requirements as reusable fact links (`constrains`, `requires_property`, or `requires_predicate`) so consistency and contradiction checks remain queryable. Relationship endpoints must already exist in KB. For requirements, the write will be rejected if it contradicts existing current requirements that constrain the same subject with incompatible properties. To replace a conflicting requirement, include a `supersedes` relationship from the new requirement to the old one in the same request. Successful writes may return non-blocking semantic advisor warnings; inspect and repair those warnings before treating prose as contradiction-checkable. Do not use for read-only inspection. Side effects: writes KB, may refresh symbol coordinates.",
334
- inputSchema: {
335
- type: "object",
336
- required: ["type", "id", "properties"],
337
- properties: {
338
- type: {
339
- type: "string",
340
- enum: [
341
- "req",
342
- "scenario",
343
- "test",
344
- "adr",
345
- "flag",
346
- "event",
347
- "symbol",
348
- "fact",
349
- ],
350
- description: "Entity type to create/update. Allowed: req, scenario, test, adr, flag, event, symbol, fact. Example: 'req'.",
351
- },
352
- id: {
353
- type: "string",
354
- description: "Unique entity ID (string). Example: 'REQ-123'. Existing ID updates the entity; new ID creates it.",
355
- },
356
- properties: {
357
- type: "object",
358
- description: "Entity fields to persist. Must include title and status. If created_at, updated_at, or source are omitted, server fills defaults.",
359
- properties: {
360
- title: {
361
- type: "string",
362
- description: "Required short title. Example: 'Protect account settings endpoint'.",
363
- },
364
- status: {
365
- type: "string",
366
- description: "Required lifecycle state. Allowed values depend on entity type; backward-compatible legacy statuses are also accepted. Examples: 'open', 'passing', 'accepted', 'active'.",
367
- },
368
- source: {
369
- type: "string",
370
- description: "Optional provenance string. Example: 'docs/requirements/REQ-123.md'. Defaults to 'mcp://kibi/upsert'.",
371
- },
372
- tags: {
373
- type: "array",
374
- items: { type: "string" },
375
- description: "Optional categorization tags. Example: ['security','api'].",
376
- },
377
- owner: {
378
- type: "string",
379
- description: "Optional owner name/team. Example: 'platform-team'.",
380
- },
381
- priority: {
382
- type: "string",
383
- description: "Optional priority label. Example: 'high'.",
384
- },
385
- severity: {
386
- type: "string",
387
- description: "Optional severity label. Example: 'critical'.",
388
- },
389
- links: {
390
- type: "array",
391
- items: { type: "string" },
392
- description: "Optional references. Example: ['REQ-010','https://example.com/spec'].",
393
- },
394
- text_ref: {
395
- type: "string",
396
- description: "Optional text anchor/reference. Example: 'requirements.md#L40'.",
397
- },
398
- sourceFile: {
399
- type: "string",
400
- description: "Optional code source file for symbol entities. Example: 'src/auth/login.ts'.",
401
- },
402
- granularity_reason: {
403
- type: "string",
404
- enum: [
405
- "config-artifact",
406
- "module-level-behavior",
407
- "extractor-miss",
408
- "legacy-link",
409
- ],
410
- description: "Optional justification for a coarse file/module-level symbol traceability relationship when narrower function/class/type symbols exist.",
411
- },
412
- symbol_role: {
413
- type: "string",
414
- enum: [
415
- "behavioral",
416
- "structural",
417
- "type-shape",
418
- "config",
419
- "module",
420
- "unknown",
421
- ],
422
- description: "Optional role classification for symbol entities. Example: 'behavioral'.",
423
- },
424
- verification_scope: {
425
- type: "string",
426
- enum: ["unit", "integration", "end_to_end"],
427
- description: "Optional typed verification scope for test entities. Example: 'end_to_end'.",
428
- },
429
- verification_perspective: {
430
- type: "string",
431
- enum: ["internal", "consumer"],
432
- description: "Optional typed verification perspective for test entities. Example: 'consumer'.",
433
- },
434
- fact_kind: {
435
- type: "string",
436
- enum: [
437
- "subject",
438
- "property_value",
439
- "observation",
440
- "meta",
441
- "predicate_schema",
442
- "predicate",
443
- ],
444
- description: "Optional fact lane kind for fact entities. Strict lane uses 'subject' and 'property_value'; context lane uses 'observation' or 'meta'; ontology lane uses 'predicate_schema' or 'predicate'. Use kb_model_requirement or kb_suggest_predicates when starting from prose.",
445
- },
446
- subject_key: {
447
- type: "string",
448
- description: "Snake_case only. Optional canonical subject key for strict fact entities. Example: 'user.session'. Do not use subjectKey in kb_upsert.properties.",
449
- },
450
- property_key: {
451
- type: "string",
452
- description: "Snake_case only. Optional canonical property key for property_value facts. Example: 'session.timeout_minutes'. Do not use propertyKey in kb_upsert.properties.",
453
- },
454
- operator: {
455
- type: "string",
456
- enum: ["eq", "neq", "lt", "lte", "gt", "gte"],
457
- description: "Optional comparison operator for property_value facts. Example: 'eq'.",
458
- },
459
- value_type: {
460
- type: "string",
461
- enum: ["string", "int", "number", "bool"],
462
- description: "Optional typed value discriminator for property_value facts. Pair with exactly one value_string, value_int, value_number, or value_bool; do not use generic value.",
463
- },
464
- value_string: {
465
- type: "string",
466
- description: "Optional string value for property_value facts.",
467
- },
468
- value_int: {
469
- type: "integer",
470
- description: "Optional integer value for property_value facts.",
471
- },
472
- value_number: {
473
- type: "number",
474
- description: "Optional number value for property_value facts.",
475
- },
476
- value_bool: {
477
- type: "boolean",
478
- description: "Optional boolean value for property_value facts.",
479
- },
480
- unit: {
481
- type: "string",
482
- description: "Optional unit for numeric property_value facts.",
483
- },
484
- scope: {
485
- type: "string",
486
- description: "Optional scope qualifier for fact entities.",
487
- },
488
- polarity: {
489
- type: "string",
490
- enum: ["require", "forbid", "assert", "deny"],
491
- description: "Optional polarity for property_value or predicate facts.",
492
- },
493
- closed_world: {
494
- type: "boolean",
495
- description: "Optional closed-world marker for strict fact interpretation.",
496
- },
497
- canonical_key: {
498
- type: "string",
499
- description: "Optional canonical identity key for predicate or strict fact claims.",
500
- },
501
- predicate_name: {
502
- type: "string",
503
- description: "Optional predicate name for ontology predicate facts. Prefer kb_suggest_predicates before hand-writing predicate_name.",
504
- },
505
- predicate_args: {
506
- type: "array",
507
- items: { type: "string" },
508
- description: "Optional ordered predicate arguments for ontology predicate facts. Prefer kb_suggest_predicates before hand-writing predicate_args.",
509
- },
510
- },
511
- required: ["title", "status"],
512
- },
513
- relationships: {
514
- type: "array",
515
- description: "Optional relationship rows to create in the same call. For requirement encoding, prefer `constrains` + `requires_property` for strict property facts or `requires_predicate` for ontology predicate facts. Side effect: asserts edges in KB.",
516
- items: {
517
- type: "object",
518
- required: ["type", "from", "to"],
519
- properties: {
520
- type: {
521
- type: "string",
522
- enum: [
523
- "depends_on",
524
- "specified_by",
525
- "verified_by",
526
- "validates",
527
- "implements",
528
- "covered_by",
529
- "executable_for",
530
- "constrained_by",
531
- "constrains",
532
- "requires_property",
533
- "requires_predicate",
534
- "guards",
535
- "publishes",
536
- "consumes",
537
- "supersedes",
538
- "relates_to",
539
- ],
540
- description: "Relationship type enum. Use only supported values. Direction semantics follow KB model (e.g., implements symbol->req, verified_by req/scenario->test, executable_for symbol->test).",
541
- },
542
- from: {
543
- type: "string",
544
- description: "Source entity ID (must exist). Example: 'SYM-login-handler'.",
545
- },
546
- to: {
547
- type: "string",
548
- description: "Target entity ID (must exist). Example: 'REQ-001'.",
549
- },
550
- },
551
- },
552
- },
553
- },
554
- },
555
- },
556
- {
557
- name: "kb_validate_upsert",
558
- description: "Validate a kb_upsert payload without mutating the KB. Use this read-only preflight before kb_upsert, especially for requirements, because it returns schema/modeling errors plus semantic advisor receipts that identify prose likely needing kb_model_requirement, kb_suggest_predicates, ambiguity review, or an ontology-gap observation.",
559
- inputSchema: {
560
- type: "object",
561
- required: ["type", "id", "properties"],
562
- properties: {
563
- type: {
564
- type: "string",
565
- enum: [
566
- "req",
567
- "scenario",
568
- "test",
569
- "adr",
570
- "flag",
571
- "event",
572
- "symbol",
573
- "fact",
574
- ],
575
- },
576
- id: { type: "string" },
577
- properties: {
578
- type: "object",
579
- description: "Entity properties to validate using the same snake_case field names accepted by kb_upsert.",
580
- },
581
- relationships: {
582
- type: "array",
583
- items: { type: "object" },
584
- },
585
- },
586
- },
587
- },
588
- {
589
- name: "kb_delete",
590
- description: "Delete entities by ID. Use only for intentional removals after dependency checks. Do not use as a bulk cleanup shortcut. Side effects: mutates and saves KB; skips entities with dependents.",
591
- inputSchema: {
592
- type: "object",
593
- required: ["ids"],
594
- properties: {
595
- ids: {
596
- type: "array",
597
- items: { type: "string" },
598
- description: "Required list of entity IDs to delete. Example: ['REQ-001','TEST-002']. At least one ID is required.",
599
- },
600
- },
601
- },
602
- },
603
- {
604
- name: "kb_check",
605
- description: "Run KB validation rules and return violations. Use before or after mutations, and after meaningful source edits with impact options to surface symbol granularity and semantic-review diagnostics. Do not use for point lookups. No write side effects. Prefer explicit rules for faster iteration; omit rules for final full validation plus full-KB qualityDiagnostics review.",
606
- inputSchema: {
607
- type: "object",
608
- properties: {
609
- rules: {
610
- type: "array",
611
- items: {
612
- type: "string",
613
- enum: [
614
- "must-priority-coverage",
615
- "symbol-coverage",
616
- "symbol-traceability",
617
- "no-dangling-refs",
618
- "no-cycles",
619
- "required-fields",
620
- "deprecated-adr-no-successor",
621
- "domain-contradictions",
622
- "strict-fact-shape",
623
- "strict-req-fact-pairing",
624
- "predicate-verifiability",
625
- "query-plan-safety",
626
- ],
627
- },
628
- description: "Optional rule subset. Allowed: must-priority-coverage, symbol-coverage, symbol-traceability, no-dangling-refs, no-cycles, required-fields, deprecated-adr-no-successor, domain-contradictions, strict-fact-shape, strict-req-fact-pairing, predicate-verifiability, query-plan-safety. If omitted, server runs all rules plus the full-KB qualityDiagnostics audit scan; if supplied, server preserves scoped validation and skips the full-KB advisory scan.",
629
- },
630
- sourceFiles: {
631
- type: "array",
632
- items: { type: "string" },
633
- description: "Optional repo-relative source files to inspect for early impact diagnostics. Use with includeImpactDiagnostics after meaningful source edits.",
634
- },
635
- staged: {
636
- type: "boolean",
637
- description: "When true, inspect staged source changes for impact diagnostics using the shared CLI impact analyzer without shelling out to kibi check.",
638
- },
639
- includeWorkingTreeDiff: {
640
- type: "boolean",
641
- description: "When true, inspect current unstaged working-tree diffs for impact diagnostics. Pair with sourceFiles to scope the analysis.",
642
- },
643
- includeImpactDiagnostics: {
644
- type: "boolean",
645
- description: "When true, include changed-file impact diagnostics such as symbol_granularity_violation and symbol_semantic_review_needed in structured output.",
646
- },
647
- maxDiagnostics: {
648
- type: "integer",
649
- minimum: 0,
650
- description: "Optional maximum number of impact diagnostics to return. Graph validation violations are not capped by this value.",
651
- },
652
- workspaceRoot: {
653
- type: "string",
654
- description: "Optional workspace root for impact diagnostics and .kb/config.json lookup. Defaults to the MCP server workspace.",
655
- },
656
- },
657
- },
658
- },
659
- {
660
- name: "kb_model_requirement",
661
- description: "Convert a prose requirement plus optional extracted claim fields into a deterministic strict-lane write set. Read-only modeling returns a sequential applyPlan for later kb_upsert calls. High-confidence claims emit req+fact strict output; lower-confidence claims emit an observation review artifact. Includes migration warnings when legacy schemaVersion metadata is detected.",
662
- inputSchema: {
663
- type: "object",
664
- required: ["text"],
665
- properties: {
666
- text: {
667
- type: "string",
668
- description: "Required prose requirement text to model. Example: 'Customer data must be retained for 7 years.'",
669
- },
670
- source: {
671
- type: "string",
672
- description: "Optional primary source path or provenance root used for stable IDs and text refs. Example: 'documentation/requirements/customer-retention.md'.",
673
- },
674
- sourceFiles: {
675
- type: "array",
676
- items: { type: "string" },
677
- description: "Optional related source files. The first value is used as the source fallback when source is omitted.",
678
- },
679
- confidence: {
680
- type: "number",
681
- default: 0.8,
682
- minimum: 0,
683
- maximum: 1,
684
- description: "Confidence score for the extracted claim. >= 0.70 yields strict-lane output; lower confidence yields observation-only review output.",
685
- },
686
- subjectKey: {
687
- type: "string",
688
- description: "Optional extracted semantic claim subjectKey. Example: 'Customer.Data'.",
689
- },
690
- propertyKey: {
691
- type: "string",
692
- description: "Optional extracted semantic claim propertyKey. Example: 'Retention Years'.",
693
- },
694
- operator: {
695
- type: "string",
696
- enum: ["eq", "gte", "lte", "neq", "bool", "polarity"],
697
- description: "Optional extracted semantic claim operator. Example: 'eq'.",
698
- },
699
- value: {
700
- description: "Optional extracted semantic claim value. Accepts string, number, or boolean.",
701
- },
702
- provenance: {
703
- type: "string",
704
- description: "Optional extracted text reference. Falls back to source when omitted. Example: 'documentation/requirements/customer-retention.md#L1'.",
705
- },
706
- },
707
- },
708
- },
709
- {
710
- name: "kb_suggest_predicates",
711
- description: "Suggest ontology predicate schemas for prose requirements before agents write facts. Read-only guidance returns ranked candidates, a safe predicate-fact applyPlan, a separate requires_predicate relationshipPlan when a requirement ID is supplied, or an explicit ontology-gap observation when no predicate fits.",
712
- inputSchema: {
713
- type: "object",
714
- required: ["text"],
715
- properties: {
716
- text: {
717
- type: "string",
718
- description: "Required prose requirement or claim to classify into ontology predicates. Example: 'When users navigate away, draft edits must auto-save.'.",
719
- },
720
- requirementId: {
721
- type: "string",
722
- description: "Optional existing requirement ID. When provided, the response includes a relationshipPlan describing the req -> fact requires_predicate link to attach after preserving existing requirement metadata.",
723
- },
724
- source: {
725
- type: "string",
726
- description: "Optional provenance or text reference for generated predicate facts or ontology-gap observations.",
727
- },
728
- subjectHint: {
729
- type: "string",
730
- description: "Optional canonical subject key to use as the first predicate argument. Example: 'editor.annotation'.",
731
- },
732
- maxCandidates: {
733
- type: "integer",
734
- default: 5,
735
- minimum: 1,
736
- maximum: 20,
737
- description: "Maximum ranked predicate candidates to return. Default: 5.",
738
- },
739
- minScore: {
740
- type: "number",
741
- default: 0.35,
742
- minimum: 0,
743
- maximum: 1,
744
- description: "Minimum candidate score. Higher values make ontology-gap fallback more likely. Default: 0.35.",
745
- },
746
- includeExistingSchemas: {
747
- type: "boolean",
748
- default: true,
749
- description: "Whether to include existing KB fact_kind=predicate_schema facts alongside Kibi's built-in predicate catalog. Default: true.",
750
- },
751
- },
752
- },
753
- },
754
- {
755
- name: "kb_autopilot_generate",
756
- description: "Generate agent-centric bootstrap output for KB population. Read-only analysis that returns activation state, bootstrap guidance, candidate entities with evidence, payoff summary, and exact applyPlan payloads for later kb_upsert calls. No mutation side effects.",
757
- inputSchema: {
758
- type: "object",
759
- properties: {
760
- includeGenericMarkdown: {
761
- type: "boolean",
762
- default: true,
763
- description: "Whether to include generic markdown file content as candidate facts. Default: true.",
764
- },
765
- minConfidence: {
766
- type: "number",
767
- default: 0.8,
768
- minimum: 0.6,
769
- maximum: 0.95,
770
- description: "Minimum confidence threshold for candidates. Clamped to [0.60, 0.95]. Default: 0.80.",
771
- },
772
- maxCandidates: {
773
- type: "integer",
774
- default: 50,
775
- minimum: 1,
776
- maximum: 200,
777
- description: "Maximum number of candidates to return. Clamped to [1, 200]. Default: 50.",
778
- },
779
- entityTypes: {
780
- type: "array",
781
- items: {
782
- type: "string",
783
- enum: ["req", "scenario", "test", "adr", "fact", "symbol"],
784
- },
785
- description: "Optional filter to limit candidate generation to specific entity types.",
786
- },
787
- bootstrapContext: {
788
- type: "object",
789
- description: "Optional declared bootstrap context supplied by the agent to ground the read-only synthesis output.",
790
- properties: {
791
- projectSummary: {
792
- type: "string",
793
- description: "Optional short summary of the project or bootstrap goal.",
794
- },
795
- sourceOfTruthPaths: {
796
- type: "array",
797
- items: { type: "string" },
798
- description: "Optional repo-relative paths that should be treated as declared sources of truth.",
799
- },
800
- sourceOfTruthNotes: {
801
- type: "array",
802
- items: { type: "string" },
803
- description: "Optional notes about how to interpret the declared sources of truth.",
804
- },
805
- priorityRoots: {
806
- type: "array",
807
- items: { type: "string" },
808
- description: "Optional repo roots the bootstrap flow should prioritize when authoring entities.",
809
- },
810
- verificationAnchors: {
811
- type: "array",
812
- items: { type: "string" },
813
- description: "Optional verification commands, documents, or checkpoints to reference in the output.",
814
- },
815
- },
816
- },
817
- },
818
- },
819
- },
20
+ const MCP_TOOL_ORDER = [
21
+ "kb_query",
22
+ "kb_search",
23
+ "kb_status",
24
+ "kb_skills_list",
25
+ "kb_skills_load",
26
+ "kb_skills_read",
27
+ "kb_find_gaps",
28
+ "kb_coverage",
29
+ "kb_graph",
30
+ "kb_sparql_remote",
31
+ "kb_semantic_advisor",
32
+ "kb_upsert",
33
+ "kb_validate_upsert",
34
+ "kb_delete",
35
+ "kb_check",
36
+ "kb_model_requirement",
37
+ "kb_suggest_predicates",
38
+ "kb_autopilot_generate",
820
39
  ];
40
+ // implements REQ-002
41
+ const TOOL_ANNOTATIONS = {
42
+ kb_status: {
43
+ title: "Inspect Kibi branch status",
44
+ readOnlyHint: true,
45
+ destructiveHint: false,
46
+ idempotentHint: true,
47
+ openWorldHint: false,
48
+ },
49
+ kb_skills_list: {
50
+ title: "List bundled Kibi skills",
51
+ readOnlyHint: true,
52
+ destructiveHint: false,
53
+ idempotentHint: true,
54
+ openWorldHint: false,
55
+ },
56
+ kb_skills_load: {
57
+ title: "Load a bundled Kibi skill",
58
+ readOnlyHint: true,
59
+ destructiveHint: false,
60
+ idempotentHint: true,
61
+ openWorldHint: false,
62
+ },
63
+ kb_skills_read: {
64
+ title: "Read a bundled Kibi skill resource",
65
+ readOnlyHint: true,
66
+ destructiveHint: false,
67
+ idempotentHint: true,
68
+ openWorldHint: false,
69
+ },
70
+ kb_semantic_advisor: {
71
+ title: "Advise on Kibi requirement modeling",
72
+ readOnlyHint: true,
73
+ destructiveHint: false,
74
+ idempotentHint: true,
75
+ openWorldHint: false,
76
+ },
77
+ kb_suggest_predicates: {
78
+ title: "Suggest Kibi ontology predicates",
79
+ readOnlyHint: true,
80
+ destructiveHint: false,
81
+ idempotentHint: true,
82
+ openWorldHint: false,
83
+ },
84
+ };
85
+ const BASE_TOOLS = MCP_TOOL_ORDER.map((name) => {
86
+ const spec = getSpec(name);
87
+ return {
88
+ name: spec.name,
89
+ description: spec.description,
90
+ inputSchema: spec.businessInputSchema,
91
+ ...(TOOL_ANNOTATIONS[name] ? { annotations: TOOL_ANNOTATIONS[name] } : {}),
92
+ };
93
+ });
821
94
  /**
822
95
  * Inject _diagnostic_telemetry schema into tool inputs when diagnostic mode is enabled.
823
96
  * Exported for unit coverage; TOOLS still applies it only when the server starts
@@ -847,4 +120,4 @@ export function withDiagnosticTelemetrySchema(tools) {
847
120
  */
848
121
  export const TOOLS = DIAGNOSTIC_MODE_ENABLED
849
122
  ? withDiagnosticTelemetrySchema(BASE_TOOLS)
850
- : BASE_TOOLS;
123
+ : [...BASE_TOOLS];