@j0hanz/memdb 1.2.3 → 1.2.5
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/dist/instructions.md +143 -62
- package/package.json +1 -1
package/dist/instructions.md
CHANGED
|
@@ -1,92 +1,173 @@
|
|
|
1
|
-
# memdb MCP Server Instructions
|
|
1
|
+
# memdb MCP Server — AI Usage Instructions
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Use this server to store and retrieve persistent memories (facts, decisions, lessons, plans) in a local SQLite database. Prefer these tools over "remembering" state in chat.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Operating Rules
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
7
|
+
- Use tools only when the operation changes or verifies memory state.
|
|
8
|
+
- Prefer `search_memories` or `memory_stats` to establish state before updating/deleting.
|
|
9
|
+
- Operate by stable identifiers (`hash`, 32-char hex MD5) rather than ambiguous user text.
|
|
10
|
+
- Treat destructive tools (`delete_memory`, `delete_memories`, `delete_relationship`) as destructive: require explicit user confirmation unless clearly requested.
|
|
11
|
+
- Keep operations atomic; if a request is vague, ask a clarifying question.
|
|
12
|
+
- **Client UX:** Tool lists can be cached (reset via "MCP: Reset Cached Tools"). Only run MCP servers from trusted sources.
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
### Strategies
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
- **Discovery:** Start with `search_memories` or `memory_stats` to discover what exists. Use `recall` (depth 1-2) when you need connected context.
|
|
17
|
+
- **Action:** Use `store_memories` for batch imports (up to 50). Prefer `update_memory` to fix content (preserves history/context better than delete+create). Always confirm explicit deletions with the user.
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
- Use when you have one clear item.
|
|
18
|
-
- Provide `tags` (1–100). Optional: `importance` (0–10), `memory_type`.
|
|
19
|
-
- `store_memories`: Batch store up to 50 memories.
|
|
20
|
-
- Use for importing many items; supports partial success.
|
|
19
|
+
## Data Model
|
|
21
20
|
|
|
22
|
-
|
|
21
|
+
- **Memory:**
|
|
22
|
+
- `hash` (MD5 of content, primary key)
|
|
23
|
+
- `content` (1–100k chars)
|
|
24
|
+
- `tags` (1–100 items, no whitespace, `kebab-case`)
|
|
25
|
+
- `importance` (0–10, 10=critical)
|
|
26
|
+
- `memory_type` (`general`, `fact`, `plan`, `decision`, `reflection`, `lesson`, `error`, `gradient`)
|
|
27
|
+
- **Relationship:** Directed edge (`from_hash` → `to_hash`) with a typed label (`relation_type`).
|
|
23
28
|
|
|
24
|
-
|
|
25
|
-
- Use first for discovery.
|
|
26
|
-
- Prefer specific queries and tags (include tag text in the query).
|
|
27
|
-
- `get_memory`: Fetch a memory by `hash`.
|
|
28
|
-
- Use after search results identify a specific `hash`.
|
|
29
|
+
## Workflows
|
|
29
30
|
|
|
30
|
-
###
|
|
31
|
+
### 1) Capture a new memory
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
1. Prepare content (crisp, 1–3 sentences).
|
|
34
|
+
2. Choose 2–6 tags: domain tags (`auth`, `postgres`) + intent tags (`decision`, `bug`).
|
|
35
|
+
3. Call `store_memory`. Record the returned `hash` if you need to reference it later.
|
|
35
36
|
|
|
36
|
-
###
|
|
37
|
+
### 2) Retrieve context for a task
|
|
37
38
|
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
1. Call `search_memories` with a focused query (include relevant tag text in the query).
|
|
40
|
+
2. If you need related context, call `recall` with `depth: 1` or `2`.
|
|
41
|
+
3. For verbatim content of a specific hash, call `get_memory`.
|
|
40
42
|
|
|
41
|
-
|
|
43
|
+
### 3) Maintain quality over time
|
|
42
44
|
|
|
43
|
-
|
|
45
|
+
1. Prefer `update_memory` over creating duplicates when correcting content.
|
|
46
|
+
2. Use `create_relationship` to link durable facts/decisions in the knowledge graph.
|
|
47
|
+
3. Use `delete_memory` / `delete_memories` only with explicit user intent.
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
- Use to connect related memories (e.g., `depends_on`, `causes`, `part_of`).
|
|
47
|
-
- `get_relationships`: List relationships for a memory.
|
|
48
|
-
- Use to inspect the local graph around one memory.
|
|
49
|
-
- `delete_relationship`: Remove a relationship.
|
|
50
|
-
- Use when an edge is wrong/outdated.
|
|
49
|
+
## Tools
|
|
51
50
|
|
|
52
|
-
###
|
|
51
|
+
### store_memory
|
|
53
52
|
|
|
54
|
-
|
|
55
|
-
- Use when you need broader context beyond keyword matches.
|
|
56
|
-
- `depth` controls hops (0–3). Use 1–2 by default.
|
|
53
|
+
Store a single memory with tags.
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
- **Use when:** You have one clear item to persist.
|
|
56
|
+
- **Args:** `content` (req), `tags` (req), `importance` (opt), `memory_type` (opt).
|
|
57
|
+
- **Returns:** `{ id, hash, isNew }`.
|
|
59
58
|
|
|
60
|
-
|
|
61
|
-
- Use to sanity-check the DB or report status.
|
|
59
|
+
### store_memories
|
|
62
60
|
|
|
63
|
-
|
|
61
|
+
Batch store up to 50 memories.
|
|
64
62
|
|
|
65
|
-
|
|
63
|
+
- **Use when:** Importing multiple items at once.
|
|
64
|
+
- **Args:** `items[]` (each has `content`, `tags`, optional `importance`, `memory_type`).
|
|
65
|
+
- **Returns:** `{ results, succeeded, failed }`.
|
|
66
66
|
|
|
67
|
-
|
|
68
|
-
2. Choose stable tags (topic + type), e.g. `auth`, `decision`, `bug`, `postgres`.
|
|
69
|
-
3. Call `store_memory`.
|
|
67
|
+
### search_memories
|
|
70
68
|
|
|
71
|
-
|
|
69
|
+
Full-text + tag search.
|
|
72
70
|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
- **Use when:** Discovering what exists; start here before mutating.
|
|
72
|
+
- **Args:** `query` (1–1,000 chars).
|
|
73
|
+
- **Returns:** Array of `Memory` + `relevance`, up to 100 results.
|
|
74
|
+
- **Notes:** Content matches rank higher than tag matches.
|
|
76
75
|
|
|
77
|
-
###
|
|
76
|
+
### get_memory
|
|
78
77
|
|
|
79
|
-
|
|
80
|
-
2. Use `create_relationship` to connect durable facts/decisions.
|
|
81
|
-
3. Use delete tools only with explicit user intent.
|
|
78
|
+
Fetch a single memory by hash.
|
|
82
79
|
|
|
83
|
-
|
|
80
|
+
- **Use when:** You need verbatim content after search identified a hash.
|
|
81
|
+
- **Args:** `hash` (32 hex chars).
|
|
82
|
+
- **Returns:** `Memory` object.
|
|
84
83
|
|
|
85
|
-
|
|
86
|
-
- `memory_type` is optional; use it when it helps retrieval: `fact`, `decision`, `plan`, `lesson`, `error`, `reflection`, `gradient`, `general`.
|
|
87
|
-
- Use `importance` to surface critical items (0=low, 10=critical).
|
|
84
|
+
### update_memory
|
|
88
85
|
|
|
89
|
-
|
|
86
|
+
Update content (and optionally replace tags).
|
|
90
87
|
|
|
91
|
-
-
|
|
92
|
-
-
|
|
88
|
+
- **Use when:** Correcting or refining an existing memory.
|
|
89
|
+
- **Args:** `hash` (req), `content` (req), `tags` (opt, replaces all).
|
|
90
|
+
- **Returns:** `{ updated: true, oldHash, newHash }`.
|
|
91
|
+
- **Notes:** Hash changes because content changes (content-addressed).
|
|
92
|
+
|
|
93
|
+
### delete_memory
|
|
94
|
+
|
|
95
|
+
Delete a single memory by hash.
|
|
96
|
+
|
|
97
|
+
- **Use when:** User explicitly wants removal.
|
|
98
|
+
- **Args:** `hash`.
|
|
99
|
+
- **Returns:** `{ deleted: true }` or error if not found.
|
|
100
|
+
|
|
101
|
+
### delete_memories
|
|
102
|
+
|
|
103
|
+
Batch delete up to 50 hashes.
|
|
104
|
+
|
|
105
|
+
- **Use when:** Bulk cleanup with explicit user intent.
|
|
106
|
+
- **Args:** `hashes[]`.
|
|
107
|
+
- **Returns:** `{ results, succeeded, failed }`.
|
|
108
|
+
|
|
109
|
+
### create_relationship
|
|
110
|
+
|
|
111
|
+
Link two memories with a typed edge.
|
|
112
|
+
|
|
113
|
+
- **Use when:** Building a knowledge graph (e.g., `depends_on`, `causes`, `part_of`).
|
|
114
|
+
- **Args:** `from_hash`, `to_hash`, `relation_type`.
|
|
115
|
+
- **Returns:** `{ id, isNew }`.
|
|
116
|
+
|
|
117
|
+
### get_relationships
|
|
118
|
+
|
|
119
|
+
List relationships for a memory.
|
|
120
|
+
|
|
121
|
+
- **Use when:** Inspecting local graph around one memory.
|
|
122
|
+
- **Args:** `hash`, `direction` (opt: `outgoing`, `incoming`, `both`; default `both`).
|
|
123
|
+
- **Returns:** Array of `Relationship` objects.
|
|
124
|
+
|
|
125
|
+
### delete_relationship
|
|
126
|
+
|
|
127
|
+
Remove a relationship edge.
|
|
128
|
+
|
|
129
|
+
- **Use when:** An edge is wrong or outdated.
|
|
130
|
+
- **Args:** `from_hash`, `to_hash`, `relation_type`.
|
|
131
|
+
- **Returns:** `{ deleted: true }`.
|
|
132
|
+
|
|
133
|
+
### recall
|
|
134
|
+
|
|
135
|
+
Search + traverse relationships to return a connected cluster.
|
|
136
|
+
|
|
137
|
+
- **Use when:** You need broader context beyond keyword matches.
|
|
138
|
+
- **Args:** `query`, `depth` (opt, 0–3; default 1).
|
|
139
|
+
- **Returns:** `{ memories, relationships, depth }`.
|
|
140
|
+
|
|
141
|
+
### memory_stats
|
|
142
|
+
|
|
143
|
+
Database statistics and health.
|
|
144
|
+
|
|
145
|
+
- **Use when:** Sanity-checking the DB or reporting status.
|
|
146
|
+
- **Args:** (none).
|
|
147
|
+
- **Returns:** `{ memoryCount, tagCount, oldestMemory, newestMemory }`.
|
|
148
|
+
|
|
149
|
+
## Response Shape
|
|
150
|
+
|
|
151
|
+
Success: `{ "ok": true, "result": { ... } }`
|
|
152
|
+
Error: `{ "ok": false, "error": { "code": "E_...", "message": "..." } }`
|
|
153
|
+
|
|
154
|
+
### Common Errors
|
|
155
|
+
|
|
156
|
+
| Code | Meaning | Resolution |
|
|
157
|
+
| --------------- | ----------------------------- | ----------------------------------- |
|
|
158
|
+
| `E_NOT_FOUND` | Memory/Relationship not found | Check hash or create new |
|
|
159
|
+
| `E_INVALID_ARG` | Validation failed (zod) | Check limits, types, and formatting |
|
|
160
|
+
| `E_TOOL_ERROR` | Internal/Db error | Check server logs or stats |
|
|
161
|
+
|
|
162
|
+
## Limits
|
|
163
|
+
|
|
164
|
+
- **Content Size:** 100,000 chars per memory
|
|
165
|
+
- **Tag Count:** 100 per memory
|
|
166
|
+
- **Tag Length:** 50 chars (no whitespace)
|
|
167
|
+
- **Batch Size:** 50 items (store/delete)
|
|
168
|
+
- **Query Length:** 1,000 chars
|
|
169
|
+
|
|
170
|
+
## Security
|
|
171
|
+
|
|
172
|
+
- **No Secrets:** Do not store API keys, passwords, or PII in memory content.
|
|
173
|
+
- **Confirmation:** Always ask before using `delete_*` tools unless the user explicitly requested it.
|