@j0hanz/memdb 1.2.2 → 1.2.3

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/index.js CHANGED
@@ -19,9 +19,24 @@ const readPackageVersion = async () => {
19
19
  const version = Reflect.get(parsed, 'version');
20
20
  return typeof version === 'string' ? version : undefined;
21
21
  };
22
+ const readServerInstructions = async () => {
23
+ try {
24
+ const text = await readFile(new URL('./instructions.md', import.meta.url), {
25
+ encoding: 'utf-8',
26
+ signal: AbortSignal.timeout(5000),
27
+ });
28
+ const trimmed = text.trim();
29
+ return trimmed.length > 0 ? trimmed : undefined;
30
+ }
31
+ catch {
32
+ return undefined;
33
+ }
34
+ };
22
35
  const packageVersion = await readPackageVersion();
36
+ const serverInstructions = (await readServerInstructions()) ??
37
+ 'A Memory MCP Server for AI Assistants using node:sqlite';
23
38
  const server = new McpServer({ name: 'memdb', version: packageVersion ?? '0.0.0' }, {
24
- instructions: 'A Memory MCP Server for AI Assistants using node:sqlite',
39
+ instructions: serverInstructions,
25
40
  capabilities: { tools: {} },
26
41
  });
27
42
  const patchToolErrorResults = (target) => {
@@ -0,0 +1,92 @@
1
+ # memdb MCP Server Instructions
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.
4
+
5
+ ## Scope & Constraints
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`).
11
+
12
+ ## Tool Guide
13
+
14
+ ### Store
15
+
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.
21
+
22
+ ### Find & Read
23
+
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
+
30
+ ### Update
31
+
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.
35
+
36
+ ### Delete (Destructive)
37
+
38
+ - `delete_memory`: Delete a single memory by `hash`.
39
+ - `delete_memories`: Batch delete up to 50 hashes.
40
+
41
+ Use delete tools only when the user explicitly wants removal.
42
+
43
+ ### Relationships (Knowledge Graph)
44
+
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.
51
+
52
+ ### Deep Recall
53
+
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.
57
+
58
+ ### Health / Overview
59
+
60
+ - `memory_stats`: Returns database stats (counts, oldest/newest).
61
+ - Use to sanity-check the DB or report status.
62
+
63
+ ## Recommended Workflows
64
+
65
+ ### Capture a new memory (single)
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`.
70
+
71
+ ### Retrieve context for a task
72
+
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.
76
+
77
+ ### Maintain quality over time
78
+
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.
82
+
83
+ ## Tagging & Memory Type Guidelines
84
+
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).
88
+
89
+ ## Safety
90
+
91
+ - Do not store secrets (API keys, passwords, tokens, private keys) in memory content.
92
+ - Confirm destructive operations (`delete_*`, `delete_relationship`) before calling them.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@j0hanz/memdb",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "mcpName": "io.github.j0hanz/memdb",
5
5
  "description": "A SQLite-backed MCP memory server with local workspace storage.",
6
6
  "type": "module",
@@ -18,7 +18,7 @@
18
18
  "README.md"
19
19
  ],
20
20
  "scripts": {
21
- "build": "tsc -p tsconfig.build.json && node -e \"require('fs').chmodSync('dist/index.js', '755')\"",
21
+ "build": "tsc -p tsconfig.build.json && node -e \"const fs=require('fs');fs.copyFileSync('src/instructions.md','dist/instructions.md');fs.chmodSync('dist/index.js','755');\"",
22
22
  "prepare": "npm run build",
23
23
  "dev": "tsx watch src/index.ts",
24
24
  "start": "node dist/index.js",