@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,482 +0,0 @@
1
- # MCP Server Guide
2
-
3
- The `kbdb mcp` command starts a long-lived MCP
4
- server that exposes the knowledge base to AI
5
- agents over stdio using JSON-RPC 2.0.
6
-
7
- ## Setup
8
-
9
- Configure kbdb as an MCP server for your AI agent
10
- platform. The server requires a database path via
11
- `--db` or the `KBDB_DB_DIR` environment variable.
12
-
13
- ### Claude Code (CLI)
14
-
15
- Create `.mcp.json` in the project root:
16
-
17
- ```json
18
- {
19
- "mcpServers": {
20
- "kbdb": {
21
- "command": "npx",
22
- "args": [
23
- "-y", "@dikolab/kbdb", "mcp",
24
- "--db", "/path/to/.kbdb"
25
- ]
26
- }
27
- }
28
- }
29
- ```
30
-
31
- Deno variant:
32
-
33
- ```json
34
- {
35
- "mcpServers": {
36
- "kbdb": {
37
- "command": "deno",
38
- "args": [
39
- "run", "-A",
40
- "jsr:@dikolab/kbdb/cli", "mcp",
41
- "--db", "/path/to/.kbdb"
42
- ]
43
- }
44
- }
45
- }
46
- ```
47
-
48
- ### Claude for VS Code
49
-
50
- Create `.vscode/mcp.json`:
51
-
52
- ```json
53
- {
54
- "servers": {
55
- "kbdb": {
56
- "command": "npx",
57
- "args": [
58
- "-y", "@dikolab/kbdb", "mcp",
59
- "--db", "/path/to/.kbdb"
60
- ]
61
- }
62
- }
63
- }
64
- ```
65
-
66
- Deno variant:
67
-
68
- ```json
69
- {
70
- "servers": {
71
- "kbdb": {
72
- "command": "deno",
73
- "args": [
74
- "run", "-A",
75
- "jsr:@dikolab/kbdb/cli", "mcp",
76
- "--db", "/path/to/.kbdb"
77
- ]
78
- }
79
- }
80
- }
81
- ```
82
-
83
- ### Claude Desktop
84
-
85
- Add to `claude_desktop_config.json`:
86
-
87
- ```json
88
- {
89
- "mcpServers": {
90
- "kbdb": {
91
- "command": "npx",
92
- "args": [
93
- "-y", "@dikolab/kbdb", "mcp",
94
- "--db", "/path/to/.kbdb"
95
- ]
96
- }
97
- }
98
- }
99
- ```
100
-
101
- Deno variant:
102
-
103
- ```json
104
- {
105
- "mcpServers": {
106
- "kbdb": {
107
- "command": "deno",
108
- "args": [
109
- "run", "-A",
110
- "jsr:@dikolab/kbdb/cli", "mcp",
111
- "--db", "/path/to/.kbdb"
112
- ]
113
- }
114
- }
115
- }
116
- ```
117
-
118
- ### Other AI Agents
119
-
120
- Any MCP-compatible agent can connect via stdio
121
- transport. Run the server directly:
122
-
123
- ```sh
124
- npx @dikolab/kbdb mcp --db /path/to/.kbdb
125
- ```
126
-
127
- Or with Deno:
128
-
129
- ```sh
130
- deno run -A jsr:@dikolab/kbdb/cli mcp \
131
- --db /path/to/.kbdb
132
- ```
133
-
134
- ### Using `KBDB_DB_DIR` Environment Variable
135
-
136
- The `--db` flag can be replaced by the `KBDB_DB_DIR`
137
- environment variable in any configuration:
138
-
139
- ```json
140
- {
141
- "mcpServers": {
142
- "kbdb": {
143
- "command": "npx",
144
- "args": ["-y", "@dikolab/kbdb", "mcp"],
145
- "env": {
146
- "KBDB_DB_DIR": "/path/to/.kbdb"
147
- }
148
- }
149
- }
150
- }
151
- ```
152
-
153
- Resolution order: `--db` flag, then `KBDB_DB_DIR`
154
- env var. If neither is set, the server exits with
155
- an error. The server does not fall back to the
156
- current working directory because the server's cwd
157
- is determined by the host application, not the
158
- user.
159
-
160
- ### `KBDB_DAEMON_TIMEOUT`
161
-
162
- Per-request daemon timeout in milliseconds.
163
- Defaults to `30000` (30 seconds). Overridden by
164
- the `--timeout-ms` flag.
165
-
166
- ### `KBDB_RETRY`
167
-
168
- Maximum number of retries with daemon respawn when
169
- a request times out. Defaults to `1`. Overridden
170
- by the `--retry` flag.
171
-
172
- ### `KBDB_LOG_LEVEL`
173
-
174
- Log verbosity: `debug`, `info`, `warning`, `error`
175
- (case-insensitive). Defaults to `error`. Overridden
176
- by `-v`/`-vv`/`-vvv` flags. The level is forwarded
177
- to the worker daemon via `--log-level`.
178
-
179
- ### `KBDB_NON_INTERACTIVE`
180
-
181
- Suppress interactive prompts. Accepts `1` or
182
- `true`. The MCP server does not prompt interactively
183
- (it reads JSON-RPC from stdin), but the variable is
184
- inherited by the worker daemon for consistency.
185
-
186
- These variables can be set in the `env` block of
187
- your MCP configuration:
188
-
189
- ```json
190
- {
191
- "mcpServers": {
192
- "kbdb": {
193
- "command": "npx",
194
- "args": ["-y", "@dikolab/kbdb", "mcp"],
195
- "env": {
196
- "KBDB_DB_DIR": "/path/to/.kbdb",
197
- "KBDB_DAEMON_TIMEOUT": "60000",
198
- "KBDB_RETRY": "2",
199
- "KBDB_LOG_LEVEL": "warning"
200
- }
201
- }
202
- }
203
- }
204
- ```
205
-
206
- ### Multiple Knowledge Bases
207
-
208
- Register multiple server instances pointing to
209
- different databases:
210
-
211
- ```json
212
- {
213
- "mcpServers": {
214
- "kbdb-docs": {
215
- "command": "npx",
216
- "args": [
217
- "-y", "@dikolab/kbdb", "mcp",
218
- "--db", "/home/user/docs/.kbdb"
219
- ]
220
- },
221
- "kbdb-project": {
222
- "command": "npx",
223
- "args": [
224
- "-y", "@dikolab/kbdb", "mcp",
225
- "--db", "/home/user/project/.kbdb"
226
- ]
227
- }
228
- }
229
- }
230
- ```
231
-
232
- Each instance runs as a separate process with its
233
- own worker client connection.
234
-
235
- ## Tools Reference
236
-
237
- The MCP server exposes 20 tools grouped by
238
- function. All tools communicate with the worker
239
- daemon via JSON-RPC 2.0 over IPC.
240
-
241
- ### Knowledge Base Tools
242
-
243
- | Tool | Parameters | Description | Read-only | Destructive |
244
- |------|-----------|-------------|-----------|-------------|
245
- | `search` | `query` (string, required), `mode` (string), `algo` (string: lexical, vector, hybrid), `limit` (number), `offset` (number), `content` (boolean) | Query the knowledge base by keywords. Returns ranked results with heading, snippet, and matched terms. Use `algo` to select search algorithm (default: lexical). | yes | no |
246
- | `learn` | `content` (string, required), `type` (string), `title` (string), `description` (string), `docid` (string), `tags` (string[]), `replace` (boolean) | Import content into the knowledge base. Use for durable facts, decisions, and corrections. Use `replace` when updating existing knowledge. Attach `tags` for scoping. | no | no |
247
- | `unlearn` | `kbid` (string, required) | Remove a section by kb-id. Cascades deletion to index entries and ranking data. | no | yes |
248
- | `retrieve` | `kbid` (string), `docid` (string) | Fetch a specific section or document by identifier. At least one of `kbid` or `docid` required. | yes | no |
249
- | `recall` | `kbid` (string), `kbids` (string[]), `depth` (number) | Retrieve full content and progressive context for sections. Use after `search` to read relevant results. Depth 0-3 controls context expansion. | yes | no |
250
- | `content` | `ids` (string[], required) | Compose a rendered Markdown document from one or more kbid or docid identifiers. | yes | no |
251
- | `status` | (none) | Return database status and cache statistics. | yes | no |
252
- | `check` | (none) | Verify knowledge base integrity. Reports checksum mismatches, orphan sections, broken references. | yes | no |
253
- | `gc` | (none) | Remove unreferenced sections (no document manifest references). | no | yes |
254
- | `rebuild` | (none) | Reconstruct all index files from section files and document manifests on disk. | no | no |
255
- | `export` | `path` (string) | Export the knowledge base as a self-contained directory snapshot for backup or versioning. Copies sections, documents, and catalog (no indexes). | no | no |
256
- | `auto-capture-review` | `action` (string: list, approve, reject) | Review and approve pending auto-captured knowledge before storage. | no | no |
257
-
258
- ### Skills Tools
259
-
260
- | Tool | Parameters | Description | Read-only | Destructive |
261
- |------|-----------|-------------|-----------|-------------|
262
- | `skill-learn` | `name` (string, required), `description` (string), `body` (string, required) | Create or update a skill definition. Body supports `{{argName}}` template placeholders. | no | no |
263
- | `skill-list` | (none) | List all skill definitions. Returns array of summaries with kbid, name, description, argumentCount. | yes | no |
264
- | `skill-get` | `name` (string), `kbid` (string) | Retrieve a single skill by name or kb-id. At least one required; `kbid` takes precedence. | yes | no |
265
- | `skill-delete` | `kbid` (string, required) | Remove a skill by kb-id. Agent documents referencing this skill will have dangling references. | no | yes |
266
-
267
- ### Agents Tools
268
-
269
- | Tool | Parameters | Description | Read-only | Destructive |
270
- |------|-----------|-------------|-----------|-------------|
271
- | `agent-create` | `name` (string, required), `description` (string), `persona` (string, required), `skills` (string[]) | Create an agent with a persona and optional skill references. | no | no |
272
- | `agent-list` | (none) | List all agent documents. Returns array of summaries with docid, name, description, skillCount. | yes | no |
273
- | `agent-get` | `docid` (string, required) | Retrieve an agent with resolved skill definitions. Deleted skills appear with `name: null`. | yes | no |
274
- | `agent-delete` | `docid` (string, required) | Remove an agent document. Referenced skill sections are preserved. | no | yes |
275
-
276
- ### Tool Annotations Summary
277
-
278
- | Tool | Idempotent |
279
- |------|------------|
280
- | `search` | yes |
281
- | `learn` | yes |
282
- | `unlearn` | yes |
283
- | `retrieve` | yes |
284
- | `content` | yes |
285
- | `status` | yes |
286
- | `check` | yes |
287
- | `gc` | no |
288
- | `recall` | yes |
289
- | `rebuild` | no |
290
- | `export` | yes |
291
- | `skill-learn` | yes |
292
- | `skill-list` | yes |
293
- | `skill-get` | yes |
294
- | `skill-delete` | yes |
295
- | `agent-create` | yes |
296
- | `agent-list` | yes |
297
- | `agent-get` | yes |
298
- | `agent-delete` | yes |
299
- | `auto-capture-review` | yes |
300
-
301
- ## Prompts
302
-
303
- The MCP server exposes knowledge base content as
304
- discoverable prompts via `prompts/list` and
305
- `prompts/get`.
306
-
307
- ### Skills as Prompts
308
-
309
- Each skill stored in the database appears as an
310
- MCP prompt. The skill's `{{argName}}` template
311
- placeholders become prompt arguments. When an
312
- agent calls `prompts/get` with argument values,
313
- the server renders the template with substitutions
314
- and returns it as a user message.
315
-
316
- ```json
317
- {
318
- "name": "summarize-document",
319
- "description": "Summarize a document into key points",
320
- "arguments": [
321
- {
322
- "name": "docid",
323
- "description": "Document identifier",
324
- "required": true
325
- },
326
- {
327
- "name": "max_points",
328
- "description": "Max bullet points",
329
- "required": false
330
- }
331
- ]
332
- }
333
- ```
334
-
335
- ### Agents as Prompts
336
-
337
- Each agent appears as a prompt with an `agent:`
338
- name prefix. Agent prompts have no arguments.
339
- When rendered, they produce two messages:
340
-
341
- 1. An assistant message containing the agent's
342
- persona text.
343
- 2. A user message listing the agent's available
344
- skills.
345
-
346
- ```json
347
- {
348
- "name": "agent:code-reviewer",
349
- "description": "Reviews code for bugs, style, and best practices",
350
- "arguments": []
351
- }
352
- ```
353
-
354
- ## Resources
355
-
356
- Resources provide direct access to knowledge base
357
- contents by URI, without going through search.
358
-
359
- ### URI Templates
360
-
361
- The server exposes parameterised URI templates
362
- via `resources/templates/list`:
363
-
364
- | URI Template | MIME Type | Description |
365
- |-------------|----------|-------------|
366
- | `kbdb://section/{kbid}` | `text/plain` | Raw content of a single section by kb-id. For image sections, returns base64-encoded content with the image MIME type. |
367
- | `kbdb://document/{docid}` | `application/json` | Document manifest and all sections, ordered by position. |
368
-
369
- ### Static Resources
370
-
371
- The `resources/list` endpoint returns an empty
372
- list. All resources are accessed through URI
373
- templates.
374
-
375
- ### Reading Resources
376
-
377
- Use `resources/read` with an expanded URI:
378
-
379
- - `kbdb://section/abcdef1234567890abcdef1234` --
380
- returns the section content.
381
- - `kbdb://document/agent-code-reviewer` --
382
- returns the document with all sections.
383
-
384
- ## Protocol Features
385
-
386
- The kbdb MCP server implements Model Context
387
- Protocol version **2025-11-25** and advertises the
388
- following capabilities:
389
-
390
- - **tools** -- `tools/list` and `tools/call` for
391
- all 20 tools.
392
- - **resources** -- `resources/list`,
393
- `resources/read`, and
394
- `resources/templates/list` for URI-based content
395
- access.
396
- - **prompts** -- `prompts/list` and `prompts/get`
397
- for skill and agent prompt discovery.
398
- - **completions** -- `completion/complete` for
399
- autocomplete on prompt names and resource URIs.
400
- - **logging** -- `logging/setLevel` to control
401
- server-to-client log notification verbosity.
402
- Levels: `debug`, `info`, `notice`, `warning`,
403
- `error`, `critical`, `alert`, `emergency`.
404
- - **roots** -- `roots/list` returns the `.kbdb`
405
- database directory as the single filesystem root.
406
- - **subscriptions** -- `resources/subscribe` and
407
- `resources/unsubscribe` for change notifications
408
- on individual resources.
409
- - **sampling** -- `sampling/createMessage` allows
410
- the server to request text generation from the
411
- host's language model.
412
-
413
- ## Error Handling
414
-
415
- ### Protocol Errors
416
-
417
- Standard JSON-RPC 2.0 error codes for protocol
418
- violations:
419
-
420
- | Code | Meaning |
421
- |------|---------|
422
- | `-32700` | Parse error (malformed JSON) |
423
- | `-32601` | Method not found |
424
- | `-32602` | Invalid params |
425
- | `-32603` | Internal error |
426
- | `-32002` | Resource not found (MCP-specific) |
427
-
428
- ### Tool Execution Errors
429
-
430
- Tool-level failures are returned as successful
431
- JSON-RPC responses with `isError: true` in the
432
- result:
433
-
434
- ```json
435
- {
436
- "content": [
437
- {
438
- "type": "text",
439
- "text": "Section not found: abc123"
440
- }
441
- ],
442
- "isError": true
443
- }
444
- ```
445
-
446
- Successful tool results are wrapped as:
447
-
448
- ```json
449
- {
450
- "content": [
451
- {
452
- "type": "text",
453
- "text": "<JSON result>"
454
- }
455
- ]
456
- }
457
- ```
458
-
459
- ## Transport
460
-
461
- The MCP server uses stdio transport:
462
-
463
- - Reads JSON-RPC 2.0 requests from **stdin**.
464
- - Writes JSON-RPC 2.0 responses to **stdout**.
465
- - Diagnostic messages go to **stderr**.
466
-
467
- The host application spawns `kbdb mcp` as a child
468
- process and communicates over its stdin/stdout
469
- streams. Each JSON-RPC message is serialised as a
470
- single line of JSON terminated by `\n`.
471
-
472
- ## Lifecycle
473
-
474
- 1. Host sends `initialize` with its capabilities.
475
- Server responds with its identity and supported
476
- capability groups.
477
- 2. Host sends `notifications/initialized` to
478
- confirm the handshake. Server begins accepting
479
- tool and resource requests.
480
- 3. Either party can send `ping` to check liveness.
481
- 4. When the host closes stdin, the server
482
- disconnects from the worker daemon and exits.