@danielsimonjr/memory-mcp 9.8.2 → 9.9.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.
Files changed (44) hide show
  1. package/README.md +360 -1829
  2. package/dist/core/ManagerContext.d.ts +4 -0
  3. package/dist/core/ManagerContext.d.ts.map +1 -1
  4. package/dist/core/ManagerContext.js +12 -2
  5. package/dist/features/KeywordExtractor.d.ts +61 -0
  6. package/dist/features/KeywordExtractor.d.ts.map +1 -0
  7. package/dist/features/KeywordExtractor.js +126 -0
  8. package/dist/features/ObservationNormalizer.d.ts +90 -0
  9. package/dist/features/ObservationNormalizer.d.ts.map +1 -0
  10. package/dist/features/ObservationNormalizer.js +193 -0
  11. package/dist/features/index.d.ts +2 -0
  12. package/dist/features/index.d.ts.map +1 -1
  13. package/dist/features/index.js +3 -0
  14. package/dist/search/HybridSearchManager.d.ts +80 -0
  15. package/dist/search/HybridSearchManager.d.ts.map +1 -0
  16. package/dist/search/HybridSearchManager.js +187 -0
  17. package/dist/search/QueryAnalyzer.d.ts +76 -0
  18. package/dist/search/QueryAnalyzer.d.ts.map +1 -0
  19. package/dist/search/QueryAnalyzer.js +227 -0
  20. package/dist/search/QueryPlanner.d.ts +58 -0
  21. package/dist/search/QueryPlanner.d.ts.map +1 -0
  22. package/dist/search/QueryPlanner.js +137 -0
  23. package/dist/search/ReflectionManager.d.ts +71 -0
  24. package/dist/search/ReflectionManager.d.ts.map +1 -0
  25. package/dist/search/ReflectionManager.js +124 -0
  26. package/dist/search/SymbolicSearch.d.ts +61 -0
  27. package/dist/search/SymbolicSearch.d.ts.map +1 -0
  28. package/dist/search/SymbolicSearch.js +163 -0
  29. package/dist/search/index.d.ts +5 -0
  30. package/dist/search/index.d.ts.map +1 -1
  31. package/dist/search/index.js +8 -0
  32. package/dist/server/toolDefinitions.d.ts +1 -1
  33. package/dist/server/toolDefinitions.d.ts.map +1 -1
  34. package/dist/server/toolDefinitions.js +141 -1
  35. package/dist/server/toolHandlers.d.ts.map +1 -1
  36. package/dist/server/toolHandlers.js +167 -0
  37. package/dist/types/index.d.ts +1 -1
  38. package/dist/types/index.d.ts.map +1 -1
  39. package/dist/types/types.d.ts +118 -0
  40. package/dist/types/types.d.ts.map +1 -1
  41. package/dist/utils/logger.d.ts +7 -0
  42. package/dist/utils/logger.d.ts.map +1 -1
  43. package/dist/utils/logger.js +9 -2
  44. package/package.json +2 -2
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Memory MCP Server
2
2
 
3
- [![Version](https://img.shields.io/badge/version-9.0.0-blue.svg)](https://github.com/danielsimonjr/memory-mcp)
3
+ [![Version](https://img.shields.io/badge/version-9.8.3-blue.svg)](https://github.com/danielsimonjr/memory-mcp)
4
4
  [![NPM](https://img.shields.io/npm/v/@danielsimonjr/memory-mcp.svg)](https://www.npmjs.com/package/@danielsimonjr/memory-mcp)
5
5
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
6
6
  [![MCP](https://img.shields.io/badge/MCP-1.0-purple.svg)](https://modelcontextprotocol.io)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.6-blue.svg)](https://www.typescriptlang.org/)
8
- [![Changelog](https://img.shields.io/badge/changelog-latest-orange.svg)](CHANGELOG.md)
8
+ [![Coverage](https://img.shields.io/badge/coverage-96.6%25-brightgreen.svg)](docs/architecture/TEST_COVERAGE.md)
9
9
 
10
10
  An **enhanced fork** of the official [Model Context Protocol](https://modelcontextprotocol.io) memory server with advanced features for **hierarchical nesting**, **intelligent compression**, **semantic search**, **graph algorithms**, **archiving**, **advanced search**, and **multi-format import/export**.
11
11
 
12
- > **Enterprise-grade knowledge graph** with 55 tools, hierarchical organization, semantic search with embeddings, graph traversal algorithms, duplicate detection, smart archiving, and sophisticated search capabilities for long-term memory management.
12
+ > **Enterprise-grade knowledge graph** with 59 tools, hierarchical organization, semantic search with embeddings, graph traversal algorithms, duplicate detection, smart archiving, and sophisticated search capabilities for long-term memory management.
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -18,1746 +18,338 @@ An **enhanced fork** of the official [Model Context Protocol](https://modelconte
18
18
  - [Installation](#installation)
19
19
  - [Core Concepts](#core-concepts)
20
20
  - [API Reference](#api-reference)
21
- - [Data Model](#data-model)
22
- - [Usage Examples](#usage-examples)
23
- - [Documentation](#documentation)
24
21
  - [Configuration](#configuration)
25
22
  - [Development](#development)
23
+ - [Documentation](#documentation)
26
24
  - [Contributing](#contributing)
27
25
  - [Changelog](#changelog)
28
- - [License](#license)
29
- - [Acknowledgments](#acknowledgments)
30
-
31
- ## Features
32
-
33
- ### Core Memory Capabilities
34
- - **Knowledge Graph Storage**: Entity-Relation-Observation model for structured memory
35
- - **Persistent Memory**: Information persists across chat sessions with JSONL or SQLite storage
36
- - **Dual Storage Backends**: JSONL (human-readable) or SQLite with better-sqlite3 (3-10x faster, FTS5 search)
37
- - **Full CRUD Operations**: Create, read, update, delete entities and relations
38
- - **Flexible Search**: Text-based, fuzzy, boolean, and TF-IDF ranked search
39
-
40
- ### Advanced Features
41
- - **Hierarchical Nesting**: Parent-child relationships for organizing tree structures (9 tools)
42
- - **Graph Algorithms**: Path finding, connected components, centrality metrics (4 tools)
43
- - **Semantic Search**: Embedding-based similarity search with OpenAI or local models (3 tools)
44
- - **Memory Compression**: Intelligent duplicate detection and merging with similarity scoring (4 tools)
45
- - **Advanced Search**: TF-IDF ranking, boolean queries, fuzzy matching, date range search (6 tools)
46
- - **Import/Export**: 7 export formats (JSON, CSV, GraphML, GEXF, DOT, Markdown, Mermaid) with brotli compression, 3 import formats
47
- - **Tag Management**: Tags, aliases, bulk operations, importance scores (11 tools)
48
- - **Saved Searches**: Store and execute frequent queries (5 tools)
49
- - **Graph Analytics**: Statistics, validation, integrity checks (2 tools)
50
- - **Brotli Compression**: Compressed backups, exports, and MCP responses (50-70% size reduction)
51
-
52
- ### Data Management
53
- - **Automatic Timestamps**: `createdAt` and `lastModified` fields with smart updates
54
- - **Date Range Search**: Filter entities/relations by creation or modification date
55
- - **Graph Statistics**: Comprehensive analytics with counts, types, and temporal data
56
- - **Tags System**: Categorize entities with case-insensitive tags and aliases
57
- - **Importance Levels**: 0-10 scale for entity prioritization
58
- - **Advanced Filtering**: Combine text, tags, importance, and date ranges
59
- - **Compressed Archives**: Archived entities stored with brotli compression
60
-
61
- ### Comparison with Official Memory Server
62
-
63
- | Feature | Official | Enhanced (This Fork) |
64
- |---------|----------|----------------------|
65
- | Entity Management | ✅ | ✅ |
66
- | Relation Management | ✅ | ✅ |
67
- | Observation Tracking | ✅ | ✅ |
68
- | Basic Search | ✅ | ✅ |
69
- | **Hierarchical Nesting** | ❌ | ✅ Parent-child trees |
70
- | **Graph Algorithms** | ❌ | ✅ Path finding, centrality |
71
- | **Semantic Search** | ❌ | ✅ Embedding-based similarity |
72
- | **Memory Compression** | ❌ | ✅ Duplicate detection (50x faster) |
73
- | **Brotli Compression** | ❌ | ✅ Backups, exports, responses |
74
- | **Smart Archiving** | ❌ | ✅ Criteria-based |
75
- | **Advanced Search** | ❌ | ✅ TF-IDF + Boolean |
76
- | **Fuzzy Search** | ❌ | ✅ Typo-tolerant |
77
- | **Saved Searches** | ❌ | ✅ Store queries |
78
- | **Tag Aliases** | ❌ | ✅ Synonyms |
79
- | **Graph Validation** | ❌ | ✅ Integrity checks |
80
- | **Timestamps** | ❌ | ✅ createdAt + lastModified |
81
- | **Importance Levels** | ❌ | ✅ 0-10 scale |
82
- | **Export Formats** | ❌ | ✅ 7 formats + compression |
83
- | **Import** | ❌ | ✅ 3 formats + merge |
84
- | **Input Validation** | ❌ | ✅ Zod schemas (14 validators) |
85
- | **Caching Layer** | ❌ | ✅ In-memory (instant reads) |
86
- | **Backup & Restore** | ❌ | ✅ Point-in-time recovery |
87
- | **Transactions** | ❌ | ✅ ACID guarantees |
88
- | **Security** | Basic | ✅ Input validation |
89
- | **Reliability** | Basic | ✅ Backups & Transactions |
90
- | **Performance** | Basic | ✅ Caching & Optimizations |
91
- | **SQLite Backend** | ❌ | ✅ better-sqlite3 (3-10x faster) |
92
- | **Full-Text Search** | ❌ | ✅ FTS5 with BM25 ranking |
93
- | **Concurrency Control** | ❌ | ✅ Thread-safe with async-mutex |
94
- | **Total Tools** | 11 | **55** (+400%) |
95
- | **Code Structure** | Monolithic | **Modular** (58 files, ~22.5K lines) |
96
-
97
- ## Key Features
98
-
99
- ### Production-Ready Enterprise Capabilities
100
-
101
- **🔐 Security & Data Integrity**
102
- - **Input Validation**: Zod-based schemas validate all inputs, preventing malformed data and injection attacks
103
- - **Transaction Support**: ACID-compliant transactions with automatic rollback on failures
104
- - **Backup & Restore**: Point-in-time recovery with timestamped, compressed backups and metadata
105
- - **Data Protection**: Comprehensive validation with size limits, range checks, and format enforcement
106
-
107
- **⚡ Performance Optimizations**
108
- - **Smart Caching**: In-memory cache with write-through invalidation for instant reads
109
- - **Optimized Algorithms**: 50x faster duplicate detection using two-level bucketing (O(n²) → O(n·k))
110
- - **Efficient Storage**: JSONL format with modular architecture for better tree-shaking
111
- - **Brotli Compression**: 50-70% size reduction for backups, exports, and large responses
112
- - **Multi-Level Caching**: Bidirectional relation cache, fuzzy search cache, boolean AST cache
113
-
114
- **🏗️ Architecture**
115
- - **Modular Design**: Clean separation of concerns across 58 focused modules with 7 lazy-initialized managers
116
- - **Type Safety**: Full TypeScript strict mode with comprehensive type definitions
117
- - **Lazy Initialization**: Context pattern with on-demand manager instantiation
118
- - **Developer Experience**: Barrel exports, 2493 tests (92% coverage), and comprehensive documentation
119
-
120
- ## Quick Start
121
-
122
- ### 1. Install from NPM (Recommended)
123
-
124
- ```bash
125
- npm install -g @danielsimonjr/memory-mcp
126
- ```
127
-
128
- Or use with npx (no installation required):
129
-
130
- ```bash
131
- npx @danielsimonjr/memory-mcp
132
- ```
133
-
134
- ### 2. Configure Claude Desktop
135
-
136
- Add to `claude_desktop_config.json`:
137
-
138
- **Using NPM Global Install:**
139
- ```json
140
- {
141
- "mcpServers": {
142
- "memory": {
143
- "command": "mcp-server-memory"
144
- }
145
- }
146
- }
147
- ```
148
-
149
- **Using NPX:**
150
- ```json
151
- {
152
- "mcpServers": {
153
- "memory": {
154
- "command": "npx",
155
- "args": ["-y", "@danielsimonjr/memory-mcp"]
156
- }
157
- }
158
- }
159
- ```
160
-
161
- ### 3. Restart Claude Desktop
162
-
163
- Restart Claude Desktop to load the enhanced memory server.
164
-
165
- ### 4. Start Using
166
-
167
- Tell Claude:
168
- ```
169
- Please remember that I prefer TypeScript over JavaScript.
170
- Tag this as "preferences" with importance 8.
171
- Create a parent entity called "Development Preferences" and nest this under it.
172
- ```
173
-
174
- Claude will automatically use the enhanced tools!
175
-
176
- ## Installation
177
-
178
- ### Local Build (Recommended)
179
-
180
- ```bash
181
- # Clone repository
182
- git clone https://github.com/danielsimonjr/memory-mcp.git
183
- cd memory-mcp
184
-
185
- # Install and build
186
- npm install
187
- npm run build
188
-
189
- # Run tests
190
- npm test
191
-
192
- # Type check
193
- npm run typecheck
194
- ```
195
-
196
- ### Claude Desktop Configuration
197
-
198
- Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (Mac) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
199
-
200
- ```json
201
- {
202
- "mcpServers": {
203
- "memory": {
204
- "command": "node",
205
- "args": ["<PATH_TO>/memory-mcp/dist/index.js"],
206
- "env": {
207
- "MEMORY_FILE_PATH": "<PATH_TO>/memory.jsonl"
208
- }
209
- }
210
- }
211
- }
212
- ```
213
-
214
- Replace `<PATH_TO>` with your actual paths.
215
-
216
- ### VS Code
217
-
218
- Add to `.vscode/mcp.json`:
219
-
220
- ```json
221
- {
222
- "servers": {
223
- "memory": {
224
- "command": "node",
225
- "args": ["/path/to/memory-mcp/dist/index.js"]
226
- }
227
- }
228
- }
229
- ```
230
-
231
- ## Core Concepts
232
-
233
- ### Entities
234
-
235
- **Primary nodes** in the knowledge graph.
236
-
237
- **Fields:**
238
- - `name` (string): Unique identifier
239
- - `entityType` (string): Classification
240
- - `observations` (string[]): Facts about the entity
241
- - `parentId` (string, optional): Parent entity name for hierarchical nesting
242
- - `createdAt` (string, optional): ISO 8601 timestamp
243
- - `lastModified` (string, optional): ISO 8601 timestamp
244
- - `tags` (string[], optional): Lowercase tags for categorization
245
- - `importance` (number, optional): 0-10 scale for prioritization
246
-
247
- **Example:**
248
- ```json
249
- {
250
- "name": "John_Smith",
251
- "entityType": "person",
252
- "observations": ["Speaks fluent Spanish", "Senior developer"],
253
- "parentId": "Engineering_Team",
254
- "createdAt": "2025-01-15T10:30:00.000Z",
255
- "tags": ["colleague", "engineering"],
256
- "importance": 7
257
- }
258
- ```
259
-
260
- ### Relations
261
-
262
- **Directed connections** between entities.
263
-
264
- **Fields:**
265
- - `from` (string): Source entity name
266
- - `to` (string): Target entity name
267
- - `relationType` (string): Relationship type
268
- - `createdAt` (string, optional): ISO 8601 timestamp
269
- - `lastModified` (string, optional): ISO 8601 timestamp
270
-
271
- **Example:**
272
- ```json
273
- {
274
- "from": "John_Smith",
275
- "to": "Anthropic",
276
- "relationType": "works_at",
277
- "createdAt": "2025-01-15T10:30:00.000Z"
278
- }
279
- ```
280
-
281
- ### Observations
282
-
283
- **Discrete facts** about entities.
284
-
285
- **Principles:**
286
- - One fact per observation
287
- - Atomic information
288
- - Independently manageable
289
-
290
- ## API Reference
291
-
292
- ### Complete Tool List (55 Tools)
293
-
294
- #### Entity Operations (4 tools)
295
- - `create_entities` - Create multiple new entities
296
- - `delete_entities` - Remove entities and their relations
297
- - `read_graph` - Read entire knowledge graph
298
- - `open_nodes` - Retrieve specific nodes by name
299
-
300
- #### Relation Operations (2 tools)
301
- - `create_relations` - Create multiple new relations
302
- - `delete_relations` - Remove specific relations
303
-
304
- #### Observation Management (2 tools)
305
- - `add_observations` - Add observations to entities
306
- - `delete_observations` - Remove specific observations
307
-
308
- #### Search (7 tools)
309
- - `search_nodes` - Search for nodes by query with filters
310
- - `search_by_date_range` - Filter by date range
311
- - `search_nodes_ranked` - TF-IDF relevance ranking
312
- - `boolean_search` - Boolean queries (AND/OR/NOT)
313
- - `fuzzy_search` - Typo-tolerant search
314
- - `get_search_suggestions` - Get "Did you mean?" suggestions
315
- - `search_auto` - Automatically select best search method (Phase 10)
316
-
317
- #### Semantic Search (3 tools)
318
- - `semantic_search` - Search by semantic similarity using embeddings
319
- - `find_similar_entities` - Find entities similar to a reference entity
320
- - `index_embeddings` - Build or rebuild the semantic search index
321
-
322
- #### Saved Searches (5 tools)
323
- - `save_search` - Save search query
324
- - `list_saved_searches` - List all saved searches
325
- - `execute_saved_search` - Execute saved search
326
- - `delete_saved_search` - Delete saved search
327
- - `update_saved_search` - Update saved search
328
-
329
- #### Tag Management (6 tools)
330
- - `add_tags` - Add tags to entity
331
- - `remove_tags` - Remove tags from entity
332
- - `set_importance` - Set entity importance (0-10)
333
- - `add_tags_to_multiple_entities` - Add tags to multiple entities
334
- - `replace_tag` - Replace tag globally
335
- - `merge_tags` - Merge two tags into one
336
-
337
- #### Tag Aliases (5 tools)
338
- - `add_tag_alias` - Create tag synonym
339
- - `list_tag_aliases` - List all tag aliases
340
- - `remove_tag_alias` - Remove tag alias
341
- - `get_aliases_for_tag` - Get aliases for tag
342
- - `resolve_tag` - Resolve alias to canonical form
343
-
344
- #### Hierarchical Nesting (9 tools)
345
- - `set_entity_parent` - Set or remove parent relationship
346
- - `get_children` - Get immediate children
347
- - `get_parent` - Get parent entity
348
- - `get_ancestors` - Get all ancestors (parent chain)
349
- - `get_descendants` - Get all descendants (recursive)
350
- - `get_subtree` - Get entity + descendants with relations
351
- - `get_root_entities` - Get all entities with no parent
352
- - `get_entity_depth` - Get depth in hierarchy (0 = root)
353
- - `move_entity` - Move entity to new parent
354
-
355
- #### Graph Algorithms (4 tools)
356
- - `find_shortest_path` - Find shortest path between two entities
357
- - `find_all_paths` - Find all paths between entities with max depth
358
- - `get_connected_components` - Analyze graph connectivity and detect isolated subgraphs
359
- - `get_centrality` - Calculate centrality metrics (degree, betweenness, PageRank)
360
-
361
- #### Graph Analytics (2 tools)
362
- - `get_graph_stats` - Get comprehensive graph statistics
363
- - `validate_graph` - Validate graph integrity
364
-
365
- #### Compression & Archiving (4 tools)
366
- - `find_duplicates` - Find similar entities by threshold
367
- - `merge_entities` - Merge multiple entities into one
368
- - `compress_graph` - Automated compression with dry-run
369
- - `archive_entities` - Archive by age, importance, or tags
370
-
371
- #### Import & Export (2 tools)
372
- - `export_graph` - Export in 7 formats (with optional brotli compression)
373
- - `import_graph` - Import from JSON/CSV/GraphML
374
-
375
- ---
376
-
377
- ### Detailed API Documentation
378
-
379
- <details>
380
- <summary><b>Core: create_entities</b></summary>
381
-
382
- Create multiple new entities in the knowledge graph.
383
-
384
- **Input:**
385
- ```typescript
386
- {
387
- entities: Array<{
388
- name: string;
389
- entityType: string;
390
- observations: string[];
391
- parentId?: string; // NEW in v0.8.0
392
- tags?: string[];
393
- importance?: number; // 0-10
394
- }>
395
- }
396
- ```
397
-
398
- **Returns:** Array of created entities with timestamps
399
-
400
- **Example:**
401
- ```json
402
- {
403
- "entities": [{
404
- "name": "Project_Alpha",
405
- "entityType": "project",
406
- "observations": ["Web application rewrite"],
407
- "tags": ["high-priority"],
408
- "importance": 8
409
- }]
410
- }
411
- ```
412
- </details>
413
-
414
- <details>
415
- <summary><b>Core: create_relations</b></summary>
416
-
417
- Create multiple new relations between entities.
418
-
419
- **Input:**
420
- ```typescript
421
- {
422
- relations: Array<{
423
- from: string;
424
- to: string;
425
- relationType: string;
426
- }>
427
- }
428
- ```
429
-
430
- **Returns:** Array of created relations with timestamps
431
-
432
- **Example:**
433
- ```json
434
- {
435
- "relations": [{
436
- "from": "John_Smith",
437
- "to": "Project_Alpha",
438
- "relationType": "works_on"
439
- }]
440
- }
441
- ```
442
- </details>
443
-
444
- <details>
445
- <summary><b>Core: add_observations</b></summary>
446
-
447
- Add new observations to existing entities.
448
-
449
- **Input:**
450
- ```typescript
451
- {
452
- observations: Array<{
453
- entityName: string;
454
- contents: string[];
455
- }>
456
- }
457
- ```
458
-
459
- **Returns:** Array with added observations per entity
460
-
461
- **Example:**
462
- ```json
463
- {
464
- "observations": [{
465
- "entityName": "John_Smith",
466
- "contents": ["Certified AWS architect", "Speaks German"]
467
- }]
468
- }
469
- ```
470
- </details>
471
-
472
- <details>
473
- <summary><b>Core: delete_entities</b></summary>
474
-
475
- Remove entities and all their relations from the graph.
476
-
477
- **Input:**
478
- ```typescript
479
- {
480
- entityNames: string[]
481
- }
482
- ```
483
-
484
- **Returns:** Confirmation
485
-
486
- **Note:** Cascade deletes all relations to/from these entities.
487
- </details>
488
-
489
- <details>
490
- <summary><b>Core: delete_observations</b></summary>
491
-
492
- Remove specific observations from entities.
493
-
494
- **Input:**
495
- ```typescript
496
- {
497
- deletions: Array<{
498
- entityName: string;
499
- observations: string[];
500
- }>
501
- }
502
- ```
503
-
504
- **Returns:** Confirmation
505
- </details>
506
-
507
- <details>
508
- <summary><b>Core: delete_relations</b></summary>
509
-
510
- Remove specific relations from the graph.
511
-
512
- **Input:**
513
- ```typescript
514
- {
515
- relations: Array<{
516
- from: string;
517
- to: string;
518
- relationType: string;
519
- }>
520
- }
521
- ```
522
-
523
- **Returns:** Confirmation
524
- </details>
525
-
526
- <details>
527
- <summary><b>Core: read_graph</b></summary>
528
-
529
- Read the entire knowledge graph (all entities and relations).
530
-
531
- **Input:** None
532
-
533
- **Returns:** Complete knowledge graph
534
- ```typescript
535
- {
536
- entities: Entity[];
537
- relations: Relation[];
538
- }
539
- ```
540
- </details>
541
-
542
- <details>
543
- <summary><b>Core: search_nodes</b></summary>
544
-
545
- Search for nodes by query string with optional filters.
546
-
547
- **Input:**
548
- ```typescript
549
- {
550
- query: string;
551
- tags?: string[];
552
- minImportance?: number;
553
- maxImportance?: number;
554
- }
555
- ```
556
-
557
- **Returns:** Matching entities and their relations
558
-
559
- **Example:**
560
- ```json
561
- {
562
- "query": "typescript",
563
- "tags": ["programming"],
564
- "minImportance": 5
565
- }
566
- ```
567
- </details>
568
-
569
- <details>
570
- <summary><b>Core: open_nodes</b></summary>
571
-
572
- Retrieve specific nodes by exact name match.
573
-
574
- **Input:**
575
- ```typescript
576
- {
577
- names: string[]
578
- }
579
- ```
580
-
581
- **Returns:** Requested entities and relations between them
582
-
583
- **Example:**
584
- ```json
585
- {
586
- "names": ["John_Smith", "Project_Alpha"]
587
- }
588
- ```
589
- </details>
590
-
591
- ---
592
-
593
- <details>
594
- <summary><b>Hierarchy: set_entity_parent</b></summary>
595
-
596
- Set or remove parent-child relationship for hierarchical nesting.
597
-
598
- **Input:**
599
- ```typescript
600
- {
601
- entityName: string;
602
- parentName: string | null; // null removes parent
603
- }
604
- ```
605
-
606
- **Returns:** Updated entity
607
-
608
- **Features:**
609
- - Automatic cycle detection
610
- - Updates lastModified timestamp
611
-
612
- **Example:**
613
- ```json
614
- {
615
- "entityName": "Feature_Auth",
616
- "parentName": "Project_Alpha"
617
- }
618
- ```
619
- </details>
620
-
621
- <details>
622
- <summary><b>Hierarchy: get_children</b></summary>
623
-
624
- Get immediate children of an entity.
625
-
626
- **Input:**
627
- ```typescript
628
- {
629
- entityName: string;
630
- }
631
- ```
632
-
633
- **Returns:** Array of child entities
634
-
635
- **Example:**
636
- ```json
637
- {
638
- "entityName": "Project_Alpha"
639
- }
640
- ```
641
- </details>
642
-
643
- <details>
644
- <summary><b>Hierarchy: get_parent</b></summary>
645
-
646
- Get parent entity (or null if root).
647
-
648
- **Input:**
649
- ```typescript
650
- {
651
- entityName: string;
652
- }
653
- ```
654
-
655
- **Returns:** Parent entity or null
656
- </details>
657
-
658
- <details>
659
- <summary><b>Hierarchy: get_ancestors</b></summary>
660
-
661
- Get all ancestors (parent chain to root).
662
-
663
- **Input:**
664
- ```typescript
665
- {
666
- entityName: string;
667
- }
668
- ```
669
-
670
- **Returns:** Array of ancestors (closest to furthest)
671
-
672
- **Example:** Task → Feature → Project → Root
673
- </details>
674
-
675
- <details>
676
- <summary><b>Hierarchy: get_descendants</b></summary>
677
-
678
- Get all descendants recursively (BFS traversal).
679
-
680
- **Input:**
681
- ```typescript
682
- {
683
- entityName: string;
684
- }
685
- ```
686
-
687
- **Returns:** Array of all descendant entities
688
- </details>
689
-
690
- <details>
691
- <summary><b>Hierarchy: get_subtree</b></summary>
692
-
693
- Get entity + all descendants with their relations.
694
-
695
- **Input:**
696
- ```typescript
697
- {
698
- entityName: string;
699
- }
700
- ```
701
-
702
- **Returns:** Subtree (entities + relations)
703
- ```typescript
704
- {
705
- entities: Entity[];
706
- relations: Relation[];
707
- }
708
- ```
709
-
710
- **Use cases:** Export branches, analyze sections, filter by scope
711
- </details>
712
-
713
- <details>
714
- <summary><b>Hierarchy: get_root_entities</b></summary>
715
-
716
- Get all entities with no parent (top-level entities).
717
-
718
- **Input:** None
719
-
720
- **Returns:** Array of root entities
721
- </details>
722
-
723
- <details>
724
- <summary><b>Hierarchy: get_entity_depth</b></summary>
725
-
726
- Get depth in hierarchy (0 = root, 1 = child of root, etc.).
727
-
728
- **Input:**
729
- ```typescript
730
- {
731
- entityName: string;
732
- }
733
- ```
734
-
735
- **Returns:**
736
- ```typescript
737
- {
738
- entityName: string;
739
- depth: number;
740
- }
741
- ```
742
- </details>
743
-
744
- <details>
745
- <summary><b>Hierarchy: move_entity</b></summary>
746
-
747
- Move an entity to a new parent (shorthand for set_entity_parent).
748
-
749
- **Input:**
750
- ```typescript
751
- {
752
- entityName: string;
753
- newParentName: string | null; // null makes it a root entity
754
- }
755
- ```
756
-
757
- **Returns:** Updated entity
758
-
759
- **Features:**
760
- - Automatic cycle detection
761
- - Updates lastModified timestamp
762
- </details>
763
-
764
- ---
765
-
766
- <details>
767
- <summary><b>Compression: find_duplicates</b></summary>
768
-
769
- Find similar entities using multi-factor similarity scoring.
770
-
771
- **Input:**
772
- ```typescript
773
- {
774
- threshold?: number; // Default 0.8 (80% similar)
775
- }
776
- ```
777
-
778
- **Returns:** Array of duplicate entity name groups
779
-
780
- **Algorithm:**
781
- - Name similarity: 40% (Levenshtein distance)
782
- - Type match: 30% (exact match)
783
- - Observation overlap: 20% (Jaccard similarity)
784
- - Tag overlap: 10% (Jaccard similarity)
785
-
786
- **Example:**
787
- ```json
788
- {
789
- "threshold": 0.85
790
- }
791
- ```
792
- </details>
793
-
794
- <details>
795
- <summary><b>Compression: merge_entities</b></summary>
796
-
797
- Merge multiple entities into one target entity.
798
-
799
- **Input:**
800
- ```typescript
801
- {
802
- entityNames: string[];
803
- targetName?: string; // Auto-selects if not provided
804
- }
805
- ```
806
-
807
- **Returns:** Merged entity
808
-
809
- **Merge behavior:**
810
- - Combines unique observations and tags
811
- - Keeps highest importance
812
- - Redirects all relations to target
813
- - Preserves earliest createdAt
814
-
815
- **Example:**
816
- ```json
817
- {
818
- "entityNames": ["Project Alpha", "project-alpha", "Project-Alpha"],
819
- "targetName": "Project Alpha"
820
- }
821
- ```
822
- </details>
823
-
824
- <details>
825
- <summary><b>Compression: compress_graph</b></summary>
826
-
827
- Automated duplicate detection and merging.
828
-
829
- **Input:**
830
- ```typescript
831
- {
832
- threshold?: number; // Default 0.8
833
- dryRun?: boolean; // Default false (preview only)
834
- }
835
- ```
836
-
837
- **Returns:** Compression statistics
838
- ```typescript
839
- {
840
- duplicatesFound: number;
841
- entitiesMerged: number;
842
- observationsCompressed: number;
843
- relationsConsolidated: number;
844
- spaceFreed: number;
845
- mergedEntities: Array<{ kept: string; merged: string[] }>;
846
- }
847
- ```
848
-
849
- **Example:**
850
- ```json
851
- {
852
- "threshold": 0.8,
853
- "dryRun": true
854
- }
855
- ```
856
- </details>
857
-
858
- ---
859
-
860
- <details>
861
- <summary><b>Archiving: archive_entities</b></summary>
862
-
863
- Archive entities based on criteria (OR logic).
864
-
865
- **Input:**
866
- ```typescript
867
- {
868
- olderThan?: string; // ISO date
869
- importanceLessThan?: number; // 0-10
870
- tags?: string[]; // Any match
871
- }
872
- ```
873
-
874
- **Second parameter:** `dryRun` (boolean, default false)
875
-
876
- **Returns:**
877
- ```typescript
878
- {
879
- archived: number;
880
- entityNames: string[];
881
- }
882
- ```
883
-
884
- **Criteria (OR logic):** Archive if ANY criterion matches
885
-
886
- **Example:**
887
- ```json
888
- {
889
- "olderThan": "2025-01-01T00:00:00.000Z",
890
- "importanceLessThan": 3,
891
- "tags": ["completed", "deprecated"]
892
- }
893
- ```
894
- </details>
895
-
896
- ---
897
-
898
- <details>
899
- <summary><b>Search: search_nodes_ranked</b></summary>
900
-
901
- Full-text search with TF-IDF relevance ranking.
902
-
903
- **Input:**
904
- ```typescript
905
- {
906
- query: string;
907
- limit?: number; // Default 50, max 200
908
- }
909
- ```
910
-
911
- **Returns:** Ranked results with scores
912
- ```typescript
913
- Array<{
914
- entityName: string;
915
- score: number;
916
- matchedIn: string[]; // Fields matched
917
- }>
918
- ```
919
-
920
- **Example:**
921
- ```json
922
- {
923
- "query": "machine learning algorithms",
924
- "limit": 10
925
- }
926
- ```
927
- </details>
928
-
929
- <details>
930
- <summary><b>Search: boolean_search</b></summary>
931
-
932
- Advanced boolean queries with logical operators.
933
-
934
- **Input:**
935
- ```typescript
936
- {
937
- query: string; // Boolean expression
938
- }
939
- ```
940
-
941
- **Operators:**
942
- - `AND`, `OR`, `NOT`, `()`
943
- - Field-specific: `name:`, `type:`, `observation:`, `tag:`
944
- - Quoted strings: `"exact phrase"`
945
-
946
- **Example:**
947
- ```json
948
- {
949
- "query": "type:project AND (frontend OR backend) NOT deprecated"
950
- }
951
- ```
952
- </details>
953
-
954
- <details>
955
- <summary><b>Search: fuzzy_search</b></summary>
956
-
957
- Typo-tolerant search using Levenshtein distance.
958
-
959
- **Input:**
960
- ```typescript
961
- {
962
- query: string;
963
- threshold?: number; // Default 0.7 (70% match)
964
- }
965
- ```
966
-
967
- **Returns:** Matching entities (sorted by similarity)
968
-
969
- **Example:**
970
- ```json
971
- {
972
- "query": "projekt",
973
- "threshold": 0.8
974
- }
975
- ```
976
- </details>
977
-
978
- ---
979
-
980
- <details>
981
- <summary><b>Saved Search: save_search</b></summary>
982
-
983
- Save a search query for reuse.
984
-
985
- **Input:**
986
- ```typescript
987
- {
988
- name: string;
989
- query: string;
990
- filters?: object;
991
- description?: string;
992
- }
993
- ```
994
-
995
- **Returns:** Saved search object
996
- </details>
997
-
998
- <details>
999
- <summary><b>Saved Search: list_saved_searches</b></summary>
1000
-
1001
- List all saved searches.
1002
-
1003
- **Input:** None
1004
-
1005
- **Returns:** Array of saved searches with metadata
1006
- </details>
1007
-
1008
- <details>
1009
- <summary><b>Saved Search: execute_saved_search</b></summary>
1010
-
1011
- Execute a saved search (updates usage count).
1012
-
1013
- **Input:**
1014
- ```typescript
1015
- {
1016
- name: string;
1017
- }
1018
- ```
1019
-
1020
- **Returns:** Search results
1021
- </details>
1022
-
1023
- <details>
1024
- <summary><b>Saved Search: delete_saved_search</b></summary>
1025
-
1026
- Delete a saved search.
1027
-
1028
- **Input:**
1029
- ```typescript
1030
- {
1031
- name: string;
1032
- }
1033
- ```
1034
-
1035
- **Returns:** Confirmation
1036
- </details>
1037
-
1038
- <details>
1039
- <summary><b>Saved Search: update_saved_search</b></summary>
1040
-
1041
- Update a saved search.
1042
-
1043
- **Input:**
1044
- ```typescript
1045
- {
1046
- name: string;
1047
- query?: string;
1048
- filters?: object;
1049
- description?: string;
1050
- }
1051
- ```
1052
-
1053
- **Returns:** Updated saved search
1054
- </details>
1055
-
1056
- <details>
1057
- <summary><b>Search: get_search_suggestions</b></summary>
1058
-
1059
- Get "Did you mean?" suggestions for typos.
1060
-
1061
- **Input:**
1062
- ```typescript
1063
- {
1064
- query: string;
1065
- limit?: number; // Default 5
1066
- }
1067
- ```
1068
-
1069
- **Returns:** Array of suggestions with scores
1070
- </details>
1071
-
1072
- ---
1073
-
1074
- <details>
1075
- <summary><b>Tags: add_tags</b></summary>
1076
-
1077
- Add tags to an entity (normalized to lowercase).
1078
-
1079
- **Input:**
1080
- ```typescript
1081
- {
1082
- entityName: string;
1083
- tags: string[];
1084
- }
1085
- ```
1086
-
1087
- **Returns:** Entity with added tags
1088
- </details>
1089
-
1090
- <details>
1091
- <summary><b>Tags: remove_tags</b></summary>
1092
-
1093
- Remove tags from an entity.
1094
-
1095
- **Input:**
1096
- ```typescript
1097
- {
1098
- entityName: string;
1099
- tags: string[];
1100
- }
1101
- ```
1102
-
1103
- **Returns:** Entity with remaining tags
1104
- </details>
1105
-
1106
- <details>
1107
- <summary><b>Tags: add_tags_to_multiple_entities</b></summary>
1108
-
1109
- Add tags to multiple entities at once (bulk operation).
1110
-
1111
- **Input:**
1112
- ```typescript
1113
- {
1114
- entityNames: string[];
1115
- tags: string[];
1116
- }
1117
- ```
1118
-
1119
- **Returns:** Array of results per entity
1120
- </details>
1121
-
1122
- <details>
1123
- <summary><b>Tags: replace_tag</b></summary>
1124
-
1125
- Replace a tag globally across all entities.
1126
-
1127
- **Input:**
1128
- ```typescript
1129
- {
1130
- oldTag: string;
1131
- newTag: string;
1132
- }
1133
- ```
1134
-
1135
- **Returns:** Count of entities updated
1136
- </details>
1137
-
1138
- <details>
1139
- <summary><b>Tags: merge_tags</b></summary>
1140
-
1141
- Merge two tags into one (all entities with tag1 get tag2).
1142
-
1143
- **Input:**
1144
- ```typescript
1145
- {
1146
- sourceTag: string;
1147
- targetTag: string;
1148
- }
1149
- ```
1150
-
1151
- **Returns:** Count of entities updated
1152
- </details>
1153
-
1154
- <details>
1155
- <summary><b>Tag Aliases: add_tag_alias</b></summary>
1156
-
1157
- Create a tag synonym (alias → canonical).
1158
-
1159
- **Input:**
1160
- ```typescript
1161
- {
1162
- alias: string;
1163
- canonical: string;
1164
- description?: string;
1165
- }
1166
- ```
1167
-
1168
- **Example:** "ai" → "artificial-intelligence"
1169
-
1170
- **Returns:** Tag alias object
1171
- </details>
1172
-
1173
- <details>
1174
- <summary><b>Tag Aliases: list_tag_aliases</b></summary>
1175
-
1176
- List all tag aliases.
1177
-
1178
- **Input:** None
1179
-
1180
- **Returns:** Array of tag aliases
1181
- </details>
1182
-
1183
- <details>
1184
- <summary><b>Tag Aliases: get_aliases_for_tag</b></summary>
1185
-
1186
- Get all aliases for a canonical tag.
1187
-
1188
- **Input:**
1189
- ```typescript
1190
- {
1191
- canonical: string;
1192
- }
1193
- ```
1194
-
1195
- **Returns:** Array of aliases
1196
- </details>
1197
-
1198
- <details>
1199
- <summary><b>Tag Aliases: remove_tag_alias</b></summary>
1200
-
1201
- Remove a tag alias.
1202
-
1203
- **Input:**
1204
- ```typescript
1205
- {
1206
- alias: string;
1207
- }
1208
- ```
1209
-
1210
- **Returns:** Confirmation
1211
- </details>
1212
-
1213
- <details>
1214
- <summary><b>Tag Aliases: resolve_tag</b></summary>
1215
-
1216
- Resolve an alias to its canonical form.
1217
-
1218
- **Input:**
1219
- ```typescript
1220
- {
1221
- tag: string;
1222
- }
1223
- ```
1224
-
1225
- **Returns:** Canonical tag name (or original if no alias)
1226
- </details>
1227
-
1228
- ---
1229
-
1230
- <details>
1231
- <summary><b>Analytics: get_graph_stats</b></summary>
1232
-
1233
- Get comprehensive graph statistics.
1234
-
1235
- **Input:** None
1236
-
1237
- **Returns:**
1238
- ```typescript
1239
- {
1240
- totalEntities: number;
1241
- totalRelations: number;
1242
- entityTypesCounts: { [type: string]: number };
1243
- relationTypesCounts: { [type: string]: number };
1244
- oldestEntity: { name: string; date: string };
1245
- newestEntity: { name: string; date: string };
1246
- oldestRelation: { from: string; to: string; date: string };
1247
- newestRelation: { from: string; to: string; date: string };
1248
- entityDateRange: { start: string; end: string };
1249
- relationDateRange: { start: string; end: string };
1250
- }
1251
- ```
1252
- </details>
1253
-
1254
- <details>
1255
- <summary><b>Analytics: validate_graph</b></summary>
1256
-
1257
- Validate graph integrity and detect issues.
1258
-
1259
- **Input:** None
1260
-
1261
- **Returns:**
1262
- ```typescript
1263
- {
1264
- isValid: boolean;
1265
- errors: string[]; // Critical issues
1266
- warnings: string[]; // Non-critical issues
1267
- }
1268
- ```
1269
-
1270
- **Checks:**
1271
- - Orphaned relations
1272
- - Duplicate entities
1273
- - Invalid data
1274
- - Isolated entities (warning)
1275
- - Empty observations (warning)
1276
- </details>
1277
-
1278
- ---
1279
-
1280
- <details>
1281
- <summary><b>Graph Algorithms: find_shortest_path</b></summary>
1282
-
1283
- Find the shortest path between two entities using BFS.
1284
-
1285
- **Input:**
1286
- ```typescript
1287
- {
1288
- from: string; // Source entity name
1289
- to: string; // Target entity name
1290
- directed?: boolean; // Follow relation direction (default: false)
1291
- }
1292
- ```
1293
-
1294
- **Returns:**
1295
- ```typescript
1296
- {
1297
- path: string[]; // Entity names in order
1298
- length: number; // Number of hops
1299
- relations: string[]; // Relation types traversed
1300
- }
1301
- ```
1302
-
1303
- **Example:**
1304
- ```json
1305
- {
1306
- "from": "Alice",
1307
- "to": "Charlie"
1308
- }
1309
- ```
1310
- </details>
1311
-
1312
- <details>
1313
- <summary><b>Graph Algorithms: find_all_paths</b></summary>
1314
-
1315
- Find all paths between two entities with optional depth limit.
1316
-
1317
- **Input:**
1318
- ```typescript
1319
- {
1320
- from: string; // Source entity name
1321
- to: string; // Target entity name
1322
- maxDepth?: number; // Maximum path length (default: 5)
1323
- directed?: boolean; // Follow relation direction (default: false)
1324
- }
1325
- ```
1326
-
1327
- **Returns:**
1328
- ```typescript
1329
- {
1330
- paths: Array<{
1331
- path: string[];
1332
- length: number;
1333
- relations: string[];
1334
- }>;
1335
- count: number;
1336
- }
1337
- ```
26
+ - [License](#license)
1338
27
 
1339
- **Example:**
1340
- ```json
1341
- {
1342
- "from": "Alice",
1343
- "to": "Charlie",
1344
- "maxDepth": 3
1345
- }
1346
- ```
1347
- </details>
28
+ ## Features
1348
29
 
1349
- <details>
1350
- <summary><b>Graph Algorithms: get_connected_components</b></summary>
30
+ ### Core Memory Capabilities
1351
31
 
1352
- Detect isolated subgraphs and analyze connectivity.
32
+ - **Knowledge Graph Storage**: Entity-Relation-Observation model for structured memory
33
+ - **Persistent Memory**: Information persists across chat sessions with JSONL or SQLite storage
34
+ - **Dual Storage Backends**: JSONL (human-readable) or SQLite with better-sqlite3 (3-10x faster, FTS5 search)
35
+ - **Full CRUD Operations**: Create, read, update, delete entities and relations
36
+ - **Flexible Search**: Text-based, fuzzy, boolean, semantic, and TF-IDF ranked search
1353
37
 
1354
- **Input:**
1355
- ```typescript
1356
- {
1357
- directed?: boolean; // Consider direction (default: false)
1358
- }
1359
- ```
38
+ ### Advanced Features
1360
39
 
1361
- **Returns:**
1362
- ```typescript
1363
- {
1364
- components: Array<{
1365
- id: number;
1366
- entities: string[];
1367
- size: number;
1368
- }>;
1369
- totalComponents: number;
1370
- largestComponent: number; // Size of largest
1371
- isolatedNodes: string[]; // Entities with no connections
1372
- }
1373
- ```
1374
- </details>
40
+ | Category | Tools | Description |
41
+ |----------|-------|-------------|
42
+ | **Hierarchical Nesting** | 9 | Parent-child relationships for organizing tree structures |
43
+ | **Graph Algorithms** | 4 | Path finding, connected components, centrality metrics |
44
+ | **Intelligent Search** | 3 | Hybrid multi-layer search with query analysis and reflection |
45
+ | **Semantic Search** | 3 | Embedding-based similarity search with OpenAI or local models |
46
+ | **Memory Compression** | 4 | Intelligent duplicate detection and merging with similarity scoring |
47
+ | **Advanced Search** | 7 | TF-IDF ranking, boolean queries, fuzzy matching, auto-select |
48
+ | **Observation Normalization** | 1 | Coreference resolution and temporal anchoring |
49
+ | **Tag Management** | 11 | Tags, aliases, bulk operations, importance scores |
50
+ | **Saved Searches** | 5 | Store and execute frequent queries |
51
+ | **Import/Export** | 2 | 7 export formats with brotli compression, 3 import formats |
52
+ | **Graph Analytics** | 2 | Statistics, validation, integrity checks |
1375
53
 
1376
- <details>
1377
- <summary><b>Graph Algorithms: get_centrality</b></summary>
54
+ ### Comparison with Official Memory Server
55
+
56
+ | Feature | Official | Enhanced (This Fork) |
57
+ |---------|----------|----------------------|
58
+ | Entity/Relation/Observation Management | ✅ | ✅ |
59
+ | Basic Search | ✅ | ✅ |
60
+ | **Hierarchical Nesting** | ❌ | ✅ Parent-child trees |
61
+ | **Graph Algorithms** | ❌ | ✅ Path finding, centrality |
62
+ | **Semantic Search** | ❌ | ✅ Embedding-based similarity |
63
+ | **Memory Compression** | ❌ | ✅ Duplicate detection |
64
+ | **Brotli Compression** | ❌ | ✅ Backups, exports, responses |
65
+ | **Smart Archiving** | ❌ | ✅ Criteria-based |
66
+ | **Advanced Search** | ❌ | ✅ TF-IDF + Boolean + Fuzzy |
67
+ | **SQLite Backend** | ❌ | ✅ better-sqlite3 (3-10x faster) |
68
+ | **Full-Text Search** | ❌ | ✅ FTS5 with BM25 ranking |
69
+ | **Timestamps** | ❌ | ✅ createdAt + lastModified |
70
+ | **Import/Export Formats** | ❌ | ✅ 7 export / 3 import |
71
+ | **Input Validation** | ❌ | ✅ Zod schemas |
72
+ | **Backup & Restore** | ❌ | ✅ Compressed snapshots |
73
+ | **Intelligent Search** | ❌ | ✅ Hybrid + Query Analysis + Reflection |
74
+ | **Observation Normalization** | ❌ | ✅ Coreference resolution + temporal anchoring |
75
+ | **Total Tools** | 11 | **59** |
76
+ | **Code Structure** | Monolithic | **Modular** (65 files) |
1378
77
 
1379
- Calculate centrality metrics to identify important nodes.
78
+ ## Quick Start
1380
79
 
1381
- **Input:**
1382
- ```typescript
1383
- {
1384
- metric: "degree" | "betweenness" | "pagerank";
1385
- direction?: "in" | "out" | "both"; // For degree centrality
1386
- limit?: number; // Top N results (default: 10)
1387
- }
1388
- ```
80
+ ### 1. Install from NPM
1389
81
 
1390
- **Returns:**
1391
- ```typescript
1392
- Array<{
1393
- entity: string;
1394
- score: number;
1395
- rank: number;
1396
- }>
82
+ ```bash
83
+ npm install -g @danielsimonjr/memory-mcp
1397
84
  ```
1398
85
 
1399
- **Metrics:**
1400
- - **degree**: Count of connections (hub identification)
1401
- - **betweenness**: Bridge nodes connecting subgraphs
1402
- - **pagerank**: Influence based on connections to influential nodes
86
+ Or use with npx (no installation required):
1403
87
 
1404
- **Example:**
1405
- ```json
1406
- {
1407
- "metric": "pagerank",
1408
- "limit": 5
1409
- }
88
+ ```bash
89
+ npx @danielsimonjr/memory-mcp
1410
90
  ```
1411
- </details>
1412
-
1413
- ---
1414
91
 
1415
- <details>
1416
- <summary><b>Semantic Search: semantic_search</b></summary>
92
+ ### 2. Configure Claude Desktop
1417
93
 
1418
- Search using semantic similarity with embeddings.
94
+ Add to `claude_desktop_config.json`:
1419
95
 
1420
- **Input:**
1421
- ```typescript
96
+ **Using NPM Global Install:**
97
+ ```json
1422
98
  {
1423
- query: string; // Natural language query
1424
- limit?: number; // Max results (default: 10)
1425
- threshold?: number; // Min similarity 0-1 (default: 0.5)
99
+ "mcpServers": {
100
+ "memory": {
101
+ "command": "mcp-server-memory"
102
+ }
103
+ }
1426
104
  }
1427
105
  ```
1428
106
 
1429
- **Returns:**
1430
- ```typescript
1431
- Array<{
1432
- entity: Entity;
1433
- similarity: number; // 0-1 cosine similarity
1434
- }>
1435
- ```
1436
-
1437
- **Example:**
107
+ **Using NPX:**
1438
108
  ```json
1439
109
  {
1440
- "query": "machine learning projects",
1441
- "limit": 5,
1442
- "threshold": 0.7
110
+ "mcpServers": {
111
+ "memory": {
112
+ "command": "npx",
113
+ "args": ["-y", "@danielsimonjr/memory-mcp"]
114
+ }
115
+ }
1443
116
  }
1444
117
  ```
1445
118
 
1446
- **Note:** Requires embedding provider configuration. See [Configuration](#configuration).
1447
- </details>
1448
-
1449
- <details>
1450
- <summary><b>Semantic Search: find_similar_entities</b></summary>
119
+ ### 3. Restart Claude Desktop
1451
120
 
1452
- Find entities semantically similar to a reference entity.
121
+ Restart Claude Desktop to load the enhanced memory server.
1453
122
 
1454
- **Input:**
1455
- ```typescript
1456
- {
1457
- entityName: string; // Reference entity
1458
- limit?: number; // Max results (default: 10)
1459
- threshold?: number; // Min similarity 0-1 (default: 0.5)
1460
- }
1461
- ```
123
+ ### 4. Start Using
1462
124
 
1463
- **Returns:**
1464
- ```typescript
1465
- Array<{
1466
- entity: Entity;
1467
- similarity: number;
1468
- }>
125
+ Tell Claude:
1469
126
  ```
1470
-
1471
- **Example:**
1472
- ```json
1473
- {
1474
- "entityName": "Project_Alpha",
1475
- "limit": 5
1476
- }
127
+ Please remember that I prefer TypeScript over JavaScript.
128
+ Tag this as "preferences" with importance 8.
129
+ Create a parent entity called "Development Preferences" and nest this under it.
1477
130
  ```
1478
- </details>
1479
131
 
1480
- <details>
1481
- <summary><b>Semantic Search: index_embeddings</b></summary>
1482
-
1483
- Build or rebuild the semantic search index.
132
+ ## Installation
1484
133
 
1485
- **Input:**
1486
- ```typescript
1487
- {
1488
- force?: boolean; // Rebuild even if index exists (default: false)
1489
- }
1490
- ```
134
+ ### Local Build
1491
135
 
1492
- **Returns:**
1493
- ```typescript
1494
- {
1495
- indexed: number; // Entities indexed
1496
- skipped: number; // Already indexed (if not forced)
1497
- duration: number; // Time in ms
1498
- }
1499
- ```
136
+ ```bash
137
+ # Clone repository
138
+ git clone https://github.com/danielsimonjr/memory-mcp.git
139
+ cd memory-mcp
1500
140
 
1501
- **Note:** Required before using semantic_search if auto-indexing is disabled.
1502
- </details>
141
+ # Install and build
142
+ npm install
143
+ npm run build
1503
144
 
1504
- ---
145
+ # Run tests (2692+ tests)
146
+ npm test
1505
147
 
1506
- <details>
1507
- <summary><b>Export: export_graph</b></summary>
148
+ # Type check
149
+ npm run typecheck
150
+ ```
1508
151
 
1509
- Export knowledge graph in multiple formats with optional compression.
152
+ ### Claude Desktop Configuration
1510
153
 
1511
- **Input:**
1512
- ```typescript
1513
- {
1514
- format: "json" | "csv" | "graphml" | "gexf" | "dot" | "markdown" | "mermaid";
1515
- filter?: {
1516
- startDate?: string;
1517
- endDate?: string;
1518
- entityType?: string;
1519
- tags?: string[];
1520
- };
1521
- compress?: boolean; // Enable brotli compression (auto for >100KB)
1522
- compressionQuality?: number; // 0-11, default 6
1523
- }
1524
- ```
154
+ Add to `~/Library/Application Support/Claude/claude_desktop_config.json` (Mac) or `%APPDATA%\Claude\claude_desktop_config.json` (Windows):
1525
155
 
1526
- **Formats:**
1527
- - **JSON**: Pretty-printed with all data
1528
- - **CSV**: Entities + relations sections
1529
- - **GraphML**: XML for Gephi, Cytoscape, yEd
1530
- - **GEXF**: Gephi native format
1531
- - **DOT**: GraphViz for publication
1532
- - **Markdown**: Human-readable documentation
1533
- - **Mermaid**: Embedded diagrams
1534
-
1535
- **Compression:**
1536
- - Exports >100KB are automatically compressed unless `compress: false`
1537
- - Compressed output is base64-encoded for safe JSON transport
1538
- - Returns `ExportResult` with compression metadata
1539
-
1540
- **Example:**
1541
156
  ```json
1542
157
  {
1543
- "format": "json",
1544
- "compress": true,
1545
- "compressionQuality": 9
158
+ "mcpServers": {
159
+ "memory": {
160
+ "command": "node",
161
+ "args": ["<PATH_TO>/memory-mcp/dist/index.js"],
162
+ "env": {
163
+ "MEMORY_FILE_PATH": "<PATH_TO>/memory.jsonl"
164
+ }
165
+ }
166
+ }
1546
167
  }
1547
168
  ```
1548
- </details>
1549
169
 
1550
- <details>
1551
- <summary><b>Import: import_graph</b></summary>
170
+ ### VS Code
1552
171
 
1553
- Import knowledge graph from JSON, CSV, or GraphML.
172
+ Add to `.vscode/mcp.json`:
1554
173
 
1555
- **Input:**
1556
- ```typescript
174
+ ```json
1557
175
  {
1558
- format: "json" | "csv" | "graphml";
1559
- data: string;
1560
- strategy?: "replace" | "skip" | "merge" | "fail"; // Default "merge"
1561
- dryRun?: boolean; // Default false
176
+ "servers": {
177
+ "memory": {
178
+ "command": "node",
179
+ "args": ["/path/to/memory-mcp/dist/index.js"]
180
+ }
181
+ }
1562
182
  }
1563
183
  ```
1564
184
 
1565
- **Merge strategies:**
1566
- - **replace**: Overwrite existing entities
1567
- - **skip**: Keep existing, skip imports
1568
- - **merge**: Combine observations/tags
1569
- - **fail**: Error on conflicts
1570
-
1571
- **Returns:** Import statistics
1572
- ```typescript
1573
- {
1574
- entitiesImported: number;
1575
- relationsImported: number;
1576
- entitiesSkipped: number;
1577
- relationsSkipped: number;
1578
- errors: string[];
1579
- }
1580
- ```
1581
- </details>
185
+ ## Core Concepts
1582
186
 
1583
- ## Data Model
187
+ ### Entities
1584
188
 
1585
- ### Entity Schema
189
+ Primary nodes in the knowledge graph.
1586
190
 
1587
191
  ```typescript
1588
192
  interface Entity {
1589
- name: string; // Unique identifier
1590
- entityType: string; // Classification
1591
- observations: string[]; // Facts about the entity
1592
- parentId?: string; // Parent entity (v0.8.0)
1593
- createdAt?: string; // ISO 8601 timestamp
1594
- lastModified?: string; // ISO 8601 timestamp
1595
- tags?: string[]; // Lowercase tags
1596
- importance?: number; // 0-10 scale
193
+ name: string; // Unique identifier
194
+ entityType: string; // Classification
195
+ observations: string[]; // Facts about the entity
196
+ parentId?: string; // Parent entity name for hierarchical nesting
197
+ tags?: string[]; // Lowercase tags for categorization
198
+ importance?: number; // 0-10 scale for prioritization
199
+ createdAt?: string; // ISO 8601 timestamp
200
+ lastModified?: string; // ISO 8601 timestamp
1597
201
  }
1598
202
  ```
1599
203
 
1600
- ### Relation Schema
204
+ ### Relations
205
+
206
+ Directed connections between entities.
1601
207
 
1602
208
  ```typescript
1603
209
  interface Relation {
1604
- from: string; // Source entity name
1605
- to: string; // Target entity name
1606
- relationType: string; // Relationship type
1607
- createdAt?: string; // ISO 8601 timestamp
1608
- lastModified?: string; // ISO 8601 timestamp
1609
- }
1610
- ```
1611
-
1612
- ### Storage Files
1613
-
1614
- The server automatically creates and manages these files:
1615
-
1616
- - **`memory.jsonl`**: Main knowledge graph storage (entities and relations)
1617
- - **`memory-saved-searches.jsonl`**: Saved search queries with metadata
1618
- - **`memory-tag-aliases.jsonl`**: Tag synonym mappings (alias → canonical)
1619
- - **`.backups/`**: Backup directory with timestamped snapshots
1620
-
1621
- All files use JSONL (JSON Lines) format where each line is a valid JSON object.
1622
-
1623
- **Custom path:** Set `MEMORY_FILE_PATH` environment variable (see [Configuration](#configuration))
1624
-
1625
- ## Usage Examples
1626
-
1627
- ### Example 1: Hierarchical Project Structure
1628
-
1629
- ```json
1630
- // Create entities
1631
- {
1632
- "entities": [
1633
- { "name": "Project_Alpha", "entityType": "project", "observations": ["Web app rewrite"] },
1634
- { "name": "Feature_Auth", "entityType": "feature", "observations": ["User authentication"] },
1635
- { "name": "Task_Login", "entityType": "task", "observations": ["Implement login UI"] }
1636
- ]
210
+ from: string; // Source entity name
211
+ to: string; // Target entity name
212
+ relationType: string; // Relationship type (active voice)
213
+ createdAt?: string; // ISO 8601 timestamp
214
+ lastModified?: string; // ISO 8601 timestamp
1637
215
  }
1638
-
1639
- // Set hierarchy
1640
- { "entityName": "Feature_Auth", "parentName": "Project_Alpha" }
1641
- { "entityName": "Task_Login", "parentName": "Feature_Auth" }
1642
-
1643
- // Navigate
1644
- { "entityName": "Project_Alpha" } // get_children → [Feature_Auth]
1645
- { "entityName": "Task_Login" } // get_ancestors → [Feature_Auth, Project_Alpha]
1646
- ```
1647
-
1648
- ### Example 2: Duplicate Detection and Merging
1649
-
1650
- ```json
1651
- // Find duplicates
1652
- { "threshold": 0.8 } // find_duplicates
1653
-
1654
- // Merge duplicates
1655
- {
1656
- "entityNames": ["Project Alpha", "project-alpha", "Project-Alpha"],
1657
- "targetName": "Project Alpha"
1658
- } // merge_entities
1659
-
1660
- // Auto-compress
1661
- { "threshold": 0.8, "dryRun": true } // compress_graph (preview)
1662
- { "threshold": 0.8, "dryRun": false } // compress_graph (execute)
1663
216
  ```
1664
217
 
1665
- ### Example 3: Smart Archiving
218
+ ### Observations
1666
219
 
1667
- ```json
1668
- // Archive old, low-priority, or completed entities
1669
- {
1670
- "olderThan": "2025-01-01T00:00:00.000Z",
1671
- "importanceLessThan": 3,
1672
- "tags": ["completed", "deprecated"]
1673
- } // archive_entities (OR logic)
1674
- ```
220
+ Discrete facts about entities. Each observation should be atomic and independently manageable.
1675
221
 
1676
- ### Example 4: Advanced Search
222
+ ## API Reference
1677
223
 
1678
- ```json
1679
- // Boolean search
1680
- { "query": "type:project AND (frontend OR backend) NOT deprecated" }
224
+ ### Complete Tool List (59 Tools)
1681
225
 
1682
- // TF-IDF ranking
1683
- { "query": "machine learning algorithms", "limit": 10 }
226
+ #### Entity Operations (4 tools)
227
+ | Tool | Description |
228
+ |------|-------------|
229
+ | `create_entities` | Create multiple new entities |
230
+ | `delete_entities` | Remove entities and their relations |
231
+ | `read_graph` | Read entire knowledge graph |
232
+ | `open_nodes` | Retrieve specific nodes by name |
1684
233
 
1685
- // Fuzzy search
1686
- { "query": "projekt", "threshold": 0.8 }
1687
- ```
234
+ #### Relation Operations (2 tools)
235
+ | Tool | Description |
236
+ |------|-------------|
237
+ | `create_relations` | Create relations between entities |
238
+ | `delete_relations` | Remove specific relations |
239
+
240
+ #### Observation Management (3 tools)
241
+ | Tool | Description |
242
+ |------|-------------|
243
+ | `add_observations` | Add observations to entities |
244
+ | `delete_observations` | Remove specific observations |
245
+ | `normalize_observations` | Normalize observations (resolve pronouns, anchor dates) |
1688
246
 
1689
- ### Example 5: Tag Management
247
+ #### Search (7 tools)
248
+ | Tool | Description |
249
+ |------|-------------|
250
+ | `search_nodes` | Search with filters (tags, importance) |
251
+ | `search_by_date_range` | Filter by date range |
252
+ | `search_nodes_ranked` | TF-IDF relevance ranking |
253
+ | `boolean_search` | Boolean queries (AND/OR/NOT) |
254
+ | `fuzzy_search` | Typo-tolerant search |
255
+ | `get_search_suggestions` | "Did you mean?" suggestions |
256
+ | `search_auto` | Auto-select best search method |
257
+
258
+ #### Intelligent Search (3 tools)
259
+ | Tool | Description |
260
+ |------|-------------|
261
+ | `hybrid_search` | Multi-layer search combining semantic, lexical, and symbolic signals |
262
+ | `analyze_query` | Extract entities, temporal references, and classify query complexity |
263
+ | `smart_search` | Reflection-based iterative search until results meet adequacy threshold |
1690
264
 
1691
- ```json
1692
- // Bulk tag operations
1693
- {
1694
- "entityNames": ["Entity1", "Entity2", "Entity3"],
1695
- "tags": ["new-tag"]
1696
- } // add_tags_to_multiple
265
+ #### Semantic Search (3 tools)
266
+ | Tool | Description |
267
+ |------|-------------|
268
+ | `semantic_search` | Search by semantic similarity using embeddings |
269
+ | `find_similar_entities` | Find entities similar to a reference entity |
270
+ | `index_embeddings` | Build or rebuild the semantic search index |
1697
271
 
1698
- // Tag aliases
1699
- { "alias": "ai", "canonical": "artificial-intelligence" } // add_tag_alias
272
+ #### Saved Searches (5 tools)
273
+ | Tool | Description |
274
+ |------|-------------|
275
+ | `save_search` | Save search query for reuse |
276
+ | `execute_saved_search` | Execute a saved search |
277
+ | `list_saved_searches` | List all saved searches |
278
+ | `delete_saved_search` | Delete a saved search |
279
+ | `update_saved_search` | Update saved search parameters |
1700
280
 
1701
- // Merge tags
1702
- { "sourceTag": "ml", "targetTag": "machine-learning" } // merge_tags
1703
- ```
281
+ #### Tag Management (6 tools)
282
+ | Tool | Description |
283
+ |------|-------------|
284
+ | `add_tags` | Add tags to an entity |
285
+ | `remove_tags` | Remove tags from an entity |
286
+ | `set_importance` | Set entity importance (0-10) |
287
+ | `add_tags_to_multiple_entities` | Bulk tag operation |
288
+ | `replace_tag` | Replace tag globally |
289
+ | `merge_tags` | Merge two tags into one |
1704
290
 
1705
- ## Documentation
291
+ #### Tag Aliases (5 tools)
292
+ | Tool | Description |
293
+ |------|-------------|
294
+ | `add_tag_alias` | Create tag synonym |
295
+ | `list_tag_aliases` | List all aliases |
296
+ | `remove_tag_alias` | Remove an alias |
297
+ | `get_aliases_for_tag` | Get aliases for canonical tag |
298
+ | `resolve_tag` | Resolve alias to canonical form |
1706
299
 
1707
- ### 📚 **[Complete Documentation](docs/README.md)**
300
+ #### Hierarchical Nesting (9 tools)
301
+ | Tool | Description |
302
+ |------|-------------|
303
+ | `set_entity_parent` | Set/remove parent relationship |
304
+ | `get_children` | Get immediate children |
305
+ | `get_parent` | Get parent entity |
306
+ | `get_ancestors` | Get all ancestors (parent chain) |
307
+ | `get_descendants` | Get all descendants (recursive) |
308
+ | `get_subtree` | Get entity + descendants with relations |
309
+ | `get_root_entities` | Get entities with no parent |
310
+ | `get_entity_depth` | Get depth in hierarchy |
311
+ | `move_entity` | Move entity to new parent |
1708
312
 
1709
- Comprehensive documentation organized by category:
313
+ #### Graph Algorithms (4 tools)
314
+ | Tool | Description |
315
+ |------|-------------|
316
+ | `find_shortest_path` | Shortest path between entities (BFS) |
317
+ | `find_all_paths` | All paths with max depth limit |
318
+ | `get_connected_components` | Detect isolated subgraphs |
319
+ | `get_centrality` | Calculate centrality metrics (degree, betweenness, PageRank) |
1710
320
 
1711
- **Core Documentation**
1712
- - **[API Reference](docs/architecture/API.md)** - Complete API documentation for all 55 tools
1713
- - **[Architecture](docs/architecture/ARCHITECTURE.md)** - Technical architecture and system design
1714
- - **[Dependency Graph](docs/architecture/DEPENDENCY_GRAPH.md)** - Module dependencies and structure
1715
- - **[Workflow](docs/development/WORKFLOW.md)** - Development workflow and procedures
321
+ #### Graph Analytics (2 tools)
322
+ | Tool | Description |
323
+ |------|-------------|
324
+ | `get_graph_stats` | Comprehensive graph statistics |
325
+ | `validate_graph` | Validate graph integrity |
1716
326
 
1717
- **User Guides**
1718
- - **[Hierarchy Guide](docs/guides/HIERARCHY.md)** - Parent-child relationships (9 tools)
1719
- - **[Compression Guide](docs/guides/COMPRESSION.md)** - Duplicate detection and merging (4 tools)
1720
- - **[Archiving Guide](docs/guides/ARCHIVING.md)** - Memory lifecycle and archiving
1721
- - **[Query Language](docs/guides/QUERY_LANGUAGE.md)** - Boolean search syntax reference
1722
- - **[Migration Guide](docs/guides/MIGRATION.md)** - Version upgrade guide
327
+ #### Compression & Archiving (4 tools)
328
+ | Tool | Description |
329
+ |------|-------------|
330
+ | `find_duplicates` | Find similar entities by threshold |
331
+ | `merge_entities` | Merge multiple entities into one |
332
+ | `compress_graph` | Auto compression with dry-run |
333
+ | `archive_entities` | Archive by age, importance, or tags |
1723
334
 
1724
- **Project Information**
1725
- - **[Changelog](CHANGELOG.md)** - Version history and release notes
1726
- - **[Sprint Progress](docs/reports/SPRINT_PROGRESS.md)** - Development progress tracking
1727
- - **[Future Features & Roadmap](docs/roadmap/FUTURE_FEATURES.md)** - Performance optimizations and planned features
335
+ #### Import & Export (2 tools)
336
+ | Tool | Description |
337
+ |------|-------------|
338
+ | `export_graph` | Export in 7 formats (JSON, CSV, GraphML, GEXF, DOT, Markdown, Mermaid) with compression |
339
+ | `import_graph` | Import from JSON/CSV/GraphML with merge strategies |
1728
340
 
1729
341
  ## Configuration
1730
342
 
1731
343
  ### Environment Variables
1732
344
 
1733
- #### Storage Configuration
1734
-
1735
- - **`MEMORY_FILE_PATH`**: Path to the main memory storage file
1736
- - **Default**: `memory.jsonl` in the current working directory
1737
- - Sets the location for the primary knowledge graph storage
1738
-
1739
- - **`MEMORY_STORAGE_TYPE`**: Storage backend to use
1740
- - **Values**: `jsonl` (default) or `sqlite`
1741
- - **JSONL**: Human-readable, line-based JSON format
1742
- - **SQLite**: Native database with better-sqlite3 (3-10x faster, FTS5 full-text search, WAL mode)
1743
-
1744
- #### Semantic Search Configuration
1745
-
1746
- - **`MEMORY_EMBEDDING_PROVIDER`**: Embedding provider for semantic search
1747
- - **Values**: `openai`, `local`, or `none` (default)
1748
- - **openai**: Use OpenAI's text-embedding API (requires API key)
1749
- - **local**: Use local transformer models via @xenova/transformers
1750
- - **none**: Disable semantic search features
1751
-
1752
- - **`MEMORY_OPENAI_API_KEY`**: OpenAI API key (required if provider is `openai`)
1753
-
1754
- - **`MEMORY_EMBEDDING_MODEL`**: Embedding model to use
1755
- - **OpenAI default**: `text-embedding-3-small`
1756
- - **Local default**: `Xenova/all-MiniLM-L6-v2`
1757
-
1758
- - **`MEMORY_AUTO_INDEX_EMBEDDINGS`**: Auto-index entities on creation
1759
- - **Values**: `true` or `false` (default)
1760
- - When enabled, new entities are automatically indexed for semantic search
345
+ | Variable | Description | Default |
346
+ |----------|-------------|---------|
347
+ | `MEMORY_FILE_PATH` | Path to storage file | `memory.jsonl` (current directory) |
348
+ | `MEMORY_STORAGE_TYPE` | Storage backend: `jsonl` or `sqlite` | `jsonl` |
349
+ | `MEMORY_EMBEDDING_PROVIDER` | Embedding provider: `openai`, `local`, or `none` | `none` |
350
+ | `MEMORY_OPENAI_API_KEY` | OpenAI API key (required if provider is `openai`) | - |
351
+ | `MEMORY_EMBEDDING_MODEL` | Embedding model to use | `text-embedding-3-small` (OpenAI) / `Xenova/all-MiniLM-L6-v2` (local) |
352
+ | `MEMORY_AUTO_INDEX_EMBEDDINGS` | Auto-index entities on creation | `false` |
1761
353
 
1762
354
  ### Storage Backends
1763
355
 
@@ -1765,14 +357,12 @@ Comprehensive documentation organized by category:
1765
357
  |---------|-----------------|-------------------------|
1766
358
  | Format | Human-readable text | Native binary database |
1767
359
  | Transactions | Basic | Full ACID with WAL mode |
1768
- | Indexing | In-memory | B-tree + FTS5 full-text |
1769
360
  | Full-Text Search | Basic | FTS5 with BM25 ranking |
1770
361
  | Performance | Good | 3-10x faster |
1771
362
  | Concurrency | Single-threaded | Thread-safe with async-mutex |
1772
363
  | Best For | Small graphs, debugging | Large graphs (10k+ entities) |
1773
- | File Extension | `.jsonl` | `.db`, `.sqlite` |
1774
364
 
1775
- **Using SQLite Storage:**
365
+ **Using SQLite:**
1776
366
 
1777
367
  ```json
1778
368
  {
@@ -1789,80 +379,34 @@ Comprehensive documentation organized by category:
1789
379
  }
1790
380
  ```
1791
381
 
1792
- ### Migrating from JSONL to SQLite
1793
-
1794
- Use the included migration tool to convert your existing JSONL data to SQLite:
1795
-
1796
- ```bash
1797
- # Navigate to the migration tool
1798
- cd tools/migrate-from-jsonl-to-sqlite
1799
- npm install
1800
- npm run build:ts
1801
-
1802
- # Migrate JSONL to SQLite
1803
- node dist/migrate-from-jsonl-to-sqlite.js --from /path/to/memory.jsonl --to /path/to/memory.db
1804
-
1805
- # Migrate SQLite back to JSONL (if needed)
1806
- node dist/migrate-from-jsonl-to-sqlite.js --from /path/to/memory.db --to /path/to/memory.jsonl
1807
-
1808
- # Or build standalone executable
1809
- npm run build
1810
- ./migrate-from-jsonl-to-sqlite.exe --from memory.jsonl --to memory.db
1811
- ```
1812
-
1813
- See [tools/migrate-from-jsonl-to-sqlite/README.md](tools/migrate-from-jsonl-to-sqlite/README.md) for complete documentation.
1814
-
1815
- **Migration Notes:**
1816
- - All entities, relations, and metadata are preserved
1817
- - Saved searches and tag aliases are stored in separate files and are NOT migrated
1818
- - The target file is created if it doesn't exist, or overwritten if it does
1819
-
1820
- ### Storage File Organization
382
+ ### Storage Files
1821
383
 
1822
- When you set `MEMORY_FILE_PATH`, the server automatically creates related files in the same directory:
384
+ When you set `MEMORY_FILE_PATH`, the server automatically creates related files:
1823
385
 
1824
386
  ```
1825
387
  /your/data/directory/
1826
- ├── memory.jsonl # Main knowledge graph (active entities & relations)
388
+ ├── memory.jsonl # Main knowledge graph
1827
389
  ├── memory-saved-searches.jsonl # Saved search queries
1828
390
  ├── memory-tag-aliases.jsonl # Tag synonym mappings
1829
- └── .backups/ # Timestamped backup directory
1830
- ├── backup_2025-11-24_10-30-00-123.jsonl
1831
- ├── backup_2025-11-24_10-30-00-123.jsonl.meta.json
1832
- └── ...
391
+ └── .backups/ # Timestamped backups
392
+ ├── backup_2026-01-08_10-30-00-123.jsonl
393
+ └── backup_2026-01-08_10-30-00-123.jsonl.meta.json
1833
394
  ```
1834
395
 
1835
- **Note**: All auxiliary files use the same base filename as `MEMORY_FILE_PATH` with descriptive suffixes.
396
+ ### Migration Tool
1836
397
 
1837
- ### Example Configuration
398
+ Convert between JSONL and SQLite formats:
1838
399
 
1839
- **Claude Desktop (`claude_desktop_config.json`):**
1840
- ```json
1841
- {
1842
- "mcpServers": {
1843
- "memory": {
1844
- "command": "node",
1845
- "args": ["/path/to/memory-mcp/dist/index.js"],
1846
- "env": {
1847
- "MEMORY_FILE_PATH": "/path/to/data/memory.jsonl"
1848
- }
1849
- }
1850
- }
1851
- }
1852
- ```
400
+ ```bash
401
+ cd tools/migrate-from-jsonl-to-sqlite
402
+ npm install && npm run build
1853
403
 
1854
- **Default behavior (no environment variable):**
1855
- ```json
1856
- {
1857
- "mcpServers": {
1858
- "memory": {
1859
- "command": "node",
1860
- "args": ["/path/to/memory-mcp/dist/index.js"]
1861
- }
1862
- }
1863
- }
404
+ # JSONL to SQLite
405
+ node dist/migrate-from-jsonl-to-sqlite.js --from memory.jsonl --to memory.db
406
+
407
+ # SQLite to JSONL
408
+ node dist/migrate-from-jsonl-to-sqlite.js --from memory.db --to memory.jsonl
1864
409
  ```
1865
- Creates `memory.jsonl` in the current working directory.
1866
410
 
1867
411
  ## Development
1868
412
 
@@ -1872,28 +416,25 @@ Creates `memory.jsonl` in the current working directory.
1872
416
  - npm 9+
1873
417
  - TypeScript 5.6+
1874
418
 
1875
- ### Build
1876
-
1877
- ```bash
1878
- npm install
1879
- npm run build # Production build
1880
- npm run watch # Development watch mode
1881
- ```
1882
-
1883
- ### Test
419
+ ### Build Commands
1884
420
 
1885
421
  ```bash
1886
- npm test # Run test suite with coverage
1887
- npm run typecheck # TypeScript type checking
422
+ npm install # Install dependencies
423
+ npm run build # Build TypeScript
424
+ npm test # Run tests (2692+ tests)
425
+ npm run typecheck # Strict type checking
426
+ npm run watch # Development watch mode
427
+ npm run clean # Remove dist/ directory
428
+ npm run docs:deps # Generate dependency graph
1888
429
  ```
1889
430
 
1890
- ### Architecture Overview
431
+ ### Architecture
1891
432
 
1892
433
  ```
1893
434
  ┌─────────────────────────────────────────────────────┐
1894
435
  │ Layer 1: MCP Protocol Layer │
1895
- │ server/MCPServer.ts + toolDefinitions
1896
- │ + toolHandlers (55 tools) + responseCompressor
436
+ │ server/MCPServer.ts + toolDefinitions (59 tools)
437
+ │ + toolHandlers + responseCompressor
1897
438
  └──────────────────────┬──────────────────────────────┘
1898
439
 
1899
440
  ┌──────────────────────┴──────────────────────────────┐
@@ -1920,11 +461,11 @@ npm run typecheck # TypeScript type checking
1920
461
 
1921
462
  ```
1922
463
  memory-mcp/
1923
- ├── src/ # Main source (58 TypeScript files)
464
+ ├── src/ # Source (65 TypeScript files)
1924
465
  │ ├── index.ts # Entry point
1925
- │ ├── core/ # Core managers (11 files)
466
+ │ ├── core/ # Core managers (12 files)
1926
467
  │ │ ├── ManagerContext.ts # Context holder (lazy init)
1927
- │ │ ├── EntityManager.ts # Entity CRUD + hierarchy + archive
468
+ │ │ ├── EntityManager.ts # Entity CRUD + hierarchy
1928
469
  │ │ ├── RelationManager.ts # Relation CRUD
1929
470
  │ │ ├── GraphStorage.ts # JSONL I/O + caching
1930
471
  │ │ ├── SQLiteStorage.ts # SQLite with better-sqlite3
@@ -1932,81 +473,91 @@ memory-mcp/
1932
473
  │ │ ├── StorageFactory.ts # Storage backend factory
1933
474
  │ │ ├── HierarchyManager.ts # Tree operations
1934
475
  │ │ ├── ObservationManager.ts # Observation CRUD
1935
- │ │ ├── GraphTraversal.ts # Path finding, centrality, BFS/DFS
1936
- │ │ └── index.ts # Barrel export (+ KnowledgeGraphManager alias)
1937
- ├── server/ # MCP protocol layer (4 files)
1938
- ├── MCPServer.ts # Server setup (67 lines)
1939
- │ │ ├── toolDefinitions.ts # 55 tool schemas
476
+ │ │ ├── GraphTraversal.ts # Path finding, centrality
477
+ │ │ ├── GraphEventEmitter.ts # Event system
478
+ │ └── index.ts
479
+ │ ├── server/ # MCP protocol (4 files)
480
+ │ │ ├── MCPServer.ts # Server setup
481
+ │ │ ├── toolDefinitions.ts # 59 tool schemas
1940
482
  │ │ ├── toolHandlers.ts # Handler registry
1941
- │ │ └── responseCompressor.ts # Brotli response compression
1942
- │ ├── search/ # Search implementations (13 files)
1943
- │ │ ├── SearchManager.ts # Search orchestrator + compression + analytics
483
+ │ │ └── responseCompressor.ts # Brotli compression
484
+ │ ├── search/ # Search implementations (20 files)
485
+ │ │ ├── SearchManager.ts # Search orchestrator
1944
486
  │ │ ├── BasicSearch.ts # Text matching
1945
487
  │ │ ├── RankedSearch.ts # TF-IDF scoring
1946
488
  │ │ ├── BooleanSearch.ts # AND/OR/NOT logic
1947
489
  │ │ ├── FuzzySearch.ts # Typo tolerance
1948
- │ │ ├── SavedSearchManager.ts # Saved queries
1949
- │ │ ├── SearchSuggestions.ts # "Did you mean?"
1950
- │ │ ├── TFIDFIndexManager.ts # TF-IDF index
1951
- │ │ ├── SearchFilterChain.ts # Unified filters
1952
- ├── EmbeddingService.ts # Embedding provider abstraction
1953
- │ │ ├── VectorStore.ts # Vector storage + similarity
1954
- │ │ ├── SemanticSearch.ts # Semantic search manager
1955
- │ │ └── index.ts
1956
- │ ├── features/ # Advanced capabilities (6 files)
1957
- │ │ ├── IOManager.ts # Import + export + backup (consolidated)
490
+ │ │ ├── SemanticSearch.ts # Embedding-based
491
+ │ │ ├── EmbeddingService.ts # Provider abstraction
492
+ │ │ ├── VectorStore.ts # Vector storage
493
+ │ │ └── ... # + 12 more
494
+ │ ├── features/ # Advanced capabilities (9 files)
495
+ │ │ ├── IOManager.ts # Import/export/backup
1958
496
  │ │ ├── TagManager.ts # Tag aliases
1959
- │ │ ├── AnalyticsManager.ts # Graph stats/validation
497
+ │ │ ├── AnalyticsManager.ts # Graph stats
1960
498
  │ │ ├── ArchiveManager.ts # Entity archival
1961
- │ │ ├── CompressionManager.ts # Duplicate detection/merging
499
+ │ │ ├── CompressionManager.ts # Duplicate detection
500
+ │ │ ├── StreamingExporter.ts # Large graph exports
501
+ │ │ ├── ObservationNormalizer.ts # Coreference resolution
502
+ │ │ ├── KeywordExtractor.ts # Keyword extraction
1962
503
  │ │ └── index.ts
1963
504
  │ ├── types/ # TypeScript definitions (2 files)
1964
- ├── types.ts # All type definitions (consolidated)
1965
- └── index.ts
1966
- │ └── utils/ # Shared utilities (12 files)
1967
- │ ├── schemas.ts # Zod validation (14 schemas)
1968
- │ ├── constants.ts # Shared constants (SIMILARITY_WEIGHTS)
1969
- │ ├── errors.ts # Custom error types
1970
- │ ├── searchAlgorithms.ts # Levenshtein + TF-IDF (consolidated)
1971
- │ ├── entityUtils.ts # Entity/tag/date/filter/path utilities
1972
- │ ├── formatters.ts # Response formatting + pagination
1973
- │ ├── indexes.ts # NameIndex, TypeIndex, RelationIndex
1974
- │ ├── compressionUtil.ts # Brotli compression utilities
1975
- │ ├── compressedCache.ts # LRU cache with compression
1976
- │ ├── logger.ts # Logging utilities
1977
- │ ├── searchCache.ts # Search result caching
1978
- │ └── index.ts
1979
- ├── tests/ # Test suite (2493 tests, 72 files)
505
+ │ ├── utils/ # Shared utilities (15 files)
506
+ │ └── workers/ # Worker pool (2 files)
507
+ ├── tests/ # Test suite (74 files, 2535 tests)
1980
508
  │ ├── unit/ # Unit tests
1981
509
  │ ├── integration/ # Integration tests
1982
510
  │ ├── e2e/ # End-to-end tests
1983
- │ └── performance/ # Performance benchmarks
511
+ │ └── performance/ # Benchmarks
1984
512
  ├── dist/ # Compiled output
1985
513
  ├── docs/ # Documentation
1986
514
  │ ├── architecture/ # Architecture docs
1987
515
  │ ├── guides/ # User guides
1988
- │ └── README.md
1989
- ├── tools/ # Development tools
1990
- │ ├── chunking-for-files/ # File splitting for context limits
1991
- │ ├── compress-for-context/ # CTON compression for LLMs
516
+ │ └── reports/ # Sprint reports
517
+ ├── tools/ # Standalone utilities
518
+ │ ├── chunking-for-files/ # File splitting
519
+ │ ├── compress-for-context/ # CTON compression
1992
520
  │ ├── create-dependency-graph/ # Dependency analyzer
1993
- │ └── migrate-from-jsonl-to-sqlite/ # Storage format migration
1994
- ├── vitest.config.ts # Test configuration
1995
- ├── tsconfig.json # TypeScript configuration
521
+ │ └── migrate-from-jsonl-to-sqlite/
1996
522
  ├── CHANGELOG.md # Version history
1997
523
  └── README.md # This file
1998
524
  ```
1999
525
 
2000
- ### Scripts
526
+ ### Dependencies
2001
527
 
2002
- ```bash
2003
- npm run build # Build TypeScript to JavaScript
2004
- npm run watch # Watch mode for development
2005
- npm test # Run 2493 tests with coverage
2006
- npm run typecheck # TypeScript strict type checking
2007
- npm run clean # Clean dist/ directories
2008
- npm run docs:deps # Generate dependency graph
2009
- ```
528
+ **Production:**
529
+ - `@modelcontextprotocol/sdk`: ^1.21.1
530
+ - `better-sqlite3`: ^11.7.0
531
+ - `zod`: ^4.1.13
532
+ - `async-mutex`: ^0.5.0
533
+ - `@danielsimonjr/workerpool`: ^10.0.1
534
+
535
+ **Development:**
536
+ - `typescript`: ^5.6.2
537
+ - `vitest`: ^4.0.13
538
+ - `@vitest/coverage-v8`: ^4.0.13
539
+ - `@types/better-sqlite3`: ^7.6.12
540
+
541
+ ## Documentation
542
+
543
+ Comprehensive documentation in `docs/`:
544
+
545
+ **Architecture**
546
+ - [API.md](docs/architecture/API.md) - Complete API documentation for all 59 tools
547
+ - [ARCHITECTURE.md](docs/architecture/ARCHITECTURE.md) - Technical architecture and system design
548
+ - [COMPONENTS.md](docs/architecture/COMPONENTS.md) - Component breakdown and responsibilities
549
+ - [OVERVIEW.md](docs/architecture/OVERVIEW.md) - High-level project overview
550
+ - [DEPENDENCY_GRAPH.md](docs/architecture/DEPENDENCY_GRAPH.md) - Module dependencies
551
+
552
+ **User Guides**
553
+ - [HIERARCHY.md](docs/guides/HIERARCHY.md) - Parent-child relationships (9 tools)
554
+ - [COMPRESSION.md](docs/guides/COMPRESSION.md) - Duplicate detection and merging
555
+ - [ARCHIVING.md](docs/guides/ARCHIVING.md) - Memory lifecycle and archiving
556
+ - [QUERY_LANGUAGE.md](docs/guides/QUERY_LANGUAGE.md) - Boolean search syntax
557
+
558
+ **Development**
559
+ - [WORKFLOW.md](docs/development/WORKFLOW.md) - Development procedures
560
+ - [MIGRATION.md](docs/guides/MIGRATION.md) - Version upgrade guide
2010
561
 
2011
562
  ## Contributing
2012
563
 
@@ -2014,76 +565,56 @@ We welcome contributions!
2014
565
 
2015
566
  **See:**
2016
567
  - [CONTRIBUTING.md](CONTRIBUTING.md) - Contribution guidelines
2017
- - [IMPROVEMENT_PLAN.md](IMPROVEMENT_PLAN.md) - Feature roadmap
2018
568
  - [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) - Community standards
2019
569
 
2020
570
  **Ways to Help:**
2021
- - 🐛 Report bugs
2022
- - Request features
2023
- - 🔧 Submit pull requests
2024
- - 📚 Improve documentation
2025
- - 🧪 Add tests
2026
- - 🌍 Translate guides
571
+ - Report bugs
572
+ - Request features
573
+ - Submit pull requests
574
+ - Improve documentation
575
+ - Add tests
2027
576
 
2028
577
  ## Changelog
2029
578
 
2030
- All notable changes to this project are documented in **[CHANGELOG.md](CHANGELOG.md)**.
579
+ All notable changes are documented in **[CHANGELOG.md](CHANGELOG.md)**.
2031
580
 
2032
- The changelog follows [Keep a Changelog](https://keepachangelog.com/) format and tracks:
2033
- - **Added**: New features and capabilities
2034
- - **Changed**: Changes to existing functionality
2035
- - **Deprecated**: Soon-to-be removed features
2036
- - **Removed**: Removed features
2037
- - **Fixed**: Bug fixes
2038
- - **Security**: Security improvements
581
+ **Current version**: v9.8.3 - [View full changelog](CHANGELOG.md)
2039
582
 
2040
- **Current version**: v9.0.0 - [View full changelog →](CHANGELOG.md)
583
+ Recent highlights:
584
+ - **v9.8.3**: SQLite storage support fix, JSON-RPC communication fix
585
+ - **v9.8.2**: Security hardening (22 vulnerabilities fixed)
586
+ - **v9.8.1**: Architecture documentation overhaul
2041
587
 
2042
588
  ## License
2043
589
 
2044
590
  **MIT License** - see [LICENSE](LICENSE)
2045
591
 
2046
- You are free to use, modify, and distribute this software.
2047
-
2048
592
  ## Acknowledgments
2049
593
 
2050
594
  ### Original Project
2051
595
 
2052
596
  Enhanced fork of [Model Context Protocol memory server](https://github.com/modelcontextprotocol/servers) by [Anthropic](https://www.anthropic.com/).
2053
597
 
2054
- **Original License:** MIT
598
+ ### Developer
2055
599
 
2056
- ### Enhancements
600
+ **[Daniel Simon Jr.](https://github.com/danielsimonjr)**
2057
601
 
2058
- **Developer:** [Daniel Simon Jr.](https://github.com/danielsimonjr)
602
+ ### Major Enhancements
2059
603
 
2060
- **Major Features Added:**
2061
604
  - Hierarchical nesting with parent-child relationships
2062
605
  - Graph algorithms: path finding, centrality, connected components
2063
- - Semantic search with embedding-based similarity (OpenAI/local models)
606
+ - Semantic search with embedding-based similarity
2064
607
  - Brotli compression for backups, exports, and responses
2065
608
  - Memory compression with intelligent duplicate detection
2066
609
  - Smart archiving with criteria-based filtering
2067
610
  - Advanced search: TF-IDF, boolean, and fuzzy matching
2068
- - Multi-format import/export with merge strategies and compression
2069
- - Enhanced tag management with aliases and bulk operations
2070
- - Saved searches with usage tracking
2071
- - Graph validation and integrity checks
611
+ - Multi-format import/export with merge strategies
612
+ - SQLite backend with better-sqlite3 (3-10x faster)
2072
613
  - Transaction support with ACID guarantees
2073
- - Backup and restore capabilities with compression
2074
- - Input validation and security hardening
2075
- - Performance optimizations and multi-level caching
2076
- - Comprehensive documentation and guides
2077
-
2078
- ### Community
2079
-
2080
- Thanks to:
2081
- - [MCP Specification](https://modelcontextprotocol.io)
2082
- - MCP community and contributors
2083
- - **Technologies:** Vitest, TypeScript, Node.js, better-sqlite3
614
+ - Comprehensive test suite (2535 tests, 96.6% coverage)
2084
615
 
2085
616
  ---
2086
617
 
2087
618
  **Repository:** https://github.com/danielsimonjr/memory-mcp
2088
- **Issues:** https://github.com/danielsimonjr/memory-mcp/issues
2089
619
  **NPM:** https://www.npmjs.com/package/@danielsimonjr/memory-mcp
620
+ **Issues:** https://github.com/danielsimonjr/memory-mcp/issues