@hivelore/mcp 0.30.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Hivelore contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,460 @@
1
+ <p align="center">
2
+ <a href="https://github.com/Doucs91/hivelore">
3
+ <img src="https://raw.githubusercontent.com/Doucs91/hivelore/main/packages/vscode/media/wordmark.svg" alt="Hivelore" width="240" />
4
+ </a>
5
+ </p>
6
+
7
+ # @hivelore/mcp
8
+
9
+ > **Hivelore MCP server** - policy-aware briefing and memory tools for MCP-compatible coding-agent harnesses.
10
+
11
+ The MCP server is how agents load team policy before changing code. By default it exposes a small harness-oriented tool surface: briefing, relevant memories, failed-attempt capture, anchor verification, code-map lookup, and pre-commit checks. Larger maintenance and experimental surfaces are opt-in via `HAIVE_TOOL_PROFILE`.
12
+
13
+ Hivelore is not just a memory database. The MCP layer participates in context policy: state-changing Hivelore tools require `get_briefing` or `mem_relevant_to` first, so agents cannot silently skip team context while using Hivelore.
14
+
15
+ ---
16
+
17
+ ## Install
18
+
19
+ **Recommended:** install only `@hivelore/cli`. The MCP server is **bundled** inside `haive` — configure clients with `command: "hivelore"` and `args: ["mcp", "--stdio"]` (see `@hivelore/cli` README).
20
+
21
+ Standalone package (legacy / advanced):
22
+
23
+ ```bash
24
+ npm install -g @hivelore/mcp
25
+ ```
26
+
27
+ You usually still want the CLI for `hivelore init`, `hivelore sync`, etc.:
28
+
29
+ ```bash
30
+ npm install -g @hivelore/cli
31
+ ```
32
+
33
+ ---
34
+
35
+ ## Quick start
36
+
37
+ ```bash
38
+ # 1. Install the CLI
39
+ npm install -g @hivelore/cli
40
+
41
+ # 2. Initialize Hivelore in your project (strict enforcement ON by default)
42
+ cd my-project
43
+ hivelore init # .ai/, policy config, hooks, CI workflow, code-map
44
+ hivelore enforce install
45
+ # hivelore init --manual # if you want to approve memories yourself
46
+
47
+ # 3. Point your AI client at the MCP server (see Client configuration below)
48
+
49
+ # 4. Bootstrap project context — run bootstrap_project prompt in your AI client once
50
+
51
+ # 5. Start every substantive task with get_briefing or mem_relevant_to
52
+ ```
53
+
54
+ ---
55
+
56
+ ## Client configuration
57
+
58
+ ### Claude Code
59
+
60
+ Add to `~/.claude.json` (global) or `.claude/settings.json` (per-project):
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "hivelore": {
66
+ "command": "hivelore",
67
+ "args": ["mcp", "--stdio", "--root", "/absolute/path/to/your/project"]
68
+ }
69
+ }
70
+ }
71
+ ```
72
+
73
+ ### Cursor
74
+
75
+ Add to `~/.cursor/mcp.json`:
76
+
77
+ ```json
78
+ {
79
+ "mcpServers": {
80
+ "hivelore": {
81
+ "command": "hivelore",
82
+ "args": ["mcp", "--stdio", "--root", "/absolute/path/to/your/project"]
83
+ }
84
+ }
85
+ }
86
+ ```
87
+
88
+ ### VS Code
89
+
90
+ ```bash
91
+ code --add-mcp '{"name":"haive","command":"haive","args":["mcp","--stdio","--root","/absolute/path/to/project"]}'
92
+ ```
93
+
94
+ ### Project-scoped (auto-detected)
95
+
96
+ Add a `.mcp.json` at the project root:
97
+
98
+ ```json
99
+ {
100
+ "mcpServers": {
101
+ "hivelore": {
102
+ "command": "hivelore",
103
+ "args": ["mcp", "--stdio"],
104
+ "env": { "HAIVE_PROJECT_ROOT": "/absolute/path/to/your/project" }
105
+ }
106
+ }
107
+ }
108
+ ```
109
+
110
+ The project root can also be set via the `HAIVE_PROJECT_ROOT` environment variable, or auto-detected from the nearest `.ai/`, `.git/`, or `package.json`.
111
+
112
+ ---
113
+
114
+ ## Default MCP Tools
115
+
116
+ By default, Hivelore runs with `HAIVE_TOOL_PROFILE=enforcement`. This keeps the agent surface small and aligned with the product promise.
117
+
118
+ Default tools:
119
+
120
+ - `get_briefing`
121
+ - `mem_relevant_to`
122
+ - `mem_save`
123
+ - `mem_tried`
124
+ - `mem_search`
125
+ - `mem_get`
126
+ - `mem_verify`
127
+ - `code_map`
128
+ - `pre_commit_check`
129
+ - `mem_session_end`
130
+
131
+ Default prompts:
132
+
133
+ - `bootstrap_project`
134
+ - `post_task`
135
+
136
+ ### Tool Profiles
137
+
138
+ `HAIVE_TOOL_PROFILE` controls how much Hivelore surface an agent sees:
139
+
140
+ - `enforcement` (default): compact repo-native context harness for coding agents.
141
+ - `maintenance`: adds corpus review, lifecycle, distillation, code-search, and project-context maintenance tools.
142
+ - `experimental`: adds exploratory diagnostics such as runtime journal, pattern detection, why-this-file, why-this-decision, and conflict analysis.
143
+ - `full`: legacy alias for `experimental`.
144
+
145
+ Use `maintenance` for human/team stewardship sessions and `experimental` only when you are intentionally working on Hivelore's broader research tooling.
146
+
147
+ ### `get_briefing` ⭐ Start every task with this
148
+
149
+ One-shot policy briefing: returns project context + module contexts + ranked decisions, gotchas, failed attempts, stale warnings, and setup warnings under a token budget. This is the first call agents should make before substantive edits.
150
+
151
+ ```json
152
+ {
153
+ "task": "add a Stripe payment integration",
154
+ "files": ["src/payments/PaymentService.ts"],
155
+ "symbols": ["PaymentService", "TenantFilter"],
156
+ "max_tokens": 8000,
157
+ "max_memories": 8,
158
+ "format": "full",
159
+ "semantic": true
160
+ }
161
+ ```
162
+
163
+ **Parameters:**
164
+
165
+ | Parameter | Default | Description |
166
+ |---|---|---|
167
+ | `task` | — | What you're about to do. Used to rank memories by relevance. |
168
+ | `files` | `[]` | Files you're editing. Surfaces memories anchored to these files. |
169
+ | `symbols` | `[]` | Symbol names to look up in the code-map (e.g. `["PaymentService"]`). Returns file + line + kind without grepping. Requires `hivelore index code`. |
170
+ | `max_tokens` | `8000` | Token budget for the entire response. Sections are truncated to fit. |
171
+ | `max_memories` | `8` | Max memories to include. |
172
+ | `format` | `"full"` | `"full"` = complete bodies · `"compact"` = 1-line summaries (call `mem_get` for details) |
173
+ | `semantic` | `true` | Use embedding-based ranking if `@hivelore/embeddings` is indexed. |
174
+ | `include_stale` | `false` | Include stale memories (may be outdated). |
175
+ | `track` | `true` | Increment read_count for returned memories. |
176
+
177
+ **Response includes:**
178
+ - `last_session` — most recent `hivelore session end` recap (surfaced first so agents start with fresh context)
179
+ - `project_context` — `.ai/project-context.md` (suppressed if still template — `is_template: true`)
180
+ - `module_contexts` — relevant `.ai/modules/<name>/context.md` files
181
+ - `memories` — ranked memories with `confidence`, `unverified` flag (for draft/proposed), and `match reason`
182
+ - `symbol_locations` — file:line:kind results for each requested symbol (from code-map)
183
+ - `decay_warnings` — memory IDs not read in >90 days
184
+ - `setup_warnings` — actionable warnings (e.g. template project-context, missing init)
185
+ - `search_mode` — `"semantic"` | `"literal_fallback"` | `"literal"`
186
+
187
+ ---
188
+
189
+ ### `mem_save`
190
+
191
+ Save a policy-relevant piece of knowledge. For failed approaches, use `mem_tried` immediately so the next agent sees the trap before repeating it.
192
+
193
+ > **Autopilot mode:** memories go directly to `validated` with `team` scope by default. No approval cycle.
194
+
195
+ ```json
196
+ {
197
+ "type": "gotcha",
198
+ "slug": "open-in-view-false",
199
+ "scope": "team",
200
+ "body": "spring.jpa.open-in-view=false is intentional — do not re-enable. Lazy loading outside transactions causes N+1 queries.",
201
+ "paths": ["src/main/resources/application.properties"],
202
+ "tags": ["spring", "jpa", "performance"],
203
+ "topic": "jpa-config"
204
+ }
205
+ ```
206
+
207
+ | Parameter | Required | Description |
208
+ |---|---|---|
209
+ | `type` | ✅ | `convention` · `decision` · `gotcha` · `architecture` · `glossary` |
210
+ | `slug` | ✅ | Short kebab-case identifier used in the file name |
211
+ | `scope` | — | `personal` (default in manual mode) · `team` · `module` |
212
+ | `body` | ✅ | Markdown content of the memory |
213
+ | `paths` | — | Source file paths to anchor to — enables staleness detection by `hivelore sync`. **Warning if path doesn't exist.** |
214
+ | `symbols` | — | Function/class names to anchor to |
215
+ | `tags` | — | Tags for filtering and search |
216
+ | `topic` | — | Stable key for upsert: if a memory with this `topic`+`scope` exists, update it in-place (`revision_count++`) |
217
+ | `domain` | — | Business domain (e.g. `payments`) |
218
+ | `author` | — | Author handle |
219
+
220
+ **Response:** `{ id, scope, file_path, action: "created"|"updated", warning?, invalid_paths? }`
221
+
222
+ **Deduplication:** identical body content within the same scope is rejected. Use `mem_update` to modify an existing memory.
223
+
224
+ ---
225
+
226
+ ### `mem_tried` ⭐ Record failures immediately
227
+
228
+ Record a failed approach. Automatically surfaces first in future `get_briefing` calls so agents don't repeat the same mistake.
229
+
230
+ ```json
231
+ {
232
+ "what": "using require() to import gray-matter in an ESM package",
233
+ "why_failed": "The package is ESM-only — require() throws ERR_REQUIRE_ESM",
234
+ "instead": "Use import matter from 'gray-matter' (named default import)",
235
+ "scope": "team",
236
+ "paths": ["src/parser.ts"]
237
+ }
238
+ ```
239
+
240
+ Auto-validated — no approval cycle needed.
241
+
242
+ ---
243
+
244
+ ### `mem_search`
245
+
246
+ Search memories by substring or semantic similarity.
247
+
248
+ ```json
249
+ {
250
+ "query": "flyway migration",
251
+ "scope": "team",
252
+ "semantic": true,
253
+ "limit": 10
254
+ }
255
+ ```
256
+
257
+ Falls back to literal search if embeddings are not indexed.
258
+
259
+ ---
260
+
261
+ ### `mem_get`
262
+
263
+ Fetch a single memory with full body, anchor, confidence, and usage stats.
264
+
265
+ ```json
266
+ { "id": "2025-01-15-gotcha-flyway-strict" }
267
+ ```
268
+
269
+ ---
270
+
271
+ ### `mem_list`
272
+
273
+ List memories with optional filters.
274
+
275
+ ```json
276
+ {
277
+ "scope": "team",
278
+ "type": "gotcha",
279
+ "status": "validated",
280
+ "tags": ["payments"]
281
+ }
282
+ ```
283
+
284
+ ---
285
+
286
+ ### `mem_for_files`
287
+
288
+ Given the files you're editing, return relevant memories grouped by reason (anchor overlap, module, domain).
289
+
290
+ ```json
291
+ {
292
+ "files": ["src/payments/PaymentService.java", "src/payments/WaveProvider.java"]
293
+ }
294
+ ```
295
+
296
+ ---
297
+
298
+ ### `mem_update`
299
+
300
+ Update a memory's body, tags, or anchor without changing its id or usage history.
301
+
302
+ ```json
303
+ {
304
+ "id": "2025-01-15-gotcha-flyway-strict",
305
+ "body": "Updated explanation...",
306
+ "paths": ["src/main/resources/db/migration"]
307
+ }
308
+ ```
309
+
310
+ ---
311
+
312
+ ### `mem_verify`
313
+
314
+ Check if anchor paths and symbols still exist in the current code. Detects stale memories and suggests possible renames when files have moved.
315
+
316
+ ```json
317
+ { "id": "2025-01-15-gotcha-flyway-strict", "update": true }
318
+ ```
319
+
320
+ ---
321
+
322
+ ### `mem_diff`
323
+
324
+ Compare two memories side-by-side: shows frontmatter fields that differ and lines unique to each body. Useful before merging duplicates.
325
+
326
+ ```json
327
+ { "id_a": "2025-01-15-gotcha-flyway-strict", "id_b": "2025-02-01-decision-flyway-naming" }
328
+ ```
329
+
330
+ ---
331
+
332
+ ### `mem_session_end`
333
+
334
+ Save a structured end-of-session recap. Topic-upsert: one recap per scope is kept and updated with `revision_count++`. Automatically surfaced at the top of the next `get_briefing`.
335
+
336
+ ```json
337
+ {
338
+ "goal": "Add Stripe payment integration",
339
+ "accomplished": "PaymentService done, tests passing, deployed to staging",
340
+ "discoveries": "Webhook signature requires raw body, not parsed JSON",
341
+ "files_touched": ["src/payments/PaymentService.ts", "src/payments/webhook.ts"],
342
+ "next_steps": "Add retry logic for failed webhooks",
343
+ "scope": "team"
344
+ }
345
+ ```
346
+
347
+ ---
348
+
349
+ ### `mem_observe`
350
+
351
+ Capture a code-level discovery in structured form (found-while, not a convention or decision).
352
+
353
+ ```json
354
+ {
355
+ "file": "src/payments/PaymentService.ts",
356
+ "symbol": "processPayment",
357
+ "observation": "This method calls the external API synchronously — any timeout blocks the entire request thread.",
358
+ "scope": "team"
359
+ }
360
+ ```
361
+
362
+ ---
363
+
364
+ ### `mem_approve` / `mem_reject` / `mem_pending` / `mem_delete`
365
+
366
+ Lifecycle operations:
367
+
368
+ ```json
369
+ { "id": "2025-01-15-gotcha-flyway-strict" } // mem_approve
370
+ { "id": "2025-01-15-gotcha-old", "reason": "Outdated" } // mem_reject
371
+ {} // mem_pending (list all)
372
+ { "id": "2025-01-15-gotcha-old" } // mem_delete
373
+ ```
374
+
375
+ ---
376
+
377
+ ### `get_project_context`
378
+
379
+ Read `.ai/project-context.md` directly (without token budgeting).
380
+
381
+ ```json
382
+ { "module": "payments" } // Also loads .ai/modules/payments/context.md
383
+ ```
384
+
385
+ ---
386
+
387
+ ### `bootstrap_project_save`
388
+
389
+ Persist a project (or module) context document generated by the AI.
390
+
391
+ ```json
392
+ {
393
+ "content": "# Project context\n\n## Architecture\n...",
394
+ "module": "payments" // Optional: save as .ai/modules/payments/context.md
395
+ }
396
+ ```
397
+
398
+ ---
399
+
400
+ ### `code_map`
401
+
402
+ Browse the pre-computed code map (file → exports + descriptions) instead of grepping.
403
+
404
+ ```json
405
+ { "query": "payment" } // Filter by keyword
406
+ { "file": "src/payments" } // Filter by file prefix
407
+ { "symbol": "PaymentService" } // Find a specific export
408
+ ```
409
+
410
+ Requires `hivelore index code` to be run first.
411
+
412
+ ---
413
+
414
+ ## MCP Prompts
415
+
416
+ ### `post_task` ⭐ Run before closing every session
417
+
418
+ Post-task reflection checklist. Guides the AI through capturing failed approaches, conventions, decisions, and gotchas before the session ends.
419
+
420
+ ```
421
+ Use the post_task prompt with:
422
+ task_summary: "Added Stripe payment integration"
423
+ files_touched: ["src/payments/StripeService.ts", "src/payments/PaymentController.ts"]
424
+ ```
425
+
426
+ ### `bootstrap_project`
427
+
428
+ Instructions for the AI to analyze the current project and save a structured context document to `.ai/project-context.md`. Run once after `hivelore init`.
429
+
430
+ ### `import_docs`
431
+
432
+ Analyze documentation (README, ADR, wiki page, API spec) and save actionable knowledge as Hivelore memories.
433
+
434
+ ```
435
+ Use the import_docs prompt with:
436
+ content: "<full document text>"
437
+ source: "docs/architecture.md"
438
+ scope: "team"
439
+ ```
440
+
441
+ The AI extracts up to 10 memories (conventions, decisions, gotchas, architecture) and calls `mem_save` for each.
442
+
443
+ ---
444
+
445
+ ## Memory lifecycle
446
+
447
+ ```
448
+ mem_save / mem_tried → draft (personal) or proposed (team)
449
+ mem_approve → validated
450
+ mem_verify → stale (if anchors broken)
451
+ mem_reject → rejected
452
+ ```
453
+
454
+ Validated team memories appear in `get_briefing`. Stale memories are excluded by default (pass `include_stale: true` to override).
455
+
456
+ ---
457
+
458
+ ## License
459
+
460
+ MIT