@j0hanz/memdb 1.2.8 → 1.3.0
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/README.md +110 -287
- package/dist/assets/logo.svg +12 -0
- package/dist/config.d.ts +0 -1
- package/dist/config.js +0 -1
- package/dist/core/db.d.ts +6 -3
- package/dist/core/db.js +102 -47
- package/dist/core/memory-read.d.ts +1 -2
- package/dist/core/memory-read.js +32 -18
- package/dist/core/memory-write.d.ts +1 -2
- package/dist/core/memory-write.js +59 -83
- package/dist/core/relationships.d.ts +0 -1
- package/dist/core/relationships.js +15 -36
- package/dist/core/search.d.ts +2 -3
- package/dist/core/search.js +96 -89
- package/dist/index.d.ts +0 -1
- package/dist/index.js +42 -15
- package/dist/instructions.md +41 -24
- package/dist/logger.d.ts +0 -1
- package/dist/logger.js +0 -1
- package/dist/protocol-version-guard.d.ts +0 -1
- package/dist/protocol-version-guard.js +0 -1
- package/dist/schemas.d.ts +0 -1
- package/dist/schemas.js +14 -11
- package/dist/stdio-transport.d.ts +0 -1
- package/dist/stdio-transport.js +0 -1
- package/dist/tools.d.ts +1 -2
- package/dist/tools.js +195 -211
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -1
- package/package.json +23 -20
- package/dist/config.d.ts.map +0 -1
- package/dist/config.js.map +0 -1
- package/dist/core/db.d.ts.map +0 -1
- package/dist/core/db.js.map +0 -1
- package/dist/core/memory-read.d.ts.map +0 -1
- package/dist/core/memory-read.js.map +0 -1
- package/dist/core/memory-write.d.ts.map +0 -1
- package/dist/core/memory-write.js.map +0 -1
- package/dist/core/relationships.d.ts.map +0 -1
- package/dist/core/relationships.js.map +0 -1
- package/dist/core/search.d.ts.map +0 -1
- package/dist/core/search.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/logger.d.ts.map +0 -1
- package/dist/logger.js.map +0 -1
- package/dist/protocol-version-guard.d.ts.map +0 -1
- package/dist/protocol-version-guard.js.map +0 -1
- package/dist/schemas.d.ts.map +0 -1
- package/dist/schemas.js.map +0 -1
- package/dist/stdio-transport.d.ts.map +0 -1
- package/dist/stdio-transport.js.map +0 -1
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js.map +0 -1
- package/dist/types.d.ts.map +0 -1
- package/dist/types.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,51 +1,57 @@
|
|
|
1
|
-
#
|
|
1
|
+
# MemDB MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<img src="assets/logo.svg" alt="MemDB MCP Server Logo" width="225" />
|
|
4
4
|
|
|
5
|
-
[](https://www.npmjs.com/package/@j0hanz/memdb)
|
|
5
|
+
[](https://www.npmjs.com/package/@j0hanz/memdb) [](https://github.com/j0hanz/memdb-mcp-server/blob/master/package.json)
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
[](https://insiders.vscode.dev/redirect/mcp/install?name=memdb&inputs=%5B%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fmemdb%40latest%22%5D%7D)[](https://insiders.vscode.dev/redirect/mcp/install?name=memdb&inputs=%5B%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fmemdb%40latest%22%5D%7D&quality=insiders)
|
|
7
|
+
[](https://insiders.vscode.dev/redirect/mcp/install?name=memdb&inputs=%5B%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fmemdb%40latest%22%5D%7D) [](https://insiders.vscode.dev/redirect/mcp/install?name=memdb&inputs=%5B%5D&config=%7B%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40j0hanz%2Fmemdb%40latest%22%5D%7D&quality=insiders)
|
|
10
8
|
|
|
11
9
|
[](https://cursor.com/install-mcp?name=memdb&config=eyJjb21tYW5kIjoibnB4IiwiYXJncyI6WyIteSIsIkBqMGhhbnovbWVtZGJAbGF0ZXN0Il19)
|
|
12
10
|
|
|
13
|
-
|
|
11
|
+
A specialized Memory MCP Server that provides a local Knowledge Graph and full-text search capabilities for AI assistants, backed by SQLite.
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
| :--------------- | :---------------------------------------------------------------- |
|
|
17
|
-
| Memory Storage | Store text memories with tags |
|
|
18
|
-
| Full-Text Search | FTS5-backed tokenized search with relevance ranking |
|
|
19
|
-
| Stats | Memory and tag counts + activity range |
|
|
20
|
-
| Local Privacy | All data stored locally in SQLite (`.memdb/memory.db` by default) |
|
|
13
|
+
## Overview
|
|
21
14
|
|
|
22
|
-
|
|
15
|
+
MemDB allows AI assistants to persist long-term memories, facts, and relationships in a local SQLite database. Beyond simple storage, it supports **content-deduplicated versioning**, **tag-based organization**, and **graph relationships** (linking memories together). It includes a powerful `recall` tool that traverses these relationships to retrieve connected context, effectively acting as a graph-augmented RAG system for your workspace.
|
|
23
16
|
|
|
24
|
-
|
|
17
|
+
## Key Features
|
|
25
18
|
|
|
26
|
-
|
|
19
|
+
- **Local Storage**: All data persists in a local SQLite database (`.memdb/memory.db`) within your workspace.
|
|
20
|
+
- **Knowledge Graph**: Link memories with typed relationships (e.g., `causes`, `depends_on`, `related_to`).
|
|
21
|
+
- **Graph Traversal**: `recall` tool traverses the graph (up to 3 hops) to find connected context.
|
|
22
|
+
- **Full-Text Search**: Powered by SQLite FTS5 for fast, relevance-ranked searches.
|
|
23
|
+
- **Deduplication**: Content is automatically hashed (SHA-256) to prevent duplicate storage.
|
|
24
|
+
- **Categorization**: Rich metadata support including tags, importance levels, and memory types.
|
|
25
|
+
- **Batch Operations**: dedicated tools for bulk `store` and `delete` actions.
|
|
27
26
|
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
"memdb": {
|
|
31
|
-
"command": "npx",
|
|
32
|
-
"args": ["-y", "@j0hanz/memdb@latest"]
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
```
|
|
27
|
+
## Tech Stack
|
|
36
28
|
|
|
37
|
-
|
|
29
|
+
- **Runtime**: Node.js >= 22.0.0 (Required for native `node:sqlite`)
|
|
30
|
+
- **Database**: SQLite (using `node:sqlite` sync API)
|
|
31
|
+
- **Protocol**: Model Context Protocol (MCP) SDK `v1.26.0+`
|
|
32
|
+
- **Validation**: Zod schema validation
|
|
33
|
+
- **Architecture**: Layered (Core DB <-> Tools <-> Transport)
|
|
38
34
|
|
|
39
|
-
|
|
35
|
+
## Requirements
|
|
36
|
+
|
|
37
|
+
- **Node.js**: Version **22.0.0** or higher is **strictly required**. This server uses the native `node:sqlite` module available only in recent Node.js versions.
|
|
38
|
+
|
|
39
|
+
## Quickstart
|
|
40
|
+
|
|
41
|
+
Run directly with `npx`:
|
|
40
42
|
|
|
41
43
|
```bash
|
|
42
44
|
npx -y @j0hanz/memdb@latest
|
|
43
45
|
```
|
|
44
46
|
|
|
45
|
-
|
|
47
|
+
This will start the server on stdio. The database will be created at `.memdb/memory.db` in the current working directory.
|
|
48
|
+
|
|
49
|
+
## Installation
|
|
50
|
+
|
|
51
|
+
### NPX (Recommended)
|
|
46
52
|
|
|
47
53
|
```bash
|
|
48
|
-
|
|
54
|
+
npx -y @j0hanz/memdb@latest
|
|
49
55
|
```
|
|
50
56
|
|
|
51
57
|
### From Source
|
|
@@ -55,208 +61,66 @@ git clone https://github.com/j0hanz/memdb-mcp-server.git
|
|
|
55
61
|
cd memdb-mcp-server
|
|
56
62
|
npm install
|
|
57
63
|
npm run build
|
|
64
|
+
npm start
|
|
58
65
|
```
|
|
59
66
|
|
|
60
|
-
##
|
|
61
|
-
|
|
62
|
-
The server uses a local SQLite database at `<cwd>/.memdb/memory.db`. The
|
|
63
|
-
directory is created automatically when needed. All data remains local to your
|
|
64
|
-
workspace.
|
|
65
|
-
|
|
66
|
-
> **Tip:** Add `.memdb/` to your `.gitignore` to keep your memory database out of
|
|
67
|
-
> version control:
|
|
68
|
-
>
|
|
69
|
-
> ```bash
|
|
70
|
-
> echo ".memdb/" >> .gitignore
|
|
71
|
-
> ```
|
|
72
|
-
|
|
73
|
-
To completely reset or remove all stored memories, simply delete the `.memdb/`
|
|
74
|
-
folder. The server will create a fresh database on the next run.
|
|
75
|
-
|
|
76
|
-
## Tool Response Format
|
|
77
|
-
|
|
78
|
-
All tools return structured JSON in `structuredContent`. For backwards
|
|
79
|
-
compatibility, the first `content` item is a JSON string that matches
|
|
80
|
-
`structuredContent`.
|
|
81
|
-
|
|
82
|
-
Success (`structuredContent`):
|
|
83
|
-
|
|
84
|
-
```json
|
|
85
|
-
{
|
|
86
|
-
"ok": true,
|
|
87
|
-
"result": { "...": "..." }
|
|
88
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
Error (`structuredContent`):
|
|
92
|
-
|
|
93
|
-
```json
|
|
94
|
-
{
|
|
95
|
-
"ok": false,
|
|
96
|
-
"error": {
|
|
97
|
-
"code": "E_CODE",
|
|
98
|
-
"message": "Human-readable message"
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
```
|
|
102
|
-
|
|
103
|
-
Error responses also set `isError: true` on the top-level tool result.
|
|
104
|
-
|
|
105
|
-
Example `content[0].text`:
|
|
106
|
-
|
|
107
|
-
```text
|
|
108
|
-
{"ok":true,"result":{...}}
|
|
109
|
-
```
|
|
110
|
-
|
|
111
|
-
## Tools
|
|
67
|
+
## Configuration
|
|
112
68
|
|
|
113
|
-
|
|
69
|
+
The server is configured via environment variables.
|
|
114
70
|
|
|
115
|
-
|
|
71
|
+
| Environment Variable | Description | Default |
|
|
72
|
+
| :---------------------- | :---------------------------------------------------------------------- | :----------------- |
|
|
73
|
+
| `MEMDB_PATH` | Path to the SQLite database file. Use `:memory:` for ephemeral storage. | `.memdb/memory.db` |
|
|
74
|
+
| `MEMDB_LOG_LEVEL` | Logging level (`info`, `warn`, `error`). | `info` |
|
|
75
|
+
| `MEMDB_TOOL_TIMEOUT_MS` | Execution timeout for tools in milliseconds. | `15000` |
|
|
116
76
|
|
|
117
|
-
|
|
118
|
-
| :-------- | :------- | :------- | :------ | :-------------------------------------------------- |
|
|
119
|
-
| `content` | string | Yes | - | The content of the memory (1-100000 chars) |
|
|
120
|
-
| `tags` | string[] | Yes | - | Tags (1-100 tags, no whitespace, max 50 chars each) |
|
|
77
|
+
**Note**: To keep the database out of version control, add `.memdb/` to your `.gitignore`.
|
|
121
78
|
|
|
122
|
-
|
|
79
|
+
## MCP Surface
|
|
123
80
|
|
|
124
|
-
|
|
81
|
+
### Tools
|
|
125
82
|
|
|
126
|
-
|
|
127
|
-
- Tags must not contain whitespace. Use hyphens for compound words (e.g., `api-design`, `error-handling`).
|
|
83
|
+
This server exposes 12 tools for managing memories and relationships.
|
|
128
84
|
|
|
129
|
-
|
|
85
|
+
#### Memory Management
|
|
130
86
|
|
|
131
|
-
|
|
87
|
+
| Tool | Description | Key Parameters |
|
|
88
|
+
| :-------------------- | :------------------------------------------------------- | :---------------------------------------------------- |
|
|
89
|
+
| **`store_memory`** | Store a single memory. Deduplicates by content hash. | `content`, `tags`, `importance` (0-10), `memory_type` |
|
|
90
|
+
| **`store_memories`** | Batch store multiple memories. Supports partial success. | `items` (array of objects) |
|
|
91
|
+
| **`get_memory`** | Retrieve a memory by its SHA-256 hash. | `hash` |
|
|
92
|
+
| **`update_memory`** | Update an existing memory (creates new hash). | `hash`, `content`, `tags` (optional replace) |
|
|
93
|
+
| **`delete_memory`** | Delete a single memory by hash. | `hash` |
|
|
94
|
+
| **`delete_memories`** | Batch delete multiple memories. | `hashes` (array) |
|
|
132
95
|
|
|
133
|
-
|
|
134
|
-
| :-------- | :------- | :------- | :------ | :------------------------------------- |
|
|
135
|
-
| `items` | object[] | Yes | - | Array of memory items (1-50 items max) |
|
|
96
|
+
#### Search & Retrieval
|
|
136
97
|
|
|
137
|
-
|
|
98
|
+
| Tool | Description | Key Parameters |
|
|
99
|
+
| :-------------------- | :---------------------------------------------------------------------------------------- | :-------------------------------- |
|
|
100
|
+
| **`search_memories`** | FTS5 full-text search across content and tags. | `query` |
|
|
101
|
+
| **`recall`** | **Graph Search**. Finds a memory and traverses relationships to return connected context. | `query`, `depth` (0-3, default 1) |
|
|
102
|
+
| **`memory_stats`** | Get total counts, tag counts, and timeline stats. | _(none)_ |
|
|
138
103
|
|
|
139
|
-
|
|
140
|
-
| :-------- | :------- | :------- | :------ | :-------------------------------------------------- |
|
|
141
|
-
| `content` | string | Yes | - | The content of the memory (1-100000 chars) |
|
|
142
|
-
| `tags` | string[] | Yes | - | Tags (1-100 tags, no whitespace, max 50 chars each) |
|
|
104
|
+
#### Relationships (Knowledge Graph)
|
|
143
105
|
|
|
144
|
-
|
|
106
|
+
| Tool | Description | Key Parameters |
|
|
107
|
+
| :------------------------ | :---------------------------------------------- | :--------------------------------------------------- |
|
|
108
|
+
| **`create_relationship`** | Create a directional link between two memories. | `from_hash`, `to_hash`, `relation_type` |
|
|
109
|
+
| **`get_relationships`** | Get linked memories for a given hash. | `hash`, `direction` ('outgoing', 'incoming', 'both') |
|
|
110
|
+
| **`delete_relationship`** | Remove a specific link between memories. | `from_hash`, `to_hash`, `relation_type` |
|
|
145
111
|
|
|
146
|
-
|
|
147
|
-
- `succeeded`: Count of successfully stored memories
|
|
148
|
-
- `failed`: Count of failed items
|
|
112
|
+
### Resources
|
|
149
113
|
|
|
150
|
-
|
|
114
|
+
| URI | Description | Mime Type |
|
|
115
|
+
| :------------------------ | :------------------------------------------------ | :-------------- |
|
|
116
|
+
| `internal://instructions` | Usage instructions and guidelines for the server. | `text/markdown` |
|
|
151
117
|
|
|
152
|
-
|
|
153
|
-
- Each item is validated independently.
|
|
154
|
-
- Useful for bulk memory imports.
|
|
155
|
-
|
|
156
|
-
### `search_memories`
|
|
157
|
-
|
|
158
|
-
Search memories by content and tags.
|
|
159
|
-
|
|
160
|
-
| Parameter | Type | Required | Default | Description |
|
|
161
|
-
| :-------- | :----- | :------- | :------ | :---------------------------------------- |
|
|
162
|
-
| `query` | string | Yes | - | Search query (1-1000 chars, max 50 terms) |
|
|
163
|
-
|
|
164
|
-
**Returns:** Array of search results (`Memory` + `relevance`, includes `tags`).
|
|
165
|
-
|
|
166
|
-
Notes:
|
|
167
|
-
|
|
168
|
-
- Searches both memory content (full-text) and tags.
|
|
169
|
-
- Returns up to 100 results, ranked by relevance.
|
|
170
|
-
- Content matches rank higher than tag matches.
|
|
171
|
-
|
|
172
|
-
### `get_memory`
|
|
173
|
-
|
|
174
|
-
Retrieve a specific memory by its hash.
|
|
175
|
-
|
|
176
|
-
| Parameter | Type | Required | Default | Description |
|
|
177
|
-
| :-------- | :----- | :------- | :------ | :------------------ |
|
|
178
|
-
| `hash` | string | Yes | - | MD5 hash (32 chars) |
|
|
179
|
-
|
|
180
|
-
**Returns:** `Memory` (includes `tags`).
|
|
181
|
-
|
|
182
|
-
Notes:
|
|
183
|
-
|
|
184
|
-
- Updates `accessed_at` on read.
|
|
185
|
-
|
|
186
|
-
### `delete_memory`
|
|
187
|
-
|
|
188
|
-
Delete a memory by its hash.
|
|
189
|
-
|
|
190
|
-
| Parameter | Type | Required | Default | Description |
|
|
191
|
-
| :-------- | :----- | :------- | :------ | :------------------ |
|
|
192
|
-
| `hash` | string | Yes | - | MD5 hash (32 chars) |
|
|
193
|
-
|
|
194
|
-
**Returns:** `{ deleted: true }`.
|
|
195
|
-
|
|
196
|
-
### `delete_memories`
|
|
197
|
-
|
|
198
|
-
Delete multiple memories by hash in a single batch operation.
|
|
199
|
-
|
|
200
|
-
| Parameter | Type | Required | Default | Description |
|
|
201
|
-
| :-------- | :------- | :------- | :------ | :------------------------------------ |
|
|
202
|
-
| `hashes` | string[] | Yes | - | Array of MD5 hashes (1-50 hashes max) |
|
|
203
|
-
|
|
204
|
-
**Returns:** `{ results, succeeded, failed }`
|
|
205
|
-
|
|
206
|
-
- `results`: Array of `{ hash, deleted, error? }` for each hash
|
|
207
|
-
- `succeeded`: Count of successfully deleted memories
|
|
208
|
-
- `failed`: Count of hashes not found or failed
|
|
209
|
-
|
|
210
|
-
Notes:
|
|
211
|
-
|
|
212
|
-
- Supports partial success: if one hash doesn't exist, others still delete.
|
|
213
|
-
- Returns `deleted: false` for non-existent hashes (not an error).
|
|
214
|
-
- Useful for bulk cleanup operations.
|
|
215
|
-
|
|
216
|
-
### `memory_stats`
|
|
217
|
-
|
|
218
|
-
Get database statistics.
|
|
219
|
-
|
|
220
|
-
_No parameters required._
|
|
221
|
-
|
|
222
|
-
**Returns:** `{ memoryCount, tagCount, oldestMemory, newestMemory }`.
|
|
223
|
-
|
|
224
|
-
### `update_memory`
|
|
225
|
-
|
|
226
|
-
Update the content of a memory. Returns the new hash since changing content changes the hash.
|
|
227
|
-
|
|
228
|
-
| Parameter | Type | Required | Default | Description |
|
|
229
|
-
| :-------- | :------- | :------- | :------ | :-------------------------------------- |
|
|
230
|
-
| `hash` | string | Yes | - | MD5 hash of memory to update (32 chars) |
|
|
231
|
-
| `content` | string | Yes | - | New content (1-100000 chars) |
|
|
232
|
-
| `tags` | string[] | No | - | Replace tags (max 100, each 1-50 chars) |
|
|
233
|
-
|
|
234
|
-
**Returns:** `{ updated: true, oldHash, newHash }`.
|
|
235
|
-
|
|
236
|
-
Notes:
|
|
237
|
-
|
|
238
|
-
- If `tags` is omitted, existing tags are preserved.
|
|
239
|
-
- If `tags` is provided, it replaces all existing tags for the memory.
|
|
240
|
-
- Updating to content that already exists in another memory returns an error.
|
|
241
|
-
|
|
242
|
-
### Memory Fields
|
|
243
|
-
|
|
244
|
-
All memory-shaped responses include:
|
|
245
|
-
|
|
246
|
-
- `id`: integer ID
|
|
247
|
-
- `content`: original content string
|
|
248
|
-
- `summary`: optional summary (currently unset by tools)
|
|
249
|
-
- `tags`: string array
|
|
250
|
-
- `created_at`: timestamp string
|
|
251
|
-
- `accessed_at`: timestamp string
|
|
252
|
-
- `hash`: MD5 hash
|
|
253
|
-
|
|
254
|
-
## Client Configuration
|
|
118
|
+
## Client Configuration Examples
|
|
255
119
|
|
|
256
120
|
<details>
|
|
257
121
|
<summary><b>VS Code</b></summary>
|
|
258
122
|
|
|
259
|
-
Add to
|
|
123
|
+
Add to `settings.json` or `.vscode/mcp.json`:
|
|
260
124
|
|
|
261
125
|
```json
|
|
262
126
|
{
|
|
@@ -274,7 +138,7 @@ Add to your `settings.json` or `mcpServers` config:
|
|
|
274
138
|
<details>
|
|
275
139
|
<summary><b>Claude Desktop</b></summary>
|
|
276
140
|
|
|
277
|
-
Add to
|
|
141
|
+
Add to `claude_desktop_config.json`:
|
|
278
142
|
|
|
279
143
|
```json
|
|
280
144
|
{
|
|
@@ -292,91 +156,50 @@ Add to your `claude_desktop_config.json`:
|
|
|
292
156
|
<details>
|
|
293
157
|
<summary><b>Cursor</b></summary>
|
|
294
158
|
|
|
295
|
-
1.
|
|
296
|
-
2. Click **+ Add New MCP Server
|
|
297
|
-
3. Name
|
|
298
|
-
4. Type
|
|
299
|
-
5. Command
|
|
159
|
+
1. Open **Cursor Settings** > **Features** > **MCP**.
|
|
160
|
+
2. Click **+ Add New MCP Server**.
|
|
161
|
+
3. **Name**: `memdb`
|
|
162
|
+
4. **Type**: `command`
|
|
163
|
+
5. **Command**: `npx -y @j0hanz/memdb@latest`
|
|
164
|
+
|
|
165
|
+
Or use the **Install in Cursor** button at the top of this README.
|
|
300
166
|
|
|
301
167
|
</details>
|
|
302
168
|
|
|
303
|
-
##
|
|
304
|
-
|
|
305
|
-
| Constraint | Value | Description |
|
|
306
|
-
| :---------------------- | :------------ | :---------------------------------------------------------------------------- |
|
|
307
|
-
| **Max content length** | 100,000 chars | Maximum characters in memory content |
|
|
308
|
-
| **Max query length** | 1,000 chars | Maximum characters in search query |
|
|
309
|
-
| **Max search terms** | 50 | Maximum whitespace-separated terms per query |
|
|
310
|
-
| **Max search results** | 100 | Maximum results returned from `search_memories` |
|
|
311
|
-
| **Min tags per memory** | 1 | At least one tag is required |
|
|
312
|
-
| **Max tags per memory** | 100 | Maximum number of tags when storing a memory |
|
|
313
|
-
| **Max tag length** | 50 chars | Maximum characters per tag |
|
|
314
|
-
| **Tag format** | No whitespace | Tags cannot contain spaces or tabs; use hyphens for compound words |
|
|
315
|
-
| **Hash length** | 32 chars | MD5 hash length |
|
|
316
|
-
| **Batch store limit** | 50 items | Maximum items per `store_memories` call |
|
|
317
|
-
| **Batch delete limit** | 50 hashes | Maximum hashes per `delete_memories` call |
|
|
318
|
-
| **Search mode** | Tokenized OR | Whitespace-split terms are quoted and OR'ed; FTS5 operators are not supported |
|
|
319
|
-
|
|
320
|
-
### Notes
|
|
321
|
-
|
|
322
|
-
- **Content deduplication**: Memories are deduplicated using MD5 hashes.
|
|
323
|
-
- **Search errors**: If FTS5 is unavailable, `search_memories` returns an error indicating the index is missing. Invalid query syntax returns an error with details.
|
|
324
|
-
- **Search tokenization**: Queries are split on whitespace (max 50 terms); whitespace-only queries are rejected.
|
|
325
|
-
- **Batch operations**: `store_memories` and `delete_memories` support partial success—individual item failures don't affect other items in the batch.
|
|
326
|
-
- **Tag requirements**: At least one tag is required. Tags cannot contain whitespace; use hyphens for compound words (e.g., `api-design`).
|
|
327
|
-
- **Local storage**: All data is stored locally in `.memdb/memory.db`.
|
|
328
|
-
|
|
329
|
-
## Development
|
|
330
|
-
|
|
331
|
-
### Prerequisites
|
|
332
|
-
|
|
333
|
-
- Node.js >= 22.0.0 (required for `node:sqlite`)
|
|
334
|
-
|
|
335
|
-
### Scripts
|
|
336
|
-
|
|
337
|
-
| Command | Description |
|
|
338
|
-
| :------------------------ | :----------------------------------------- |
|
|
339
|
-
| `npm run clean` | Remove `dist/` |
|
|
340
|
-
| `npm run build` | Compile TypeScript to `dist/` |
|
|
341
|
-
| `npm run dev` | Run in development mode with watch |
|
|
342
|
-
| `npm run start` | Run compiled server (`node dist/index.js`) |
|
|
343
|
-
| `npm run test` | Run tests |
|
|
344
|
-
| `npm run test:coverage` | Run tests with coverage |
|
|
345
|
-
| `npm run lint` | Run ESLint |
|
|
346
|
-
| `npm run format` | Format code with Prettier |
|
|
347
|
-
| `npm run format:check` | Check code formatting |
|
|
348
|
-
| `npm run type-check` | TypeScript type checking |
|
|
349
|
-
| `npm run type-check:test` | Type-check tests only |
|
|
350
|
-
| `npm run duplication` | Run duplication report (jscpd) |
|
|
351
|
-
| `npm run inspector` | Run MCP inspector |
|
|
352
|
-
|
|
353
|
-
### Project Structure
|
|
169
|
+
## Repository Structure
|
|
354
170
|
|
|
355
171
|
```text
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
`-- *.test.ts # Node.js test runner tests
|
|
172
|
+
c:\memdb
|
|
173
|
+
├── src
|
|
174
|
+
│ ├── core # Database logic, schema, and search
|
|
175
|
+
│ │ ├── db.ts # SQLite connection & schema
|
|
176
|
+
│ │ ├── memory-read.ts # Get/Delete/Stats operations
|
|
177
|
+
│ │ ├── memory-write.ts # Store/Update operations
|
|
178
|
+
│ │ ├── relationships.ts# Graph edge operations
|
|
179
|
+
│ │ └── search.ts # FTS5 & Graph traversal
|
|
180
|
+
│ ├── index.ts # Server entrypoint & transport setup
|
|
181
|
+
│ ├── schemas.ts # Zod schemas for tools
|
|
182
|
+
│ ├── tools.ts # Tool definitions & registration
|
|
183
|
+
│ └── types.ts # TypeScript interfaces
|
|
184
|
+
├── scripts # Build and test automation
|
|
185
|
+
├── tests/ # Node.js native tests
|
|
186
|
+
└── package.json
|
|
372
187
|
```
|
|
373
188
|
|
|
189
|
+
## Development Workflow
|
|
190
|
+
|
|
191
|
+
1. **Install**: `npm install`
|
|
192
|
+
2. **Dev Mode**: `npm run dev` (watches and recompiles)
|
|
193
|
+
3. **Run**: `npm start` (runs `dist/index.js`)
|
|
194
|
+
4. **Test**: `npm test` (runs native Node.js test runner)
|
|
195
|
+
5. **Lint**: `npm run lint`
|
|
196
|
+
|
|
374
197
|
## Troubleshooting
|
|
375
198
|
|
|
376
|
-
- **`node:sqlite`
|
|
377
|
-
- **
|
|
378
|
-
|
|
199
|
+
- **`node:sqlite` not found**: You are likely running a Node.js version older than 22.0.0. Please upgrade Node.js.
|
|
200
|
+
- **Database Locked**: This server uses WAL mode (`PRAGMA journal_mode = WAL`). If you access the `.memdb/memory.db` file with another tool while the server is running, you may encounter locking issues.
|
|
201
|
+
- **FTS5 Errors**: The bundled `node:sqlite` usually includes FTS5. If you see FTS errors, ensure your Node.js binary was built with standard SQLite extensions.
|
|
379
202
|
|
|
380
|
-
##
|
|
203
|
+
## License
|
|
381
204
|
|
|
382
|
-
|
|
205
|
+
This project is licensed under the **MIT** License.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#FFFFFF"
|
|
2
|
+
stroke-width="1" stroke-linecap="round" stroke-linejoin="round">
|
|
3
|
+
<path d="M3 7c0-1.7 2.7-3 6-3s6 1.3 6 3-2.7 3-6 3-6-1.3-6-3Z" />
|
|
4
|
+
<path d="M3 7v10c0 1.7 2.7 3 6 3s6-1.3 6-3V7" />
|
|
5
|
+
<path d="M3 12c0 1.7 2.7 3 6 3s6-1.3 6-3" />
|
|
6
|
+
<line x1="15" y1="12" x2="16" y2="12" />
|
|
7
|
+
<rect x="16" y="9" width="6" height="6" rx="1" />
|
|
8
|
+
<line x1="17.5" y1="9" x2="17.5" y2="8" />
|
|
9
|
+
<line x1="20.5" y1="9" x2="20.5" y2="8" />
|
|
10
|
+
<line x1="17.5" y1="15" x2="17.5" y2="16" />
|
|
11
|
+
<line x1="20.5" y1="15" x2="20.5" y2="16" />
|
|
12
|
+
</svg>
|
package/dist/config.d.ts
CHANGED
package/dist/config.js
CHANGED
package/dist/core/db.d.ts
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { DatabaseSync, type StatementSync } from 'node:sqlite';
|
|
2
2
|
import { type Memory, type Relationship, type SearchResult } from '../types.js';
|
|
3
3
|
export type DbRow = Record<string, unknown>;
|
|
4
|
-
export declare const db: DatabaseSync;
|
|
5
|
-
export declare const closeDb: () => void;
|
|
6
4
|
export type SqlParam = string | number | bigint | null | Uint8Array;
|
|
5
|
+
export declare const initDb: () => Promise<void>;
|
|
6
|
+
export declare const getDb: () => DatabaseSync;
|
|
7
|
+
export declare const closeDb: () => void;
|
|
7
8
|
export declare const prepareCached: (sql: string) => StatementSync;
|
|
8
9
|
export declare const executeAll: (stmt: StatementSync, ...params: SqlParam[]) => DbRow[];
|
|
9
10
|
export declare const executeGet: (stmt: StatementSync, ...params: SqlParam[]) => DbRow | undefined;
|
|
@@ -11,9 +12,11 @@ export declare const executeRun: (stmt: StatementSync, ...params: SqlParam[]) =>
|
|
|
11
12
|
changes: number | bigint;
|
|
12
13
|
};
|
|
13
14
|
export declare const withImmediateTransaction: <T>(operation: () => T) => T;
|
|
15
|
+
export declare const withSavepoint: <T>(name: string, operation: () => T) => T;
|
|
14
16
|
export declare const toSafeInteger: (value: unknown, field: string) => number;
|
|
15
17
|
export declare const mapRowToMemory: (row: DbRow, tags?: string[]) => Memory;
|
|
16
18
|
export declare const mapRowToSearchResult: (row: DbRow, tags?: string[]) => SearchResult;
|
|
17
19
|
export declare const mapRowToRelationship: (row: DbRow) => Relationship;
|
|
20
|
+
export declare const findMemoryIdByHash: (hash: string) => number | undefined;
|
|
21
|
+
export declare const requireMemoryIdByHash: (hash: string, message?: string) => number;
|
|
18
22
|
export declare const loadTagsForMemoryIds: (memoryIds: readonly number[]) => Map<number, string[]>;
|
|
19
|
-
//# sourceMappingURL=db.d.ts.map
|