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.
- package/INDRA_INSTRUCTIONS.md +19 -24
- package/package.json +1 -1
- package/src/index.ts +116 -19
package/INDRA_INSTRUCTIONS.md
CHANGED
|
@@ -1,33 +1,28 @@
|
|
|
1
|
-
# Indra:
|
|
1
|
+
# Indra: User's Personal Knowledge Base
|
|
2
2
|
|
|
3
|
-
You have access to **Indra**,
|
|
3
|
+
You have access to **Indra**, the user's personal notes system. Help them build and use it.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## PRIMARY TOOLS
|
|
6
6
|
|
|
7
|
-
###
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
-
###
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
##
|
|
18
|
+
## THE PATTERN
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
##
|
|
24
|
+
## IMPORTANT
|
|
28
25
|
|
|
29
|
-
|
|
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
|
-
|
|
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
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:
|
|
35
|
+
const SERVER_INSTRUCTIONS = `# Indra: User's Personal Knowledge Base
|
|
36
36
|
|
|
37
37
|
## What This Is
|
|
38
|
-
Indra
|
|
39
|
-
|
|
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
|
-
##
|
|
42
|
+
## PRIMARY TOOLS
|
|
42
43
|
|
|
43
|
-
###
|
|
44
|
-
Search
|
|
45
|
-
-
|
|
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
|
-
###
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
##
|
|
57
|
-
1.
|
|
58
|
-
2. Answer the question
|
|
59
|
-
3.
|
|
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
|
// ============================================================================
|