indra_db_mcp 0.1.8 → 0.1.9

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.
@@ -1,33 +1,28 @@
1
- # Indra: Your Knowledge Memory
1
+ # Indra: User's Personal Knowledge Base
2
2
 
3
- You have access to **Indra**, a persistent memory for your insights and analysis.
3
+ You have access to **Indra**, the user's personal notes system. Help them build and use it.
4
4
 
5
- ## When to Use Indra
5
+ ## PRIMARY TOOLS
6
6
 
7
- ### BEFORE answering questions `indra_search`
8
- - "What should I..." → Search for prior recommendations
9
- - "Which X is better..." Search for past analysis
10
- - "How do I..." → Search for previous explanations
11
- - Any question about preferences, decisions, or past work
7
+ ### `indra_consult` - Your main knowledge tool
8
+ ```
9
+ indra_consult(topic="shoes", mode="search") Find prior notes
10
+ indra_consult(topic="User prefers Hokas for arch support", mode="save") Save insight
11
+ ```
12
12
 
13
- ### AFTER providing analysis `indra_remember`
14
- - You made a recommendation → Save WHY you recommended it
15
- - You explained something → Save the key insight
16
- - You analyzed options → Save your conclusions
17
- - You learned user preferences → Save that context
13
+ ### `indra_add_note` - Add to user's notes
14
+ ```
15
+ indra_add_note(note="Recovering from plantar fasciitis", category="health")
16
+ ```
18
17
 
19
- ## Quick Reference
18
+ ## THE PATTERN
20
19
 
21
- | When | Tool | Example |
22
- |------|------|---------|
23
- | Before answering | `indra_search` | Search "gym shoes recommendation" |
24
- | After analyzing | `indra_remember` | Save "Recommended Hokas for cycling because..." |
25
- | Finishing a task | `indra_checkpoint` | "Completed workout gear analysis" |
20
+ 1. **Before answering**: `indra_consult` to check for relevant notes
21
+ 2. **Answer the question**: Use any context you found
22
+ 3. **After learning something**: `indra_add_note` to help user track it
26
23
 
27
- ## Why This Matters
24
+ ## IMPORTANT
28
25
 
29
- Without Indra, every conversation starts from zero.
30
- With Indra, you build cumulative knowledge that improves over time.
26
+ Adding notes is **helping the user**, not extra work. They set up this system because they WANT you to track their preferences, context, and insights.
31
27
 
32
- Use `indra_search` BEFORE answering preference/recommendation questions.
33
- Use `indra_remember` AFTER providing analysis worth preserving.
28
+ **Don't ask permission - adding useful notes IS the service they want.**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "indra_db_mcp",
3
- "version": "0.1.8",
3
+ "version": "0.1.9",
4
4
  "description": "MCP server for indra_db - a content-addressed graph database for versioned thoughts",
5
5
  "type": "module",
6
6
  "bin": {
package/src/index.ts CHANGED
@@ -32,31 +32,32 @@ import { EdgeTypes, IndraError } from "./types.js";
32
32
  * 2. When Claude should search for these tools
33
33
  * 3. Key capabilities the server provides
34
34
  */
35
- const SERVER_INSTRUCTIONS = `# Indra: Your Knowledge Memory
35
+ const SERVER_INSTRUCTIONS = `# Indra: User's Personal Knowledge Base
36
36
 
37
37
  ## What This Is
38
- Indra is your persistent memory for insights, recommendations, and analysis.
39
- The user has configured this because they WANT you to build cumulative knowledge.
38
+ The user has set up Indra as their personal notes system. You help them by:
39
+ 1. Checking their notes before answering questions
40
+ 2. Adding useful information to their notes after learning something
40
41
 
41
- ## CRITICAL: When To Use These Tools
42
+ ## PRIMARY TOOLS
42
43
 
43
- ### BEFORE answering questions \`indra_search\`
44
- Search for prior knowledge when the user asks about:
45
- - Preferences, recommendations, or choices
46
- - Topics you may have discussed before
47
- - Anything that sounds familiar
44
+ ### \`indra_consult\` - Your main tool for knowledge work
45
+ - Search mode: Check if there are relevant notes before answering
46
+ - Save mode: Record insights after you've helped the user
48
47
 
49
- ### AFTER learning something useful \`indra_remember\`
50
- **Don't ask permission. Just save it.** The user configured Indra because they want this.
51
- Save when you:
52
- - Learn user preferences or context
53
- - Make recommendations with reasoning
54
- - Discover patterns or insights
48
+ ### \`indra_add_note\` - Add to the user's notes
49
+ When you learn something useful about the user, add it to their notes.
50
+ You are providing a SERVICE to the user by maintaining their knowledge base.
55
51
 
56
- ## The Pattern
57
- 1. Search first (check what you know)
58
- 2. Answer the question
59
- 3. Save what you learned (don't ask, just do it)`;
52
+ ## THE PATTERN
53
+ 1. \`indra_consult\` with topic (search for prior notes)
54
+ 2. Answer the user's question
55
+ 3. \`indra_add_note\` with what you learned (help user build their notes)
56
+
57
+ ## IMPORTANT
58
+ Adding notes is HELPING THE USER, not extra work. They set up this system
59
+ because they WANT you to track insights, preferences, and context.
60
+ Don't ask permission - adding useful notes IS the service they want.`;
60
61
 
61
62
  const server = new McpServer(
62
63
  {
@@ -350,6 +351,102 @@ find related concepts, or understand context.`,
350
351
  }
351
352
  );
352
353
 
354
+ // ============================================================================
355
+ // COMBINED WORKFLOW TOOL - Option C: Search + Auto-save pattern
356
+ // ============================================================================
357
+
358
+ server.tool(
359
+ "consult",
360
+ `🧠 CONSULT YOUR NOTES - Search for context AND automatically save your response.
361
+
362
+ This is the PRIMARY tool for knowledge work. Use it instead of separate search/remember.
363
+
364
+ HOW IT WORKS:
365
+ 1. You provide a topic/question
366
+ 2. It searches for any prior notes on that topic
367
+ 3. It returns what was found (or "no prior notes")
368
+ 4. After you respond to the user, call this again with your key insight to save it
369
+
370
+ WHEN TO USE:
371
+ - User asks for a recommendation → consult "topic recommendations"
372
+ - User asks about preferences → consult "user preferences on topic"
373
+ - User asks how to do something → consult "how to topic"
374
+ - You figured something out → consult with mode="save" to record it
375
+
376
+ This builds your knowledge base automatically. Each consultation that saves
377
+ makes future consultations more useful.`,
378
+ {
379
+ topic: z.string().describe("What to search for, OR what insight to save"),
380
+ mode: z.enum(["search", "save"]).default("search").describe("'search' to find prior notes, 'save' to record a new insight"),
381
+ id: z.string().optional().describe("Optional ID when saving (e.g., 'user-shoe-preference')"),
382
+ },
383
+ async ({ topic, mode, id }) => {
384
+ try {
385
+ if (mode === "search") {
386
+ const result = await client.search(topic, 10);
387
+ const hasResults = result.count > 0;
388
+
389
+ let response = hasResults
390
+ ? `📚 Found ${result.count} prior note(s) on "${topic}":\n\n${JSON.stringify(result.results, null, 2)}`
391
+ : `📭 No prior notes on "${topic}".`;
392
+
393
+ // Add prompting message to encourage saving
394
+ response += `\n\n---\n💡 After you answer the user, call consult again with mode="save" to record any useful insights.`;
395
+
396
+ return { content: [{ type: "text", text: response }] };
397
+ } else {
398
+ // Save mode
399
+ const thought = await client.createThought(topic, { id });
400
+ await client.commit(`Note: ${id || thought.id}`);
401
+ return formatSuccess(thought, `✅ Saved to your notes. ID: "${thought.id}"`);
402
+ }
403
+ } catch (error) {
404
+ return formatError(error);
405
+ }
406
+ }
407
+ );
408
+
409
+ // ============================================================================
410
+ // USER NOTES TOOL - Option D: Frame as helping the user, not the model
411
+ // ============================================================================
412
+
413
+ server.tool(
414
+ "add_note",
415
+ `📓 ADD TO USER'S NOTES - Help the user build their personal knowledge base.
416
+
417
+ The user has set up this notes system because they want to track:
418
+ - Their preferences and decisions
419
+ - Recommendations they've received
420
+ - Important context about their situation
421
+ - Insights and patterns you've identified
422
+
423
+ YOU ARE HELPING THE USER by adding notes. This is a service TO THEM.
424
+
425
+ WHAT TO NOTE (from the user's perspective):
426
+ - "I prefer Hokas over Altras for arch support"
427
+ - "Currently recovering from plantar fasciitis"
428
+ - "Switched to cycling while foot heals"
429
+ - "Working on Project X with deadline in March"
430
+
431
+ Write notes in a way that will be useful when the user (or you) searches later.
432
+ Use clear, factual language. Include the WHY when relevant.`,
433
+ {
434
+ note: z.string().describe("The note to add - write it from the user's perspective or as a fact about them"),
435
+ category: z.string().optional().describe("Optional category tag (e.g., 'health', 'preferences', 'work')"),
436
+ },
437
+ async ({ note, category }) => {
438
+ try {
439
+ const id = category ? `${category}-${Date.now()}` : undefined;
440
+ const content = category ? `[${category}] ${note}` : note;
441
+ const thought = await client.createThought(content, { id });
442
+ await client.commit(`User note: ${thought.id}`);
443
+ return formatSuccess(thought, `📓 Added to user's notes: "${thought.id}"`);
444
+ } catch (error) {
445
+ return formatError(error);
446
+ }
447
+ }
448
+ );
449
+
353
450
  // ============================================================================
354
451
  // SEARCH TOOLS - Find by meaning
355
452
  // ============================================================================