@j0hanz/memdb 1.2.3 → 1.2.4
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 +173 -61
- package/package.json +1 -1
package/dist/instructions.md
CHANGED
|
@@ -1,92 +1,204 @@
|
|
|
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 using 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
|
+
- Batch operations when available: use `store_memories` / `delete_memories` for multiple items.
|
|
11
|
+
- Treat destructive tools (`delete_memory`, `delete_memories`, `delete_relationship`) as destructive: require explicit user confirmation unless the user clearly requested deletion.
|
|
12
|
+
- Keep operations atomic; if a request is vague, ask a clarifying question before calling tools.
|
|
11
13
|
|
|
12
|
-
|
|
14
|
+
### Quick Decision Rules
|
|
13
15
|
|
|
14
|
-
|
|
16
|
+
- If unsure what exists → call `search_memories` or `memory_stats` before mutation.
|
|
17
|
+
- If the user provides multiple items → use `store_memories` (up to 50) or `delete_memories`.
|
|
18
|
+
- If the user asks to delete without a specific target → list matches first and ask which hash.
|
|
19
|
+
- Prefer `update_memory` over delete+recreate when correcting an existing memory.
|
|
15
20
|
|
|
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.
|
|
21
|
+
### Client UX Notes (VS Code)
|
|
21
22
|
|
|
22
|
-
|
|
23
|
+
- Non-read-only tools typically require user confirmation.
|
|
24
|
+
- Tool lists can be cached; users can reset via **MCP: Reset Cached Tools**.
|
|
25
|
+
- Only run MCP servers from trusted sources.
|
|
23
26
|
|
|
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`.
|
|
27
|
+
## Data Model (What the Server Operates On)
|
|
29
28
|
|
|
30
|
-
###
|
|
29
|
+
### Memory
|
|
31
30
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
31
|
+
| Field | Type | Description |
|
|
32
|
+
| ------------- | ---------- | --------------------------------------------------------------------------- |
|
|
33
|
+
| `id` | int | Auto-generated row ID |
|
|
34
|
+
| `hash` | string | MD5 of content (32 hex chars); primary lookup key |
|
|
35
|
+
| `content` | string | 1–100,000 chars; the stored text |
|
|
36
|
+
| `tags` | string[] | 1–100 tags; no whitespace; max 50 chars each; use `kebab-case` |
|
|
37
|
+
| `importance` | int (0–10) | Priority (0=low, 10=critical); higher surfaces first in search |
|
|
38
|
+
| `memory_type` | enum | `general` `fact` `plan` `decision` `reflection` `lesson` `error` `gradient` |
|
|
39
|
+
| `created_at` | ISO 8601 | Creation timestamp |
|
|
40
|
+
| `accessed_at` | ISO 8601 | Last access timestamp |
|
|
35
41
|
|
|
36
|
-
###
|
|
42
|
+
### Relationship (Knowledge Graph Edge)
|
|
37
43
|
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
| Field | Type | Description |
|
|
45
|
+
| --------------- | ------ | ----------------------------------------------------------------- |
|
|
46
|
+
| `from_hash` | string | Source memory hash |
|
|
47
|
+
| `to_hash` | string | Target memory hash |
|
|
48
|
+
| `relation_type` | string | No whitespace; e.g., `depends_on`, `causes`, `part_of`, `follows` |
|
|
40
49
|
|
|
41
|
-
|
|
50
|
+
### Constraints
|
|
42
51
|
|
|
43
|
-
|
|
52
|
+
- Changing content changes the hash (content-addressed).
|
|
53
|
+
- Tags and `relation_type` must not contain whitespace.
|
|
54
|
+
- Search query: 1–1,000 chars, max 50 terms.
|
|
55
|
+
- Batch limits: 50 items for `store_memories` and `delete_memories`.
|
|
44
56
|
|
|
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.
|
|
57
|
+
## Response Shape
|
|
51
58
|
|
|
52
|
-
|
|
59
|
+
All tools return JSON in `structuredContent`:
|
|
53
60
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
61
|
+
```json
|
|
62
|
+
// Success
|
|
63
|
+
{ "ok": true, "result": { ... } }
|
|
57
64
|
|
|
58
|
-
|
|
65
|
+
// Error
|
|
66
|
+
{ "ok": false, "error": { "code": "E_CODE", "message": "..." } }
|
|
67
|
+
```
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
- Use to sanity-check the DB or report status.
|
|
69
|
+
Error responses also set `isError: true` on the top-level tool result.
|
|
62
70
|
|
|
63
|
-
## Recommended
|
|
71
|
+
## Workflows (Recommended)
|
|
64
72
|
|
|
65
|
-
### Capture a new memory
|
|
73
|
+
### 1) Capture a new memory
|
|
66
74
|
|
|
67
|
-
1.
|
|
68
|
-
2. Choose
|
|
69
|
-
3. Call `store_memory`.
|
|
75
|
+
1. Prepare content (crisp, 1–3 sentences).
|
|
76
|
+
2. Choose 2–6 tags: domain tags (`auth`, `postgres`) + intent tags (`decision`, `bug`).
|
|
77
|
+
3. Call `store_memory`. Record the returned `hash` if you need to reference it later.
|
|
70
78
|
|
|
71
|
-
### Retrieve context for a task
|
|
79
|
+
### 2) Retrieve context for a task
|
|
72
80
|
|
|
73
|
-
1.
|
|
74
|
-
2. If you need related context,
|
|
75
|
-
3.
|
|
81
|
+
1. Call `search_memories` with a focused query (include relevant tag text in the query).
|
|
82
|
+
2. If you need related context, call `recall` with `depth: 1` or `2`.
|
|
83
|
+
3. For verbatim content of a specific hash, call `get_memory`.
|
|
76
84
|
|
|
77
|
-
### Maintain quality over time
|
|
85
|
+
### 3) Maintain quality over time
|
|
78
86
|
|
|
79
|
-
1. Prefer `update_memory` over creating duplicates when
|
|
80
|
-
2. Use `create_relationship` to
|
|
81
|
-
3. Use
|
|
87
|
+
1. Prefer `update_memory` over creating duplicates when correcting content.
|
|
88
|
+
2. Use `create_relationship` to link durable facts/decisions in the knowledge graph.
|
|
89
|
+
3. Use `delete_memory` / `delete_memories` only with explicit user intent.
|
|
82
90
|
|
|
83
|
-
##
|
|
91
|
+
## Tools (What to Use, When)
|
|
84
92
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
93
|
+
### store_memory
|
|
94
|
+
|
|
95
|
+
Store a single memory with tags.
|
|
96
|
+
|
|
97
|
+
- **Use when:** You have one clear item to persist.
|
|
98
|
+
- **Args:** `content` (req), `tags` (req, 1–100), `importance` (opt, 0–10), `memory_type` (opt).
|
|
99
|
+
- **Returns:** `{ id, hash, isNew }`.
|
|
100
|
+
- **Notes:** Idempotent (same content → same hash, `isNew: false`).
|
|
101
|
+
|
|
102
|
+
### store_memories
|
|
103
|
+
|
|
104
|
+
Batch store up to 50 memories.
|
|
105
|
+
|
|
106
|
+
- **Use when:** Importing multiple items at once.
|
|
107
|
+
- **Args:** `items[]` (each has `content`, `tags`, optional `importance`, `memory_type`).
|
|
108
|
+
- **Returns:** `{ results, succeeded, failed }`.
|
|
109
|
+
- **Notes:** Partial success supported.
|
|
110
|
+
|
|
111
|
+
### search_memories
|
|
112
|
+
|
|
113
|
+
Full-text + tag search.
|
|
114
|
+
|
|
115
|
+
- **Use when:** Discovering what exists; start here before mutating.
|
|
116
|
+
- **Args:** `query` (1–1,000 chars, max 50 terms).
|
|
117
|
+
- **Returns:** Array of `Memory` + `relevance`, up to 100 results.
|
|
118
|
+
- **Notes:** Read-only. Content matches rank higher than tag matches.
|
|
119
|
+
|
|
120
|
+
### get_memory
|
|
121
|
+
|
|
122
|
+
Fetch a single memory by hash.
|
|
123
|
+
|
|
124
|
+
- **Use when:** You need verbatim content after search identified a hash.
|
|
125
|
+
- **Args:** `hash` (32 hex chars).
|
|
126
|
+
- **Returns:** `Memory`.
|
|
127
|
+
- **Notes:** Read-only. Returns `E_NOT_FOUND` if missing.
|
|
128
|
+
|
|
129
|
+
### update_memory
|
|
130
|
+
|
|
131
|
+
Update content (and optionally replace tags).
|
|
132
|
+
|
|
133
|
+
- **Use when:** Correcting or refining an existing memory.
|
|
134
|
+
- **Args:** `hash` (req), `content` (req), `tags` (opt, replaces all if provided).
|
|
135
|
+
- **Returns:** `{ updated: true, oldHash, newHash }`.
|
|
136
|
+
- **Notes:** Hash changes because content changes. Idempotent.
|
|
137
|
+
|
|
138
|
+
### delete_memory
|
|
139
|
+
|
|
140
|
+
Delete a single memory by hash.
|
|
141
|
+
|
|
142
|
+
- **Use when:** User explicitly wants removal.
|
|
143
|
+
- **Args:** `hash`.
|
|
144
|
+
- **Returns:** `{ deleted: true }` or `E_NOT_FOUND`.
|
|
145
|
+
- **Notes:** Destructive. Confirm before calling.
|
|
146
|
+
|
|
147
|
+
### delete_memories
|
|
148
|
+
|
|
149
|
+
Batch delete up to 50 hashes.
|
|
150
|
+
|
|
151
|
+
- **Use when:** Bulk cleanup with explicit user intent.
|
|
152
|
+
- **Args:** `hashes[]`.
|
|
153
|
+
- **Returns:** `{ results, succeeded, failed }`.
|
|
154
|
+
- **Notes:** Destructive. Partial success supported.
|
|
155
|
+
|
|
156
|
+
### create_relationship
|
|
157
|
+
|
|
158
|
+
Link two memories with a typed edge.
|
|
159
|
+
|
|
160
|
+
- **Use when:** Building a knowledge graph (e.g., `depends_on`, `causes`, `part_of`).
|
|
161
|
+
- **Args:** `from_hash`, `to_hash`, `relation_type`.
|
|
162
|
+
- **Returns:** `{ id, isNew }`.
|
|
163
|
+
- **Notes:** Idempotent.
|
|
164
|
+
|
|
165
|
+
### get_relationships
|
|
166
|
+
|
|
167
|
+
List relationships for a memory.
|
|
168
|
+
|
|
169
|
+
- **Use when:** Inspecting local graph around one memory.
|
|
170
|
+
- **Args:** `hash`, `direction` (opt: `outgoing`, `incoming`, `both`; default `both`).
|
|
171
|
+
- **Returns:** Array of `Relationship`.
|
|
172
|
+
- **Notes:** Read-only.
|
|
173
|
+
|
|
174
|
+
### delete_relationship
|
|
175
|
+
|
|
176
|
+
Remove a relationship edge.
|
|
177
|
+
|
|
178
|
+
- **Use when:** An edge is wrong or outdated.
|
|
179
|
+
- **Args:** `from_hash`, `to_hash`, `relation_type`.
|
|
180
|
+
- **Returns:** `{ deleted: true }` or `E_NOT_FOUND`.
|
|
181
|
+
- **Notes:** Destructive. Confirm before calling.
|
|
182
|
+
|
|
183
|
+
### recall
|
|
184
|
+
|
|
185
|
+
Search + traverse relationships to return a connected cluster.
|
|
186
|
+
|
|
187
|
+
- **Use when:** You need broader context beyond keyword matches.
|
|
188
|
+
- **Args:** `query`, `depth` (opt, 0–3; default 1).
|
|
189
|
+
- **Returns:** `{ memories, relationships, depth }`.
|
|
190
|
+
- **Notes:** Read-only. Use `depth: 1–2` by default.
|
|
191
|
+
|
|
192
|
+
### memory_stats
|
|
193
|
+
|
|
194
|
+
Database statistics and health.
|
|
195
|
+
|
|
196
|
+
- **Use when:** Sanity-checking the DB or reporting status.
|
|
197
|
+
- **Args:** (none).
|
|
198
|
+
- **Returns:** `{ memoryCount, tagCount, oldestMemory, newestMemory }`.
|
|
199
|
+
- **Notes:** Read-only.
|
|
88
200
|
|
|
89
201
|
## Safety
|
|
90
202
|
|
|
91
|
-
- Do not store secrets (API keys, passwords, tokens, private keys) in memory content.
|
|
92
|
-
- Confirm destructive operations (`
|
|
203
|
+
- **Do not store secrets** (API keys, passwords, tokens, private keys) in memory content.
|
|
204
|
+
- **Confirm destructive operations** (`delete_memory`, `delete_memories`, `delete_relationship`) before calling.
|