@dikolab/kbdb 0.5.0 → 0.6.0

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 (224) hide show
  1. package/CLA.md +68 -0
  2. package/LICENSE +676 -12
  3. package/LICENSING.md +58 -0
  4. package/README.md +47 -24
  5. package/README.md.bak +320 -0
  6. package/dist/README.md +320 -0
  7. package/dist/{chunk-BJXEVALU.mjs → chunk-QLJ33C74.mjs} +44 -44
  8. package/dist/chunk-QLJ33C74.mjs.map +7 -0
  9. package/dist/cli.cjs +550 -232
  10. package/dist/cli.cjs.map +4 -4
  11. package/dist/cli.d.ts +0 -8
  12. package/dist/cli.mjs +483 -154
  13. package/dist/cli.mjs.map +4 -4
  14. package/dist/kbdb-worker.cjs +36 -5
  15. package/dist/kbdb-worker.cjs.map +3 -3
  16. package/dist/mod.cjs +89 -30
  17. package/dist/mod.cjs.map +4 -4
  18. package/dist/mod.mjs +88 -30
  19. package/dist/mod.mjs.map +4 -4
  20. package/dist/src/cli.d.ts +0 -8
  21. package/dist/src/shared/cli/constants/defaults.constant.d.ts +1 -1
  22. package/dist/src/shared/cli/constants/recfile-command-field-map.constant.d.ts +8 -0
  23. package/dist/src/shared/cli/constants/recfile-field-maps.constant.d.ts +21 -0
  24. package/dist/src/shared/cli/functions/compute-directory-level.function.d.ts +14 -0
  25. package/dist/src/shared/cli/functions/dispatch-command.function.d.ts +2 -28
  26. package/dist/src/shared/cli/functions/format-command-output.function.d.ts +14 -0
  27. package/dist/src/shared/cli/functions/format-db-not-found.function.d.ts +20 -0
  28. package/dist/src/shared/cli/functions/format-output.function.d.ts +1 -0
  29. package/dist/src/shared/cli/functions/format-recfile-output.function.d.ts +11 -0
  30. package/dist/src/shared/cli/functions/render-recfile-value.function.d.ts +11 -0
  31. package/dist/src/shared/cli/functions/resolve-db-dir.function.d.ts +24 -0
  32. package/dist/src/shared/cli/functions/resolve-recfile-key.function.d.ts +9 -0
  33. package/dist/src/shared/cli/functions/run-db-path.function.d.ts +10 -0
  34. package/dist/src/shared/cli/functions/run-export.function.d.ts +8 -4
  35. package/dist/src/shared/cli/functions/run-import.function.d.ts +4 -0
  36. package/dist/src/shared/cli/functions/run-learn.function.d.ts +12 -0
  37. package/dist/src/shared/cli/index.d.ts +4 -1
  38. package/dist/src/shared/cli/typings/cli-options.interface.d.ts +9 -2
  39. package/dist/src/shared/cli/typings/db-resolution.interface.d.ts +9 -0
  40. package/dist/src/shared/cli/typings/recfile-field-map.type.d.ts +10 -0
  41. package/dist/src/shared/version/constants/version.constant.d.ts +1 -1
  42. package/dist/src/shared/wasm-codec/functions/decode-option-u8.function.d.ts +9 -0
  43. package/dist/src/shared/wasm-codec/functions/decode-section-records.function.d.ts +4 -0
  44. package/dist/src/shared/wasm-codec/functions/encode-add-section-params.function.d.ts +2 -45
  45. package/dist/src/shared/wasm-codec/functions/encode-update-section-params.function.d.ts +10 -1
  46. package/dist/src/shared/wasm-codec/index.d.ts +1 -1
  47. package/dist/src/shared/wasm-codec/typings/add-section-input.model.d.ts +6 -0
  48. package/dist/src/shared/wasm-codec/typings/section-record-trailing.model.d.ts +5 -0
  49. package/dist/src/shared/wasm-codec/typings/section-record.model.d.ts +5 -0
  50. package/dist/src/shared/worker-client/functions/build-deno-permissions.function.d.ts +11 -0
  51. package/dist/src/shared/worker-client/functions/read-crash-reason.function.d.ts +9 -0
  52. package/dist/src/shared/worker-client/functions/resolve-spawn-script.function.d.ts +6 -0
  53. package/dist/src/shared/worker-client/functions/spawn-daemon.function.d.ts +1 -1
  54. package/dist/src/shared/worker-client/typings/section.model.d.ts +5 -0
  55. package/dist/src/shared/worker-client/typings/worker-client-options.interface.d.ts +0 -6
  56. package/dist/src/shared/worker-daemon/functions/count-files.function.d.ts +12 -0
  57. package/dist/src/shared/worker-daemon/functions/handle-import.function.d.ts +2 -0
  58. package/dist/src/shared/worker-daemon/functions/handle-read-ops.function.d.ts +8 -0
  59. package/dist/src/shared/worker-daemon/functions/validate-daemon-path.function.d.ts +15 -0
  60. package/dist/src/worker.d.ts +0 -7
  61. package/dist/wasm/default-embedding/kbdb_default_embedding_bg.wasm +0 -0
  62. package/dist/wasm/default-embedding/package.json +1 -1
  63. package/dist/wasm/fs-database/kbdb_fs_database_bg.wasm +0 -0
  64. package/dist/wasm/fs-database/package.json +1 -1
  65. package/dist/wasm/fs-migration/package.json +1 -1
  66. package/dist/wasm/kb-worker/kbdb_worker_bg.wasm +0 -0
  67. package/dist/wasm/kb-worker/package.json +1 -1
  68. package/dist/wasm/query-parser/kbdb_query_parser_bg.wasm +0 -0
  69. package/dist/wasm/query-parser/package.json +1 -1
  70. package/dist/worker.d.ts +0 -7
  71. package/dist/worker.mjs +37 -6
  72. package/dist/worker.mjs.map +3 -3
  73. package/package.json +10 -9
  74. package/dist/chunk-BJXEVALU.mjs.map +0 -7
  75. package/dist/src/shared/cli/functions/resolve-raw-db-path.function.d.ts +0 -10
  76. package/docs/details/README.md +0 -30
  77. package/docs/details/agent-tooling.md +0 -132
  78. package/docs/details/cli.md +0 -777
  79. package/docs/details/knowledge-base.md +0 -180
  80. package/docs/details/library-api.md +0 -495
  81. package/docs/details/mcp-server.md +0 -482
  82. package/docs/details/search-and-ranking.md +0 -575
  83. package/docs/details/storage.md +0 -531
  84. package/docs/goals/agents.md +0 -751
  85. package/docs/goals/architecture.svg +0 -198
  86. package/docs/goals/auto-capture.md +0 -378
  87. package/docs/goals/benchmarking.md +0 -296
  88. package/docs/goals/cli.md +0 -2654
  89. package/docs/goals/concurrency.md +0 -259
  90. package/docs/goals/content-composer.md +0 -609
  91. package/docs/goals/content-parser.md +0 -279
  92. package/docs/goals/database.md +0 -1679
  93. package/docs/goals/document.md +0 -368
  94. package/docs/goals/hybrid-search.md +0 -465
  95. package/docs/goals/mcp.md +0 -1541
  96. package/docs/goals/overview.md +0 -124
  97. package/docs/goals/query-parser.md +0 -373
  98. package/docs/goals/query-result.md +0 -860
  99. package/docs/goals/semantic-dedup.md +0 -233
  100. package/docs/goals/skills.md +0 -810
  101. package/docs/goals/sync.md +0 -217
  102. package/docs/goals/worker-client.md +0 -1005
  103. package/docs/goals/worker-daemon.md +0 -1547
  104. package/docs/modules/overview.md +0 -319
  105. package/docs/modules/rust/embedding/module.md +0 -91
  106. package/docs/modules/rust/fs-database/functions/document.md +0 -48
  107. package/docs/modules/rust/fs-database/functions/integrity.md +0 -79
  108. package/docs/modules/rust/fs-database/functions/io.md +0 -87
  109. package/docs/modules/rust/fs-database/functions/module.md +0 -22
  110. package/docs/modules/rust/fs-database/functions/query-exec.md +0 -44
  111. package/docs/modules/rust/fs-database/functions/section.md +0 -76
  112. package/docs/modules/rust/fs-database/indexes/btree.md +0 -35
  113. package/docs/modules/rust/fs-database/indexes/corpus.md +0 -61
  114. package/docs/modules/rust/fs-database/indexes/inverted.md +0 -60
  115. package/docs/modules/rust/fs-database/indexes/module.md +0 -64
  116. package/docs/modules/rust/fs-database/indexes/positional.md +0 -39
  117. package/docs/modules/rust/fs-database/indexes/vectors.md +0 -110
  118. package/docs/modules/rust/fs-database/module.md +0 -150
  119. package/docs/modules/rust/fs-database/types/catalog.md +0 -53
  120. package/docs/modules/rust/fs-database/types/module.md +0 -12
  121. package/docs/modules/rust/fs-database/types/section.md +0 -127
  122. package/docs/modules/rust/kb-worker/functions/compose.md +0 -57
  123. package/docs/modules/rust/kb-worker/functions/module.md +0 -20
  124. package/docs/modules/rust/kb-worker/functions/retrieve.md +0 -194
  125. package/docs/modules/rust/kb-worker/functions/search.md +0 -173
  126. package/docs/modules/rust/kb-worker/functions/write.md +0 -172
  127. package/docs/modules/rust/kb-worker/module.md +0 -171
  128. package/docs/modules/rust/kb-worker/types/cache.md +0 -90
  129. package/docs/modules/rust/kb-worker/types/context.md +0 -26
  130. package/docs/modules/rust/kb-worker/types/module.md +0 -16
  131. package/docs/modules/rust/kb-worker/types/status.md +0 -29
  132. package/docs/modules/rust/kb-worker/types/token.md +0 -50
  133. package/docs/modules/rust/overview.md +0 -531
  134. package/docs/modules/rust/query-parser/functions/extract.md +0 -56
  135. package/docs/modules/rust/query-parser/functions/module.md +0 -18
  136. package/docs/modules/rust/query-parser/functions/parse.md +0 -33
  137. package/docs/modules/rust/query-parser/functions/pipeline.md +0 -9
  138. package/docs/modules/rust/query-parser/functions/rank.md +0 -85
  139. package/docs/modules/rust/query-parser/module.md +0 -131
  140. package/docs/modules/rust/query-parser/types/cache.md +0 -39
  141. package/docs/modules/rust/query-parser/types/keyphrase.md +0 -71
  142. package/docs/modules/rust/query-parser/types/module.md +0 -18
  143. package/docs/modules/rust/query-parser/types/token.md +0 -46
  144. package/docs/modules/rust/shared/content-composer/functions.md +0 -114
  145. package/docs/modules/rust/shared/content-composer/module.md +0 -147
  146. package/docs/modules/rust/shared/content-composer/types.md +0 -93
  147. package/docs/modules/rust/shared/content-parser/functions.md +0 -72
  148. package/docs/modules/rust/shared/content-parser/module.md +0 -99
  149. package/docs/modules/rust/shared/content-parser/types.md +0 -71
  150. package/docs/modules/rust/shared/corpus/module.md +0 -24
  151. package/docs/modules/rust/shared/corpus/types.md +0 -141
  152. package/docs/modules/rust/shared/document/module.md +0 -25
  153. package/docs/modules/rust/shared/document/types.md +0 -154
  154. package/docs/modules/rust/shared/encode/module.md +0 -22
  155. package/docs/modules/rust/shared/encode/traits.md +0 -304
  156. package/docs/modules/rust/shared/error/module.md +0 -28
  157. package/docs/modules/rust/shared/error/types.md +0 -302
  158. package/docs/modules/rust/shared/kbid/module.md +0 -24
  159. package/docs/modules/rust/shared/kbid/types.md +0 -147
  160. package/docs/modules/rust/shared/memory/functions.md +0 -209
  161. package/docs/modules/rust/shared/memory/module.md +0 -24
  162. package/docs/modules/rust/shared/module.md +0 -196
  163. package/docs/modules/rust/shared/pipeline/functions.md +0 -141
  164. package/docs/modules/rust/shared/pipeline/module.md +0 -62
  165. package/docs/modules/rust/shared/pipeline/types.md +0 -43
  166. package/docs/modules/rust/shared/query/module.md +0 -27
  167. package/docs/modules/rust/shared/query/types.md +0 -236
  168. package/docs/modules/rust/shared/section/module.md +0 -25
  169. package/docs/modules/rust/shared/section/types.md +0 -294
  170. package/docs/modules/rust/shared/term/module.md +0 -25
  171. package/docs/modules/rust/shared/term/types.md +0 -139
  172. package/docs/modules/typescript/cli.md +0 -131
  173. package/docs/modules/typescript/kbdb-worker.md +0 -150
  174. package/docs/modules/typescript/overview.md +0 -400
  175. package/docs/modules/typescript/shared/auto-capture/module.md +0 -73
  176. package/docs/modules/typescript/shared/cli/constants.md +0 -23
  177. package/docs/modules/typescript/shared/cli/functions.md +0 -809
  178. package/docs/modules/typescript/shared/cli/module.md +0 -138
  179. package/docs/modules/typescript/shared/cli/typings.md +0 -197
  180. package/docs/modules/typescript/shared/embedding/functions.md +0 -200
  181. package/docs/modules/typescript/shared/embedding/module.md +0 -77
  182. package/docs/modules/typescript/shared/embedding/typings.md +0 -124
  183. package/docs/modules/typescript/shared/hash/functions.md +0 -20
  184. package/docs/modules/typescript/shared/hash/module.md +0 -21
  185. package/docs/modules/typescript/shared/log/constants.md +0 -82
  186. package/docs/modules/typescript/shared/log/functions.md +0 -131
  187. package/docs/modules/typescript/shared/log/module.md +0 -153
  188. package/docs/modules/typescript/shared/log/typings.md +0 -82
  189. package/docs/modules/typescript/shared/mcp/classes.md +0 -179
  190. package/docs/modules/typescript/shared/mcp/functions.md +0 -386
  191. package/docs/modules/typescript/shared/mcp/module.md +0 -160
  192. package/docs/modules/typescript/shared/mcp/typings.md +0 -529
  193. package/docs/modules/typescript/shared/module.md +0 -110
  194. package/docs/modules/typescript/shared/platform/functions.md +0 -42
  195. package/docs/modules/typescript/shared/platform/module.md +0 -25
  196. package/docs/modules/typescript/shared/runtime/functions.md +0 -26
  197. package/docs/modules/typescript/shared/runtime/module.md +0 -27
  198. package/docs/modules/typescript/shared/runtime/typings.md +0 -13
  199. package/docs/modules/typescript/shared/version/module.md +0 -27
  200. package/docs/modules/typescript/shared/wasm-codec/functions.md +0 -391
  201. package/docs/modules/typescript/shared/wasm-codec/module.md +0 -98
  202. package/docs/modules/typescript/shared/worker-client/classes.md +0 -264
  203. package/docs/modules/typescript/shared/worker-client/functions.md +0 -175
  204. package/docs/modules/typescript/shared/worker-client/module.md +0 -92
  205. package/docs/modules/typescript/shared/worker-client/typings.md +0 -511
  206. package/docs/modules/typescript/shared/worker-daemon/classes.md +0 -239
  207. package/docs/modules/typescript/shared/worker-daemon/constants.md +0 -37
  208. package/docs/modules/typescript/shared/worker-daemon/functions.md +0 -234
  209. package/docs/modules/typescript/shared/worker-daemon/module.md +0 -118
  210. package/docs/modules/typescript/shared/worker-daemon/typings.md +0 -132
  211. package/docs/overview.md +0 -191
  212. package/docs/release-notes/0.1.0.md +0 -189
  213. package/docs/release-notes/0.1.1.md +0 -46
  214. package/docs/release-notes/0.1.2.md +0 -38
  215. package/docs/release-notes/0.1.3.md +0 -42
  216. package/docs/release-notes/0.2.0.md +0 -147
  217. package/docs/release-notes/0.3.0.md +0 -89
  218. package/docs/release-notes/0.3.1.md +0 -121
  219. package/docs/release-notes/0.3.2.md +0 -64
  220. package/docs/release-notes/0.4.0.md +0 -80
  221. package/docs/release-notes/0.4.1.md +0 -149
  222. package/docs/release-notes/0.4.3.md +0 -60
  223. package/docs/release-notes/0.5.0.md +0 -41
  224. package/docs/release-notes/README.md +0 -16
@@ -1,160 +0,0 @@
1
- # mcp -- MCP Server Module
2
-
3
- *Long-lived MCP server over stdio. Routes tool and
4
- resource requests to the worker daemon via the
5
- worker-client module.*
6
-
7
- ## Source
8
-
9
- `src/shared/mcp/`
10
-
11
- ## Responsibility
12
-
13
- Starts an MCP server that listens on stdin and writes
14
- responses to stdout using JSON-RPC 2.0 (protocol
15
- version **2025-11-25**). On startup it creates a
16
- `WorkerClient` to connect to the worker daemon. All
17
- incoming MCP tool calls and resource reads are routed
18
- through that client. The MCP module does **not**
19
- perform keyword extraction, indexing, ranking, or
20
- database I/O itself.
21
-
22
- See [MCP](../../../../goals/mcp.md) for the full
23
- behavioral specification.
24
-
25
- ## Directory Layout
26
-
27
- ```
28
- src/shared/mcp/
29
- ├── index.ts
30
- ├── classes/
31
- │ └── mcp-server.class.ts
32
- ├── constants/
33
- │ └── mcp-error-codes.constant.ts
34
- ├── functions/
35
- │ ├── create-mcp-server.function.ts
36
- │ ├── create-prompt-definitions.function.ts
37
- │ ├── create-resource-templates.function.ts
38
- │ ├── create-tool-definitions.function.ts
39
- │ ├── handle-agent-create.function.ts
40
- │ ├── handle-agent-delete.function.ts
41
- │ ├── handle-agent-get.function.ts
42
- │ ├── handle-agent-list.function.ts
43
- │ ├── handle-completion.function.ts
44
- │ ├── handle-prompt-get.function.ts
45
- │ ├── handle-recall.function.ts
46
- │ ├── handle-resource-read.function.ts
47
- │ ├── handle-skill-delete.function.ts
48
- │ ├── handle-skill-get.function.ts
49
- │ ├── handle-skill-learn.function.ts
50
- │ ├── handle-skill-list.function.ts
51
- │ ├── handle-tool-call.function.ts
52
- │ ├── parse-skill-content.function.ts
53
- │ └── serialize-skill-content.function.ts
54
- ├── typings/
55
- │ ├── mcp-client.interface.ts
56
- │ ├── mcp-types.interface.ts
57
- │ └── remove-section-result.model.ts
58
- ├── tests/
59
- │ └── mcp-protocol.spec.ts
60
- └── *.spec.ts
61
- ```
62
-
63
- ## Exports
64
-
65
- - **[classes.md](classes.md)** -- `McpServer`.
66
- - **[functions.md](functions.md)** --
67
- `createMcpServer`, `createToolDefinitions`,
68
- `createPromptDefinitions`, `createResourceTemplates`,
69
- `handleToolCall`, `handleResourceRead`,
70
- `handlePromptGet`, `handleCompletion`,
71
- `parseSkillContent`, `serializeSkillContent`,
72
- `handleSkillLearn`, `handleSkillList`,
73
- `handleSkillGet`, `handleSkillDelete`,
74
- `handleAgentCreate`, `handleAgentList`,
75
- `handleAgentGet`, `handleAgentDelete`,
76
- `handleRecall`.
77
- - **[typings.md](typings.md)** -- `McpWorkerClient`,
78
- `McpRequest`, `McpResponse`, `McpNotification`,
79
- `McpToolDefinition`, `McpResourceTemplate`,
80
- `McpServerInfo`, `McpCapabilities`, `McpToolResult`,
81
- `McpResourceResult`, `RemoveSectionResult`,
82
- `McpPrompt`, `McpPromptArgument`, `McpPromptMessage`,
83
- `McpPromptMessageContent`, `McpToolAnnotations`,
84
- `McpCompletionRef`, `McpCompletionResult`,
85
- `McpLogLevel`, `McpLogMessage`, `SkillDefinition`,
86
- `SkillArgument`, `AgentDefinition`.
87
- - **Error code constants**: `PARSE_ERROR`,
88
- `METHOD_NOT_FOUND`, `INVALID_PARAMS`,
89
- `INTERNAL_ERROR`, `RESOURCE_NOT_FOUND`.
90
-
91
- ## Execution Flow
92
-
93
- ```
94
- cli.ts (entry point, MCP mode)
95
-
96
- ├─ detect runtime (Deno / Node)
97
- ├─ resolve db path (--db flag or KBDB_DB_DIR env or cwd)
98
- ├─ createWorkerClient({ targetDir })
99
- ├─ createMcpServer(client)
100
- │ └─ returns McpServer
101
- ├─ server.listen()
102
- │ ├─ opens stdio transport
103
- │ ├─ reads JSON-RPC 2.0 requests from stdin
104
- │ ├─ pre-init guard: rejects all methods except
105
- │ │ initialize and ping until
106
- │ │ notifications/initialized received
107
- │ ├─ routes protocol messages:
108
- │ │ ├─ initialize → version 2025-11-25
109
- │ │ ├─ ping → {}
110
- │ │ ├─ notifications/initialized → sets flag
111
- │ │ └─ notifications/cancelled → ignored
112
- │ ├─ routes tool calls via handleToolCall:
113
- │ │ ├─ search → client.search(params)
114
- │ │ ├─ learn → client.addSection(params)
115
- │ │ ├─ unlearn → client.removeSection(kbid)
116
- │ │ ├─ retrieve → client.readSections(kbids)
117
- │ │ │ or client.retrieveDocument(docid)
118
- │ │ ├─ recall → handleRecall(params, client)
119
- │ │ ├─ status → client.dbStatus()
120
- │ │ ├─ skill-learn → handleSkillLearn(params, client)
121
- │ │ ├─ skill-list → handleSkillList(client)
122
- │ │ ├─ skill-get → handleSkillGet(params, client)
123
- │ │ ├─ skill-delete → handleSkillDelete(params, client)
124
- │ │ ├─ agent-create → handleAgentCreate(params, client)
125
- │ │ ├─ agent-list → handleAgentList(client)
126
- │ │ ├─ agent-get → handleAgentGet(params, client)
127
- │ │ └─ agent-delete → handleAgentDelete(params, client)
128
- │ ├─ routes prompt requests:
129
- │ │ ├─ prompts/list → createPromptDefinitions(sections)
130
- │ │ └─ prompts/get → handlePromptGet(name, args, client)
131
- │ ├─ routes completion requests:
132
- │ │ └─ completion/complete → handleCompletion(ref, arg, client)
133
- │ ├─ routes resource requests:
134
- │ │ ├─ resources/list → { resources: [] }
135
- │ │ ├─ resources/templates/list → URI templates
136
- │ │ ├─ resources/subscribe → add URI to subscriptions
137
- │ │ ├─ resources/unsubscribe → remove URI from subscriptions
138
- │ │ └─ resources/read → handleResourceRead
139
- │ │ ├─ kbdb://section/{kbid}
140
- │ │ └─ kbdb://document/{docid}
141
- │ ├─ routes logging and roots:
142
- │ │ ├─ logging/setLevel → stores logLevel
143
- │ │ └─ roots/list → returns .kbdb URI
144
- │ └─ writes JSON-RPC 2.0 responses to stdout
145
- └─ on stdin close:
146
- └─ client.disconnect()
147
- ```
148
-
149
- ## Transport
150
-
151
- The MCP server uses **stdio** transport:
152
-
153
- - Reads JSON-RPC 2.0 requests from **stdin**.
154
- - Writes JSON-RPC 2.0 responses to **stdout**.
155
- - Diagnostic messages go to **stderr**.
156
-
157
- The AI agent host (Claude Desktop, Claude Code, or
158
- any MCP-compatible client) spawns `kbdb mcp` as a
159
- child process and communicates over its stdin/stdout
160
- streams.
@@ -1,529 +0,0 @@
1
- # mcp/typings -- MCP Type Definitions
2
-
3
- *Interfaces and type aliases for the MCP server's
4
- JSON-RPC protocol and worker client contract.*
5
-
6
- ## Source
7
-
8
- `src/shared/mcp/typings/`
9
-
10
- ## Typings
11
-
12
- ### `McpWorkerClient`
13
-
14
- **File:** `mcp-client.interface.ts`
15
-
16
- Interface for the worker client dependency consumed
17
- by the MCP server. Defines the knowledge-base
18
- operations the server exposes as MCP tools and
19
- resources without coupling to the concrete
20
- `WorkerClient` class.
21
-
22
- ```ts
23
- interface McpWorkerClient {
24
- search(params: {
25
- readonly query: string;
26
- readonly mode?: string;
27
- readonly limit?: number;
28
- readonly content?: boolean;
29
- readonly offset?: number;
30
- }): Promise<PagedSearchResult>;
31
-
32
- addSection(params: {
33
- readonly type: string;
34
- readonly content: string;
35
- readonly title?: string;
36
- readonly description?: string;
37
- readonly docid?: string;
38
- }): Promise<string>;
39
-
40
- removeSection(kbid: string): Promise<RemoveSectionResult>;
41
-
42
- readSections(
43
- kbids: string[],
44
- ): Promise<Section[]>;
45
-
46
- retrieveDocument(
47
- docid: string,
48
- ): Promise<unknown>;
49
-
50
- listByType(
51
- sectionType: string,
52
- ): Promise<Section[]>;
53
-
54
- listDocumentsByType(
55
- docType: string,
56
- ): Promise<unknown[]>;
57
-
58
- recall(params: {
59
- readonly kbid?: string;
60
- readonly kbids?: readonly string[];
61
- readonly depth?: number;
62
- }): Promise<RecallResult | RecallResult[]>;
63
-
64
- dbStatus(): Promise<{
65
- initialized: boolean;
66
- contextPath: string;
67
- cacheStats: {
68
- contentCount: number;
69
- indexCount: number;
70
- };
71
- }>;
72
-
73
- disconnect(): void;
74
- }
75
- ```
76
-
77
- | Method | Description |
78
- |-------------------------|-----------------------------------|
79
- | `listByType` | Returns all sections whose |
80
- | | `sectionType` matches the given |
81
- | | value (e.g. `'skill'`) |
82
- | `listDocumentsByType` | Returns all document manifests |
83
- | | whose `type` field matches (e.g. |
84
- | | `'agent'`) |
85
-
86
- ### `RemoveSectionResult`
87
-
88
- **File:** `remove-section-result.model.ts`
89
-
90
- Result returned by `McpWorkerClient.removeSection`.
91
- Reports whether the section was found and removed
92
- and the elapsed operation time.
93
-
94
- ```ts
95
- interface RemoveSectionResult {
96
- readonly removed: boolean;
97
- readonly elapsed_ms: number;
98
- }
99
- ```
100
-
101
- ### `McpRequest`
102
-
103
- **File:** `mcp-types.interface.ts`
104
-
105
- A JSON-RPC 2.0 request message sent to the MCP
106
- server. The `id` field is absent for notifications.
107
-
108
- ```ts
109
- interface McpRequest {
110
- readonly jsonrpc: '2.0';
111
- readonly id?: number | string;
112
- readonly method: string;
113
- readonly params?: Record<string, unknown>;
114
- }
115
- ```
116
-
117
- ### `McpResponse`
118
-
119
- **File:** `mcp-types.interface.ts`
120
-
121
- A JSON-RPC 2.0 response message. Contains either
122
- `result` (success) or `error` (failure), never both.
123
-
124
- ```ts
125
- interface McpResponse {
126
- readonly jsonrpc: '2.0';
127
- readonly id: number | string;
128
- readonly result?: unknown;
129
- readonly error?: {
130
- readonly code: number;
131
- readonly message: string;
132
- readonly data?: unknown;
133
- };
134
- }
135
- ```
136
-
137
- ### `McpNotification`
138
-
139
- **File:** `mcp-types.interface.ts`
140
-
141
- A JSON-RPC 2.0 notification with no `id` and no
142
- expected response.
143
-
144
- ```ts
145
- interface McpNotification {
146
- readonly jsonrpc: '2.0';
147
- readonly method: string;
148
- readonly params?: Record<string, unknown>;
149
- }
150
- ```
151
-
152
- ### `McpToolDefinition`
153
-
154
- **File:** `mcp-types.interface.ts`
155
-
156
- Definition of a single MCP tool exposed by the
157
- server via `tools/list`.
158
-
159
- ```ts
160
- interface McpToolDefinition {
161
- readonly name: string;
162
- readonly description: string;
163
- readonly inputSchema: Record<string, unknown>;
164
- readonly annotations?: McpToolAnnotations;
165
- }
166
- ```
167
-
168
- The optional `annotations` field carries hints for
169
- MCP clients about the tool's side effects and safety
170
- characteristics.
171
-
172
- ### `McpResourceTemplate`
173
-
174
- **File:** `mcp-types.interface.ts`
175
-
176
- A URI template describing an MCP resource served
177
- via `resources/templates/list`.
178
-
179
- ```ts
180
- interface McpResourceTemplate {
181
- readonly uriTemplate: string;
182
- readonly name: string;
183
- readonly description: string;
184
- readonly mimeType?: string;
185
- }
186
- ```
187
-
188
- ### `McpServerInfo`
189
-
190
- **File:** `mcp-types.interface.ts`
191
-
192
- Identity information for the MCP server, reported
193
- in the `initialize` response.
194
-
195
- ```ts
196
- interface McpServerInfo {
197
- readonly name: string;
198
- readonly version: string;
199
- }
200
- ```
201
-
202
- ### `McpCapabilities`
203
-
204
- **File:** `mcp-types.interface.ts`
205
-
206
- MCP capability flags advertised during
207
- initialization. Each key enables a group of methods.
208
-
209
- ```ts
210
- interface McpCapabilities {
211
- readonly tools?: Record<string, never>;
212
- readonly resources?: Record<string, never>;
213
- readonly prompts?: Record<string, never>;
214
- readonly logging?: Record<string, never>;
215
- readonly completions?: Record<string, never>;
216
- }
217
- ```
218
-
219
- | Key | Methods enabled |
220
- |---------------|------------------------------------------|
221
- | `tools` | `tools/list`, `tools/call` |
222
- | `resources` | `resources/list`, `resources/read`, etc. |
223
- | `prompts` | `prompts/list`, `prompts/get` |
224
- | `logging` | `logging/setLevel` |
225
- | `completions` | `completion/complete` |
226
-
227
- ### `McpToolResult`
228
-
229
- **File:** `mcp-types.interface.ts`
230
-
231
- Result returned by `handleToolCall`. Tool-level
232
- errors use `isError: true` in the result rather than
233
- JSON-RPC error responses.
234
-
235
- ```ts
236
- interface McpToolResult {
237
- readonly content: readonly {
238
- readonly type: string;
239
- readonly text: string;
240
- }[];
241
- readonly isError?: boolean;
242
- }
243
- ```
244
-
245
- ### `McpResourceResult`
246
-
247
- **File:** `mcp-types.interface.ts`
248
-
249
- Result returned by `handleResourceRead`.
250
-
251
- ```ts
252
- interface McpResourceResult {
253
- readonly contents: readonly {
254
- readonly uri: string;
255
- readonly mimeType: string;
256
- readonly text: string;
257
- }[];
258
- }
259
- ```
260
-
261
- ### `McpPrompt`
262
-
263
- **File:** `mcp-types.interface.ts`
264
-
265
- A single prompt entry returned by `prompts/list`.
266
- Skills use `name` directly; agents use `agent:<name>`.
267
-
268
- ```ts
269
- interface McpPrompt {
270
- readonly name: string;
271
- readonly description?: string;
272
- readonly arguments?: readonly McpPromptArgument[];
273
- }
274
- ```
275
-
276
- | Property | Description |
277
- |---------------|--------------------------------------|
278
- | `name` | Prompt name (or `agent:<name>`) |
279
- | `description` | Human-readable description |
280
- | `arguments` | Accepted arguments for the prompt |
281
-
282
- ### `McpPromptArgument`
283
-
284
- **File:** `mcp-types.interface.ts`
285
-
286
- A single argument accepted by an MCP prompt.
287
-
288
- ```ts
289
- interface McpPromptArgument {
290
- readonly name: string;
291
- readonly description?: string;
292
- readonly required?: boolean;
293
- }
294
- ```
295
-
296
- | Property | Description |
297
- |---------------|-----------------------------------|
298
- | `name` | Argument identifier |
299
- | `description` | Human-readable hint |
300
- | `required` | Whether the argument is required |
301
-
302
- ### `McpPromptMessage`
303
-
304
- **File:** `mcp-types.interface.ts`
305
-
306
- A single message in the array returned by `prompts/get`.
307
-
308
- ```ts
309
- interface McpPromptMessage {
310
- readonly role: 'user' | 'assistant';
311
- readonly content: McpPromptMessageContent;
312
- }
313
- ```
314
-
315
- ### `McpPromptMessageContent`
316
-
317
- **File:** `mcp-types.interface.ts`
318
-
319
- Content body of an `McpPromptMessage`.
320
-
321
- ```ts
322
- interface McpPromptMessageContent {
323
- readonly type: 'text';
324
- readonly text: string;
325
- }
326
- ```
327
-
328
- ### `McpToolAnnotations`
329
-
330
- **File:** `mcp-types.interface.ts`
331
-
332
- Hints for MCP clients about a tool's side effects
333
- and safety characteristics.
334
-
335
- ```ts
336
- interface McpToolAnnotations {
337
- readonly title?: string;
338
- readonly readOnlyHint?: boolean;
339
- readonly destructiveHint?: boolean;
340
- readonly idempotentHint?: boolean;
341
- readonly openWorldHint?: boolean;
342
- }
343
- ```
344
-
345
- | Property | Description |
346
- |-------------------|------------------------------------|
347
- | `title` | Human-readable tool title |
348
- | `readOnlyHint` | `true` if the tool only reads data |
349
- | `destructiveHint` | `true` if the tool deletes data |
350
- | `idempotentHint` | `true` if repeated calls are safe |
351
- | `openWorldHint` | `true` if side effects may extend |
352
- | | outside the knowledge base |
353
-
354
- ### `McpCompletionRef`
355
-
356
- **File:** `mcp-types.interface.ts`
357
-
358
- Reference descriptor sent with a `completion/complete`
359
- request, identifying the kind of value to complete.
360
-
361
- ```ts
362
- interface McpCompletionRef {
363
- readonly type: 'ref/prompt' | 'ref/resource';
364
- readonly name?: string;
365
- readonly uri?: string;
366
- }
367
- ```
368
-
369
- | Property | Description |
370
- |----------|----------------------------------------------|
371
- | `type` | `'ref/prompt'` to complete prompt names; |
372
- | | `'ref/resource'` to complete resource URIs |
373
- | `name` | Prompt name prefix (for `ref/prompt`) |
374
- | `uri` | Resource URI prefix (for `ref/resource`) |
375
-
376
- ### `McpCompletionResult`
377
-
378
- **File:** `mcp-types.interface.ts`
379
-
380
- Result returned by `handleCompletion`.
381
-
382
- ```ts
383
- interface McpCompletionResult {
384
- readonly completion: {
385
- readonly values: readonly string[];
386
- readonly hasMore?: boolean;
387
- readonly total?: number;
388
- };
389
- }
390
- ```
391
-
392
- | Property | Description |
393
- |--------------------|----------------------------------|
394
- | `completion.values`| Matching completion strings |
395
- | `completion.hasMore` | More results exist beyond this list |
396
- | `completion.total` | Total number of matches |
397
-
398
- ### `McpLogLevel`
399
-
400
- **File:** `mcp-types.interface.ts`
401
-
402
- MCP log severity levels as defined in the MCP spec.
403
-
404
- ```ts
405
- type McpLogLevel =
406
- | 'debug'
407
- | 'info'
408
- | 'notice'
409
- | 'warning'
410
- | 'error'
411
- | 'critical'
412
- | 'alert'
413
- | 'emergency';
414
- ```
415
-
416
- ### `McpLogMessage`
417
-
418
- **File:** `mcp-types.interface.ts`
419
-
420
- Parameters for a `notifications/message` server
421
- notification.
422
-
423
- ```ts
424
- interface McpLogMessage {
425
- readonly level: McpLogLevel;
426
- readonly logger?: string;
427
- readonly data?: unknown;
428
- }
429
- ```
430
-
431
- | Property | Description |
432
- |----------|----------------------------------------|
433
- | `level` | Severity level of the log entry |
434
- | `logger` | Optional logger name (e.g. `'kbdb'`) |
435
- | `data` | Log message or structured data |
436
-
437
- ### `SkillDefinition`
438
-
439
- **File:** `mcp-types.interface.ts`
440
-
441
- A complete skill definition as stored in the knowledge
442
- base and returned by skill retrieval operations.
443
-
444
- ```ts
445
- interface SkillDefinition {
446
- readonly name: string;
447
- readonly description: string;
448
- readonly arguments?: readonly SkillArgument[];
449
- readonly body: string;
450
- }
451
- ```
452
-
453
- | Property | Description |
454
- |---------------|---------------------------------------|
455
- | `name` | Skill name in kebab-case |
456
- | `description` | What the skill does |
457
- | `arguments` | Auto-detected template arguments |
458
- | `body` | Template body with `{{arg}}` syntax |
459
-
460
- ### `SkillArgument`
461
-
462
- **File:** `mcp-types.interface.ts`
463
-
464
- A single argument accepted by a skill template.
465
-
466
- ```ts
467
- interface SkillArgument {
468
- readonly name: string;
469
- readonly type?: 'string' | 'number' | 'boolean';
470
- readonly description?: string;
471
- readonly required?: boolean;
472
- }
473
- ```
474
-
475
- | Property | Description |
476
- |---------------|------------------------------------|
477
- | `name` | Argument identifier |
478
- | `type` | Value type (defaults to `string`) |
479
- | `description` | Human-readable argument hint |
480
- | `required` | Whether the argument is required |
481
-
482
- ### `AgentDefinition`
483
-
484
- **File:** `mcp-types.interface.ts`
485
-
486
- A complete agent definition as returned by agent
487
- retrieval operations. Skills are resolved from kbid
488
- references; missing skills appear with `name: null`.
489
-
490
- ```ts
491
- interface AgentDefinition {
492
- readonly docid: string;
493
- readonly name: string;
494
- readonly description: string;
495
- readonly persona: string;
496
- readonly skills: readonly {
497
- readonly kbid: string;
498
- readonly name: string | null;
499
- readonly position: number;
500
- }[];
501
- }
502
- ```
503
-
504
- | Property | Description |
505
- |---------------|--------------------------------------|
506
- | `docid` | Agent document identifier |
507
- | `name` | Agent name in kebab-case |
508
- | `description` | What the agent does |
509
- | `persona` | System prompt text for the agent |
510
- | `skills` | Ordered skill references (resolved) |
511
-
512
- ## Error Code Constants
513
-
514
- **File:** `src/shared/mcp/constants/mcp-error-codes.constant.ts`
515
-
516
- Named constants for JSON-RPC 2.0 and MCP-specific
517
- error codes. Use these instead of inline numbers.
518
-
519
- | Constant | Value | Meaning |
520
- |---------------------|---------|--------------------------------|
521
- | `PARSE_ERROR` | -32700 | Malformed JSON in request |
522
- | `METHOD_NOT_FOUND` | -32601 | Method not implemented |
523
- | `INVALID_PARAMS` | -32602 | Invalid or missing parameters |
524
- | `INTERNAL_ERROR` | -32603 | Unexpected server error |
525
- | `RESOURCE_NOT_FOUND`| -32002 | Resource not found (MCP-specific); also used for pre-initialization guard |
526
-
527
- No spec -- typings are compile-time only. Constants
528
- have a spec (`mcp-error-codes.spec.ts`) that verifies
529
- the exported values.