@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.
Files changed (2) hide show
  1. package/dist/instructions.md +143 -62
  2. package/package.json +1 -1
@@ -1,92 +1,173 @@
1
- # memdb MCP Server Instructions
1
+ # memdb MCP Server — AI Usage Instructions
2
2
 
3
- This server provides **local, SQLite-backed long-term memory**. Use it to store, retrieve, and organize short text memories (notes, facts, decisions, lessons) with tags and optional relationships.
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
- ## Scope & Constraints
5
+ ## Operating Rules
6
6
 
7
- - This server only manages memories in a local SQLite DB (default: `<cwd>/.memdb/memory.db`). It does not read/write project files.
8
- - All tool results return JSON in `structuredContent` with `{ ok: true, result }` or `{ ok: false, error }`.
9
- - Memory identity is an MD5 `hash` (32 hex chars). Changing content changes the hash.
10
- - Tags and relation types must not contain whitespace (use `kebab-case`).
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
- ## Tool Guide
14
+ ### Strategies
13
15
 
14
- ### Store
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
- - `store_memory`: Create or deduplicate a single memory.
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
- ### Find & Read
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
- - `search_memories`: Search across content + tags.
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
- ### Update
31
+ ### 1) Capture a new memory
31
32
 
32
- - `update_memory`: Replace content (and optionally replace tags) for a given `hash`.
33
- - Use to correct or refine a memory.
34
- - Expect a new `hash` in the result.
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
- ### Delete (Destructive)
37
+ ### 2) Retrieve context for a task
37
38
 
38
- - `delete_memory`: Delete a single memory by `hash`.
39
- - `delete_memories`: Batch delete up to 50 hashes.
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
- Use delete tools only when the user explicitly wants removal.
43
+ ### 3) Maintain quality over time
42
44
 
43
- ### Relationships (Knowledge Graph)
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
- - `create_relationship`: Create a typed edge `from_hash` → `to_hash`.
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
- ### Deep Recall
51
+ ### store_memory
53
52
 
54
- - `recall`: Search + traverse relationships to return a connected cluster.
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
- ### Health / Overview
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
- - `memory_stats`: Returns database stats (counts, oldest/newest).
61
- - Use to sanity-check the DB or report status.
59
+ ### store_memories
62
60
 
63
- ## Recommended Workflows
61
+ Batch store up to 50 memories.
64
62
 
65
- ### Capture a new memory (single)
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
- 1. Choose crisp content (1–3 sentences).
68
- 2. Choose stable tags (topic + type), e.g. `auth`, `decision`, `bug`, `postgres`.
69
- 3. Call `store_memory`.
67
+ ### search_memories
70
68
 
71
- ### Retrieve context for a task
69
+ Full-text + tag search.
72
70
 
73
- 1. Use `search_memories` with a focused query.
74
- 2. If you need related context, use `recall` (depth 1–2).
75
- 3. Use `get_memory` for any specific hash you need verbatim.
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
- ### Maintain quality over time
76
+ ### get_memory
78
77
 
79
- 1. Prefer `update_memory` over creating duplicates when you are correcting an existing item.
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
- ## Tagging & Memory Type Guidelines
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
- - Prefer 2–6 tags per memory: 1–2 domain tags + 1–2 intent tags.
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
- ## Safety
86
+ Update content (and optionally replace tags).
90
87
 
91
- - Do not store secrets (API keys, passwords, tokens, private keys) in memory content.
92
- - Confirm destructive operations (`delete_*`, `delete_relationship`) before calling them.
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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j0hanz/memdb",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
4
4
  "mcpName": "io.github.j0hanz/memdb",
5
5
  "description": "A SQLite-backed MCP memory server with local workspace storage.",
6
6
  "type": "module",