@danielsimonjr/memory-mcp 0.47.1 → 9.8.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/LICENSE +22 -0
- package/README.md +2000 -194
- package/dist/__tests__/file-path.test.js +5 -5
- package/dist/__tests__/knowledge-graph.test.js +3 -8
- package/dist/core/EntityManager.d.ts +266 -0
- package/dist/core/EntityManager.d.ts.map +1 -0
- package/dist/core/EntityManager.js +85 -133
- package/dist/core/GraphEventEmitter.d.ts +202 -0
- package/dist/core/GraphEventEmitter.d.ts.map +1 -0
- package/dist/core/GraphEventEmitter.js +346 -0
- package/dist/core/GraphStorage.d.ts +395 -0
- package/dist/core/GraphStorage.d.ts.map +1 -0
- package/dist/core/GraphStorage.js +643 -31
- package/dist/core/GraphTraversal.d.ts +141 -0
- package/dist/core/GraphTraversal.d.ts.map +1 -0
- package/dist/core/GraphTraversal.js +573 -0
- package/dist/core/HierarchyManager.d.ts +111 -0
- package/dist/core/HierarchyManager.d.ts.map +1 -0
- package/dist/{features → core}/HierarchyManager.js +14 -9
- package/dist/core/ManagerContext.d.ts +72 -0
- package/dist/core/ManagerContext.d.ts.map +1 -0
- package/dist/core/ManagerContext.js +118 -0
- package/dist/core/ObservationManager.d.ts +85 -0
- package/dist/core/ObservationManager.d.ts.map +1 -0
- package/dist/core/ObservationManager.js +51 -57
- package/dist/core/RelationManager.d.ts +131 -0
- package/dist/core/RelationManager.d.ts.map +1 -0
- package/dist/core/RelationManager.js +31 -7
- package/dist/core/SQLiteStorage.d.ts +354 -0
- package/dist/core/SQLiteStorage.d.ts.map +1 -0
- package/dist/core/SQLiteStorage.js +917 -0
- package/dist/core/StorageFactory.d.ts +45 -0
- package/dist/core/StorageFactory.d.ts.map +1 -0
- package/dist/core/StorageFactory.js +64 -0
- package/dist/core/TransactionManager.d.ts +464 -0
- package/dist/core/TransactionManager.d.ts.map +1 -0
- package/dist/core/TransactionManager.js +490 -13
- package/dist/core/index.d.ts +17 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +12 -2
- package/dist/features/AnalyticsManager.d.ts +44 -0
- package/dist/features/AnalyticsManager.d.ts.map +1 -0
- package/dist/features/AnalyticsManager.js +14 -13
- package/dist/features/ArchiveManager.d.ts +133 -0
- package/dist/features/ArchiveManager.d.ts.map +1 -0
- package/dist/features/ArchiveManager.js +221 -14
- package/dist/features/CompressionManager.d.ts +117 -0
- package/dist/features/CompressionManager.d.ts.map +1 -0
- package/dist/features/CompressionManager.js +189 -20
- package/dist/features/IOManager.d.ts +225 -0
- package/dist/features/IOManager.d.ts.map +1 -0
- package/dist/features/IOManager.js +1041 -0
- package/dist/features/StreamingExporter.d.ts +123 -0
- package/dist/features/StreamingExporter.d.ts.map +1 -0
- package/dist/features/StreamingExporter.js +203 -0
- package/dist/features/TagManager.d.ts +147 -0
- package/dist/features/TagManager.d.ts.map +1 -0
- package/dist/features/index.d.ts +12 -0
- package/dist/features/index.d.ts.map +1 -0
- package/dist/features/index.js +5 -6
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -45
- package/dist/memory.jsonl +1 -18
- package/dist/search/BasicSearch.d.ts +51 -0
- package/dist/search/BasicSearch.d.ts.map +1 -0
- package/dist/search/BasicSearch.js +9 -3
- package/dist/search/BooleanSearch.d.ts +98 -0
- package/dist/search/BooleanSearch.d.ts.map +1 -0
- package/dist/search/BooleanSearch.js +156 -9
- package/dist/search/EmbeddingService.d.ts +178 -0
- package/dist/search/EmbeddingService.d.ts.map +1 -0
- package/dist/search/EmbeddingService.js +358 -0
- package/dist/search/FuzzySearch.d.ts +118 -0
- package/dist/search/FuzzySearch.d.ts.map +1 -0
- package/dist/search/FuzzySearch.js +241 -25
- package/dist/search/QueryCostEstimator.d.ts +111 -0
- package/dist/search/QueryCostEstimator.d.ts.map +1 -0
- package/dist/search/QueryCostEstimator.js +355 -0
- package/dist/search/RankedSearch.d.ts +71 -0
- package/dist/search/RankedSearch.d.ts.map +1 -0
- package/dist/search/RankedSearch.js +54 -6
- package/dist/search/SavedSearchManager.d.ts +79 -0
- package/dist/search/SavedSearchManager.d.ts.map +1 -0
- package/dist/search/SearchFilterChain.d.ts +120 -0
- package/dist/search/SearchFilterChain.d.ts.map +1 -0
- package/dist/search/SearchFilterChain.js +2 -4
- package/dist/search/SearchManager.d.ts +326 -0
- package/dist/search/SearchManager.d.ts.map +1 -0
- package/dist/search/SearchManager.js +148 -0
- package/dist/search/SearchSuggestions.d.ts +27 -0
- package/dist/search/SearchSuggestions.d.ts.map +1 -0
- package/dist/search/SearchSuggestions.js +1 -1
- package/dist/search/SemanticSearch.d.ts +149 -0
- package/dist/search/SemanticSearch.d.ts.map +1 -0
- package/dist/search/SemanticSearch.js +323 -0
- package/dist/search/TFIDFEventSync.d.ts +85 -0
- package/dist/search/TFIDFEventSync.d.ts.map +1 -0
- package/dist/search/TFIDFEventSync.js +133 -0
- package/dist/search/TFIDFIndexManager.d.ts +151 -0
- package/dist/search/TFIDFIndexManager.d.ts.map +1 -0
- package/dist/search/TFIDFIndexManager.js +232 -17
- package/dist/search/VectorStore.d.ts +235 -0
- package/dist/search/VectorStore.d.ts.map +1 -0
- package/dist/search/VectorStore.js +311 -0
- package/dist/search/index.d.ts +21 -0
- package/dist/search/index.d.ts.map +1 -0
- package/dist/search/index.js +12 -0
- package/dist/server/MCPServer.d.ts +21 -0
- package/dist/server/MCPServer.d.ts.map +1 -0
- package/dist/server/MCPServer.js +4 -4
- package/dist/server/responseCompressor.d.ts +94 -0
- package/dist/server/responseCompressor.d.ts.map +1 -0
- package/dist/server/responseCompressor.js +127 -0
- package/dist/server/toolDefinitions.d.ts +27 -0
- package/dist/server/toolDefinitions.d.ts.map +1 -0
- package/dist/server/toolDefinitions.js +189 -18
- package/dist/server/toolHandlers.d.ts +41 -0
- package/dist/server/toolHandlers.d.ts.map +1 -0
- package/dist/server/toolHandlers.js +467 -75
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -1
- package/dist/types/types.d.ts +1654 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +9 -0
- package/dist/utils/compressedCache.d.ts +192 -0
- package/dist/utils/compressedCache.d.ts.map +1 -0
- package/dist/utils/compressedCache.js +309 -0
- package/dist/utils/compressionUtil.d.ts +214 -0
- package/dist/utils/compressionUtil.d.ts.map +1 -0
- package/dist/utils/compressionUtil.js +247 -0
- package/dist/utils/constants.d.ts +245 -0
- package/dist/utils/constants.d.ts.map +1 -0
- package/dist/utils/constants.js +124 -0
- package/dist/utils/entityUtils.d.ts +321 -0
- package/dist/utils/entityUtils.d.ts.map +1 -0
- package/dist/utils/entityUtils.js +434 -4
- package/dist/utils/errors.d.ts +95 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +24 -0
- package/dist/utils/formatters.d.ts +145 -0
- package/dist/utils/formatters.d.ts.map +1 -0
- package/dist/utils/{paginationUtils.js → formatters.js} +54 -3
- package/dist/utils/index.d.ts +23 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +69 -31
- package/dist/utils/indexes.d.ts +270 -0
- package/dist/utils/indexes.d.ts.map +1 -0
- package/dist/utils/indexes.js +526 -0
- package/dist/utils/logger.d.ts +24 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/operationUtils.d.ts +124 -0
- package/dist/utils/operationUtils.d.ts.map +1 -0
- package/dist/utils/operationUtils.js +175 -0
- package/dist/utils/parallelUtils.d.ts +72 -0
- package/dist/utils/parallelUtils.d.ts.map +1 -0
- package/dist/utils/parallelUtils.js +169 -0
- package/dist/utils/schemas.d.ts +374 -0
- package/dist/utils/schemas.d.ts.map +1 -0
- package/dist/utils/schemas.js +302 -2
- package/dist/utils/searchAlgorithms.d.ts +99 -0
- package/dist/utils/searchAlgorithms.d.ts.map +1 -0
- package/dist/utils/searchAlgorithms.js +167 -0
- package/dist/utils/searchCache.d.ts +108 -0
- package/dist/utils/searchCache.d.ts.map +1 -0
- package/dist/utils/taskScheduler.d.ts +290 -0
- package/dist/utils/taskScheduler.d.ts.map +1 -0
- package/dist/utils/taskScheduler.js +466 -0
- package/dist/workers/index.d.ts +12 -0
- package/dist/workers/index.d.ts.map +1 -0
- package/dist/workers/index.js +9 -0
- package/dist/workers/levenshteinWorker.d.ts +60 -0
- package/dist/workers/levenshteinWorker.d.ts.map +1 -0
- package/dist/workers/levenshteinWorker.js +98 -0
- package/package.json +17 -4
- package/dist/__tests__/edge-cases/edge-cases.test.js +0 -406
- package/dist/__tests__/integration/workflows.test.js +0 -449
- package/dist/__tests__/performance/benchmarks.test.js +0 -413
- package/dist/__tests__/unit/core/EntityManager.test.js +0 -334
- package/dist/__tests__/unit/core/GraphStorage.test.js +0 -205
- package/dist/__tests__/unit/core/RelationManager.test.js +0 -274
- package/dist/__tests__/unit/features/CompressionManager.test.js +0 -350
- package/dist/__tests__/unit/search/BasicSearch.test.js +0 -311
- package/dist/__tests__/unit/search/BooleanSearch.test.js +0 -432
- package/dist/__tests__/unit/search/FuzzySearch.test.js +0 -448
- package/dist/__tests__/unit/search/RankedSearch.test.js +0 -379
- package/dist/__tests__/unit/utils/levenshtein.test.js +0 -77
- package/dist/core/KnowledgeGraphManager.js +0 -423
- package/dist/features/BackupManager.js +0 -311
- package/dist/features/ExportManager.js +0 -305
- package/dist/features/ImportExportManager.js +0 -50
- package/dist/features/ImportManager.js +0 -328
- package/dist/types/analytics.types.js +0 -6
- package/dist/types/entity.types.js +0 -7
- package/dist/types/import-export.types.js +0 -7
- package/dist/types/search.types.js +0 -7
- package/dist/types/tag.types.js +0 -6
- package/dist/utils/dateUtils.js +0 -89
- package/dist/utils/filterUtils.js +0 -155
- package/dist/utils/levenshtein.js +0 -62
- package/dist/utils/pathUtils.js +0 -115
- package/dist/utils/responseFormatter.js +0 -55
- package/dist/utils/tagUtils.js +0 -107
- package/dist/utils/tfidf.js +0 -90
- package/dist/utils/validationHelper.js +0 -99
- package/dist/utils/validationUtils.js +0 -109
package/README.md
CHANGED
|
@@ -1,283 +1,2089 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Memory MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://github.com/danielsimonjr/memory-mcp)
|
|
4
|
+
[](https://www.npmjs.com/package/@danielsimonjr/memory-mcp)
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://modelcontextprotocol.io)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](CHANGELOG.md)
|
|
9
|
+
|
|
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
|
+
|
|
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.
|
|
13
|
+
|
|
14
|
+
## Table of Contents
|
|
15
|
+
|
|
16
|
+
- [Features](#features)
|
|
17
|
+
- [Quick Start](#quick-start)
|
|
18
|
+
- [Installation](#installation)
|
|
19
|
+
- [Core Concepts](#core-concepts)
|
|
20
|
+
- [API Reference](#api-reference)
|
|
21
|
+
- [Data Model](#data-model)
|
|
22
|
+
- [Usage Examples](#usage-examples)
|
|
23
|
+
- [Documentation](#documentation)
|
|
24
|
+
- [Configuration](#configuration)
|
|
25
|
+
- [Development](#development)
|
|
26
|
+
- [Contributing](#contributing)
|
|
27
|
+
- [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
|
+
```
|
|
4
230
|
|
|
5
231
|
## Core Concepts
|
|
6
232
|
|
|
7
|
-
### Entities
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
```
|
|
12
1302
|
|
|
13
|
-
Example
|
|
1303
|
+
**Example:**
|
|
14
1304
|
```json
|
|
15
1305
|
{
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"observations": ["Speaks fluent Spanish"]
|
|
1306
|
+
"from": "Alice",
|
|
1307
|
+
"to": "Charlie"
|
|
19
1308
|
}
|
|
20
1309
|
```
|
|
1310
|
+
</details>
|
|
21
1311
|
|
|
22
|
-
|
|
23
|
-
|
|
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
|
+
```
|
|
24
1338
|
|
|
25
|
-
Example
|
|
1339
|
+
**Example:**
|
|
26
1340
|
```json
|
|
27
1341
|
{
|
|
28
|
-
"from": "
|
|
29
|
-
"to": "
|
|
30
|
-
"
|
|
1342
|
+
"from": "Alice",
|
|
1343
|
+
"to": "Charlie",
|
|
1344
|
+
"maxDepth": 3
|
|
31
1345
|
}
|
|
32
1346
|
```
|
|
33
|
-
|
|
34
|
-
|
|
1347
|
+
</details>
|
|
1348
|
+
|
|
1349
|
+
<details>
|
|
1350
|
+
<summary><b>Graph Algorithms: get_connected_components</b></summary>
|
|
1351
|
+
|
|
1352
|
+
Detect isolated subgraphs and analyze connectivity.
|
|
1353
|
+
|
|
1354
|
+
**Input:**
|
|
1355
|
+
```typescript
|
|
1356
|
+
{
|
|
1357
|
+
directed?: boolean; // Consider direction (default: false)
|
|
1358
|
+
}
|
|
1359
|
+
```
|
|
1360
|
+
|
|
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>
|
|
1375
|
+
|
|
1376
|
+
<details>
|
|
1377
|
+
<summary><b>Graph Algorithms: get_centrality</b></summary>
|
|
35
1378
|
|
|
36
|
-
|
|
37
|
-
- Attached to specific entities
|
|
38
|
-
- Can be added or removed independently
|
|
39
|
-
- Should be atomic (one fact per observation)
|
|
1379
|
+
Calculate centrality metrics to identify important nodes.
|
|
40
1380
|
|
|
41
|
-
|
|
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
|
+
```
|
|
1389
|
+
|
|
1390
|
+
**Returns:**
|
|
1391
|
+
```typescript
|
|
1392
|
+
Array<{
|
|
1393
|
+
entity: string;
|
|
1394
|
+
score: number;
|
|
1395
|
+
rank: number;
|
|
1396
|
+
}>
|
|
1397
|
+
```
|
|
1398
|
+
|
|
1399
|
+
**Metrics:**
|
|
1400
|
+
- **degree**: Count of connections (hub identification)
|
|
1401
|
+
- **betweenness**: Bridge nodes connecting subgraphs
|
|
1402
|
+
- **pagerank**: Influence based on connections to influential nodes
|
|
1403
|
+
|
|
1404
|
+
**Example:**
|
|
42
1405
|
```json
|
|
43
1406
|
{
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"Speaks fluent Spanish",
|
|
47
|
-
"Graduated in 2019",
|
|
48
|
-
"Prefers morning meetings"
|
|
49
|
-
]
|
|
1407
|
+
"metric": "pagerank",
|
|
1408
|
+
"limit": 5
|
|
50
1409
|
}
|
|
51
1410
|
```
|
|
1411
|
+
</details>
|
|
52
1412
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
- Input: `observations` (array of objects)
|
|
77
|
-
- Each object contains:
|
|
78
|
-
- `entityName` (string): Target entity
|
|
79
|
-
- `contents` (string[]): New observations to add
|
|
80
|
-
- Returns added observations per entity
|
|
81
|
-
- Fails if entity doesn't exist
|
|
82
|
-
|
|
83
|
-
- **delete_entities**
|
|
84
|
-
- Remove entities and their relations
|
|
85
|
-
- Input: `entityNames` (string[])
|
|
86
|
-
- Cascading deletion of associated relations
|
|
87
|
-
- Silent operation if entity doesn't exist
|
|
88
|
-
|
|
89
|
-
- **delete_observations**
|
|
90
|
-
- Remove specific observations from entities
|
|
91
|
-
- Input: `deletions` (array of objects)
|
|
92
|
-
- Each object contains:
|
|
93
|
-
- `entityName` (string): Target entity
|
|
94
|
-
- `observations` (string[]): Observations to remove
|
|
95
|
-
- Silent operation if observation doesn't exist
|
|
96
|
-
|
|
97
|
-
- **delete_relations**
|
|
98
|
-
- Remove specific relations from the graph
|
|
99
|
-
- Input: `relations` (array of objects)
|
|
100
|
-
- Each object contains:
|
|
101
|
-
- `from` (string): Source entity name
|
|
102
|
-
- `to` (string): Target entity name
|
|
103
|
-
- `relationType` (string): Relationship type
|
|
104
|
-
- Silent operation if relation doesn't exist
|
|
105
|
-
|
|
106
|
-
- **read_graph**
|
|
107
|
-
- Read the entire knowledge graph
|
|
108
|
-
- No input required
|
|
109
|
-
- Returns complete graph structure with all entities and relations
|
|
110
|
-
|
|
111
|
-
- **search_nodes**
|
|
112
|
-
- Search for nodes based on query
|
|
113
|
-
- Input: `query` (string)
|
|
114
|
-
- Searches across:
|
|
115
|
-
- Entity names
|
|
116
|
-
- Entity types
|
|
117
|
-
- Observation content
|
|
118
|
-
- Returns matching entities and their relations
|
|
119
|
-
|
|
120
|
-
- **open_nodes**
|
|
121
|
-
- Retrieve specific nodes by name
|
|
122
|
-
- Input: `names` (string[])
|
|
123
|
-
- Returns:
|
|
124
|
-
- Requested entities
|
|
125
|
-
- Relations between requested entities
|
|
126
|
-
- Silently skips non-existent nodes
|
|
127
|
-
|
|
128
|
-
# Usage with Claude Desktop
|
|
129
|
-
|
|
130
|
-
### Setup
|
|
131
|
-
|
|
132
|
-
Add this to your claude_desktop_config.json:
|
|
133
|
-
|
|
134
|
-
#### Docker
|
|
1413
|
+
---
|
|
1414
|
+
|
|
1415
|
+
<details>
|
|
1416
|
+
<summary><b>Semantic Search: semantic_search</b></summary>
|
|
1417
|
+
|
|
1418
|
+
Search using semantic similarity with embeddings.
|
|
1419
|
+
|
|
1420
|
+
**Input:**
|
|
1421
|
+
```typescript
|
|
1422
|
+
{
|
|
1423
|
+
query: string; // Natural language query
|
|
1424
|
+
limit?: number; // Max results (default: 10)
|
|
1425
|
+
threshold?: number; // Min similarity 0-1 (default: 0.5)
|
|
1426
|
+
}
|
|
1427
|
+
```
|
|
1428
|
+
|
|
1429
|
+
**Returns:**
|
|
1430
|
+
```typescript
|
|
1431
|
+
Array<{
|
|
1432
|
+
entity: Entity;
|
|
1433
|
+
similarity: number; // 0-1 cosine similarity
|
|
1434
|
+
}>
|
|
1435
|
+
```
|
|
135
1436
|
|
|
1437
|
+
**Example:**
|
|
136
1438
|
```json
|
|
137
1439
|
{
|
|
138
|
-
"
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
1440
|
+
"query": "machine learning projects",
|
|
1441
|
+
"limit": 5,
|
|
1442
|
+
"threshold": 0.7
|
|
1443
|
+
}
|
|
1444
|
+
```
|
|
1445
|
+
|
|
1446
|
+
**Note:** Requires embedding provider configuration. See [Configuration](#configuration).
|
|
1447
|
+
</details>
|
|
1448
|
+
|
|
1449
|
+
<details>
|
|
1450
|
+
<summary><b>Semantic Search: find_similar_entities</b></summary>
|
|
1451
|
+
|
|
1452
|
+
Find entities semantically similar to a reference entity.
|
|
1453
|
+
|
|
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)
|
|
144
1460
|
}
|
|
145
1461
|
```
|
|
146
1462
|
|
|
147
|
-
|
|
1463
|
+
**Returns:**
|
|
1464
|
+
```typescript
|
|
1465
|
+
Array<{
|
|
1466
|
+
entity: Entity;
|
|
1467
|
+
similarity: number;
|
|
1468
|
+
}>
|
|
1469
|
+
```
|
|
1470
|
+
|
|
1471
|
+
**Example:**
|
|
148
1472
|
```json
|
|
149
1473
|
{
|
|
150
|
-
"
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
1474
|
+
"entityName": "Project_Alpha",
|
|
1475
|
+
"limit": 5
|
|
1476
|
+
}
|
|
1477
|
+
```
|
|
1478
|
+
</details>
|
|
1479
|
+
|
|
1480
|
+
<details>
|
|
1481
|
+
<summary><b>Semantic Search: index_embeddings</b></summary>
|
|
1482
|
+
|
|
1483
|
+
Build or rebuild the semantic search index.
|
|
1484
|
+
|
|
1485
|
+
**Input:**
|
|
1486
|
+
```typescript
|
|
1487
|
+
{
|
|
1488
|
+
force?: boolean; // Rebuild even if index exists (default: false)
|
|
1489
|
+
}
|
|
1490
|
+
```
|
|
1491
|
+
|
|
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
|
+
```
|
|
1500
|
+
|
|
1501
|
+
**Note:** Required before using semantic_search if auto-indexing is disabled.
|
|
1502
|
+
</details>
|
|
1503
|
+
|
|
1504
|
+
---
|
|
1505
|
+
|
|
1506
|
+
<details>
|
|
1507
|
+
<summary><b>Export: export_graph</b></summary>
|
|
1508
|
+
|
|
1509
|
+
Export knowledge graph in multiple formats with optional compression.
|
|
1510
|
+
|
|
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
|
+
```
|
|
1525
|
+
|
|
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
|
+
```json
|
|
1542
|
+
{
|
|
1543
|
+
"format": "json",
|
|
1544
|
+
"compress": true,
|
|
1545
|
+
"compressionQuality": 9
|
|
1546
|
+
}
|
|
1547
|
+
```
|
|
1548
|
+
</details>
|
|
1549
|
+
|
|
1550
|
+
<details>
|
|
1551
|
+
<summary><b>Import: import_graph</b></summary>
|
|
1552
|
+
|
|
1553
|
+
Import knowledge graph from JSON, CSV, or GraphML.
|
|
1554
|
+
|
|
1555
|
+
**Input:**
|
|
1556
|
+
```typescript
|
|
1557
|
+
{
|
|
1558
|
+
format: "json" | "csv" | "graphml";
|
|
1559
|
+
data: string;
|
|
1560
|
+
strategy?: "replace" | "skip" | "merge" | "fail"; // Default "merge"
|
|
1561
|
+
dryRun?: boolean; // Default false
|
|
1562
|
+
}
|
|
1563
|
+
```
|
|
1564
|
+
|
|
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>
|
|
1582
|
+
|
|
1583
|
+
## Data Model
|
|
1584
|
+
|
|
1585
|
+
### Entity Schema
|
|
1586
|
+
|
|
1587
|
+
```typescript
|
|
1588
|
+
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
|
|
1597
|
+
}
|
|
1598
|
+
```
|
|
1599
|
+
|
|
1600
|
+
### Relation Schema
|
|
1601
|
+
|
|
1602
|
+
```typescript
|
|
1603
|
+
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
|
+
]
|
|
159
1637
|
}
|
|
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
|
+
```
|
|
1664
|
+
|
|
1665
|
+
### Example 3: Smart Archiving
|
|
1666
|
+
|
|
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
|
+
```
|
|
1675
|
+
|
|
1676
|
+
### Example 4: Advanced Search
|
|
1677
|
+
|
|
1678
|
+
```json
|
|
1679
|
+
// Boolean search
|
|
1680
|
+
{ "query": "type:project AND (frontend OR backend) NOT deprecated" }
|
|
1681
|
+
|
|
1682
|
+
// TF-IDF ranking
|
|
1683
|
+
{ "query": "machine learning algorithms", "limit": 10 }
|
|
1684
|
+
|
|
1685
|
+
// Fuzzy search
|
|
1686
|
+
{ "query": "projekt", "threshold": 0.8 }
|
|
160
1687
|
```
|
|
161
1688
|
|
|
162
|
-
|
|
1689
|
+
### Example 5: Tag Management
|
|
163
1690
|
|
|
164
|
-
|
|
1691
|
+
```json
|
|
1692
|
+
// Bulk tag operations
|
|
1693
|
+
{
|
|
1694
|
+
"entityNames": ["Entity1", "Entity2", "Entity3"],
|
|
1695
|
+
"tags": ["new-tag"]
|
|
1696
|
+
} // add_tags_to_multiple
|
|
1697
|
+
|
|
1698
|
+
// Tag aliases
|
|
1699
|
+
{ "alias": "ai", "canonical": "artificial-intelligence" } // add_tag_alias
|
|
1700
|
+
|
|
1701
|
+
// Merge tags
|
|
1702
|
+
{ "sourceTag": "ml", "targetTag": "machine-learning" } // merge_tags
|
|
1703
|
+
```
|
|
1704
|
+
|
|
1705
|
+
## Documentation
|
|
1706
|
+
|
|
1707
|
+
### 📚 **[Complete Documentation](docs/README.md)**
|
|
1708
|
+
|
|
1709
|
+
Comprehensive documentation organized by category:
|
|
1710
|
+
|
|
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
|
|
1716
|
+
|
|
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
|
|
1723
|
+
|
|
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
|
|
1728
|
+
|
|
1729
|
+
## Configuration
|
|
1730
|
+
|
|
1731
|
+
### Environment Variables
|
|
1732
|
+
|
|
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
|
|
1761
|
+
|
|
1762
|
+
### Storage Backends
|
|
1763
|
+
|
|
1764
|
+
| Feature | JSONL (Default) | SQLite (better-sqlite3) |
|
|
1765
|
+
|---------|-----------------|-------------------------|
|
|
1766
|
+
| Format | Human-readable text | Native binary database |
|
|
1767
|
+
| Transactions | Basic | Full ACID with WAL mode |
|
|
1768
|
+
| Indexing | In-memory | B-tree + FTS5 full-text |
|
|
1769
|
+
| Full-Text Search | Basic | FTS5 with BM25 ranking |
|
|
1770
|
+
| Performance | Good | 3-10x faster |
|
|
1771
|
+
| Concurrency | Single-threaded | Thread-safe with async-mutex |
|
|
1772
|
+
| Best For | Small graphs, debugging | Large graphs (10k+ entities) |
|
|
1773
|
+
| File Extension | `.jsonl` | `.db`, `.sqlite` |
|
|
1774
|
+
|
|
1775
|
+
**Using SQLite Storage:**
|
|
165
1776
|
|
|
166
1777
|
```json
|
|
167
1778
|
{
|
|
168
1779
|
"mcpServers": {
|
|
169
1780
|
"memory": {
|
|
170
|
-
"command": "
|
|
171
|
-
"args": [
|
|
172
|
-
"-y",
|
|
173
|
-
"@modelcontextprotocol/server-memory"
|
|
174
|
-
],
|
|
1781
|
+
"command": "node",
|
|
1782
|
+
"args": ["/path/to/memory-mcp/dist/index.js"],
|
|
175
1783
|
"env": {
|
|
176
|
-
"
|
|
1784
|
+
"MEMORY_STORAGE_TYPE": "sqlite",
|
|
1785
|
+
"MEMORY_FILE_PATH": "/path/to/data/memory.db"
|
|
177
1786
|
}
|
|
178
1787
|
}
|
|
179
1788
|
}
|
|
180
1789
|
}
|
|
181
1790
|
```
|
|
182
1791
|
|
|
183
|
-
|
|
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
|
|
184
1804
|
|
|
185
|
-
#
|
|
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
|
|
186
1807
|
|
|
187
|
-
|
|
1808
|
+
# Or build standalone executable
|
|
1809
|
+
npm run build
|
|
1810
|
+
./migrate-from-jsonl-to-sqlite.exe --from memory.jsonl --to memory.db
|
|
1811
|
+
```
|
|
188
1812
|
|
|
189
|
-
[
|
|
1813
|
+
See [tools/migrate-from-jsonl-to-sqlite/README.md](tools/migrate-from-jsonl-to-sqlite/README.md) for complete documentation.
|
|
190
1814
|
|
|
191
|
-
|
|
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
|
|
192
1819
|
|
|
193
|
-
|
|
1820
|
+
### Storage File Organization
|
|
194
1821
|
|
|
195
|
-
|
|
196
|
-
Add the configuration to your user-level MCP configuration file. Open the Command Palette (`Ctrl + Shift + P`) and run `MCP: Open User Configuration`. This will open your user `mcp.json` file where you can add the server configuration.
|
|
1822
|
+
When you set `MEMORY_FILE_PATH`, the server automatically creates related files in the same directory:
|
|
197
1823
|
|
|
198
|
-
|
|
199
|
-
|
|
1824
|
+
```
|
|
1825
|
+
/your/data/directory/
|
|
1826
|
+
├── memory.jsonl # Main knowledge graph (active entities & relations)
|
|
1827
|
+
├── memory-saved-searches.jsonl # Saved search queries
|
|
1828
|
+
├── 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
|
+
└── ...
|
|
1833
|
+
```
|
|
200
1834
|
|
|
201
|
-
|
|
1835
|
+
**Note**: All auxiliary files use the same base filename as `MEMORY_FILE_PATH` with descriptive suffixes.
|
|
202
1836
|
|
|
203
|
-
|
|
1837
|
+
### Example Configuration
|
|
204
1838
|
|
|
1839
|
+
**Claude Desktop (`claude_desktop_config.json`):**
|
|
205
1840
|
```json
|
|
206
1841
|
{
|
|
207
|
-
"
|
|
1842
|
+
"mcpServers": {
|
|
208
1843
|
"memory": {
|
|
209
|
-
"command": "
|
|
210
|
-
"args": [
|
|
211
|
-
|
|
212
|
-
"
|
|
213
|
-
|
|
1844
|
+
"command": "node",
|
|
1845
|
+
"args": ["/path/to/memory-mcp/dist/index.js"],
|
|
1846
|
+
"env": {
|
|
1847
|
+
"MEMORY_FILE_PATH": "/path/to/data/memory.jsonl"
|
|
1848
|
+
}
|
|
214
1849
|
}
|
|
215
1850
|
}
|
|
216
1851
|
}
|
|
217
1852
|
```
|
|
218
1853
|
|
|
219
|
-
|
|
220
|
-
|
|
1854
|
+
**Default behavior (no environment variable):**
|
|
221
1855
|
```json
|
|
222
1856
|
{
|
|
223
|
-
"
|
|
1857
|
+
"mcpServers": {
|
|
224
1858
|
"memory": {
|
|
225
|
-
"command": "
|
|
226
|
-
"args": [
|
|
227
|
-
"run",
|
|
228
|
-
"-i",
|
|
229
|
-
"-v",
|
|
230
|
-
"claude-memory:/app/dist",
|
|
231
|
-
"--rm",
|
|
232
|
-
"mcp/memory"
|
|
233
|
-
]
|
|
1859
|
+
"command": "node",
|
|
1860
|
+
"args": ["/path/to/memory-mcp/dist/index.js"]
|
|
234
1861
|
}
|
|
235
1862
|
}
|
|
236
1863
|
}
|
|
237
1864
|
```
|
|
1865
|
+
Creates `memory.jsonl` in the current working directory.
|
|
1866
|
+
|
|
1867
|
+
## Development
|
|
238
1868
|
|
|
239
|
-
###
|
|
1869
|
+
### Prerequisites
|
|
240
1870
|
|
|
241
|
-
|
|
1871
|
+
- Node.js 18+
|
|
1872
|
+
- npm 9+
|
|
1873
|
+
- TypeScript 5.6+
|
|
242
1874
|
|
|
243
|
-
|
|
1875
|
+
### Build
|
|
244
1876
|
|
|
1877
|
+
```bash
|
|
1878
|
+
npm install
|
|
1879
|
+
npm run build # Production build
|
|
1880
|
+
npm run watch # Development watch mode
|
|
245
1881
|
```
|
|
246
|
-
Follow these steps for each interaction:
|
|
247
1882
|
|
|
248
|
-
|
|
249
|
-
- You should assume that you are interacting with default_user
|
|
250
|
-
- If you have not identified default_user, proactively try to do so.
|
|
1883
|
+
### Test
|
|
251
1884
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
1885
|
+
```bash
|
|
1886
|
+
npm test # Run test suite with coverage
|
|
1887
|
+
npm run typecheck # TypeScript type checking
|
|
1888
|
+
```
|
|
255
1889
|
|
|
256
|
-
|
|
257
|
-
- While conversing with the user, be attentive to any new information that falls into these categories:
|
|
258
|
-
a) Basic Identity (age, gender, location, job title, education level, etc.)
|
|
259
|
-
b) Behaviors (interests, habits, etc.)
|
|
260
|
-
c) Preferences (communication style, preferred language, etc.)
|
|
261
|
-
d) Goals (goals, targets, aspirations, etc.)
|
|
262
|
-
e) Relationships (personal and professional relationships up to 3 degrees of separation)
|
|
1890
|
+
### Architecture Overview
|
|
263
1891
|
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
1892
|
+
```
|
|
1893
|
+
┌─────────────────────────────────────────────────────┐
|
|
1894
|
+
│ Layer 1: MCP Protocol Layer │
|
|
1895
|
+
│ server/MCPServer.ts + toolDefinitions │
|
|
1896
|
+
│ + toolHandlers (55 tools) + responseCompressor │
|
|
1897
|
+
└──────────────────────┬──────────────────────────────┘
|
|
1898
|
+
│
|
|
1899
|
+
┌──────────────────────┴──────────────────────────────┐
|
|
1900
|
+
│ Layer 2: Managers + Context (Lazy Initialization) │
|
|
1901
|
+
│ ManagerContext (aliased as KnowledgeGraphManager) │
|
|
1902
|
+
│ • EntityManager (CRUD + hierarchy + archive) │
|
|
1903
|
+
│ • RelationManager (relation CRUD) │
|
|
1904
|
+
│ • SearchManager (search + compression + stats) │
|
|
1905
|
+
│ • IOManager (import + export + backup) │
|
|
1906
|
+
│ • TagManager (tag aliases) │
|
|
1907
|
+
│ • GraphTraversal (path finding, centrality) │
|
|
1908
|
+
│ • SemanticSearch (embeddings, similarity) │
|
|
1909
|
+
└──────────────────────┬──────────────────────────────┘
|
|
1910
|
+
│
|
|
1911
|
+
┌──────────────────────┴──────────────────────────────┐
|
|
1912
|
+
│ Layer 3: Storage Layer │
|
|
1913
|
+
│ core/GraphStorage.ts (JSONL + in-memory cache) │
|
|
1914
|
+
│ core/SQLiteStorage.ts (better-sqlite3 + FTS5) │
|
|
1915
|
+
│ core/StorageFactory.ts (backend selection) │
|
|
1916
|
+
└─────────────────────────────────────────────────────┘
|
|
269
1917
|
```
|
|
270
1918
|
|
|
271
|
-
|
|
1919
|
+
### Project Structure
|
|
1920
|
+
|
|
1921
|
+
```
|
|
1922
|
+
memory-mcp/
|
|
1923
|
+
├── src/ # Main source (58 TypeScript files)
|
|
1924
|
+
│ ├── index.ts # Entry point
|
|
1925
|
+
│ ├── core/ # Core managers (11 files)
|
|
1926
|
+
│ │ ├── ManagerContext.ts # Context holder (lazy init)
|
|
1927
|
+
│ │ ├── EntityManager.ts # Entity CRUD + hierarchy + archive
|
|
1928
|
+
│ │ ├── RelationManager.ts # Relation CRUD
|
|
1929
|
+
│ │ ├── GraphStorage.ts # JSONL I/O + caching
|
|
1930
|
+
│ │ ├── SQLiteStorage.ts # SQLite with better-sqlite3
|
|
1931
|
+
│ │ ├── TransactionManager.ts # ACID transactions
|
|
1932
|
+
│ │ ├── StorageFactory.ts # Storage backend factory
|
|
1933
|
+
│ │ ├── HierarchyManager.ts # Tree operations
|
|
1934
|
+
│ │ ├── 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
|
|
1940
|
+
│ │ ├── toolHandlers.ts # Handler registry
|
|
1941
|
+
│ │ └── responseCompressor.ts # Brotli response compression
|
|
1942
|
+
│ ├── search/ # Search implementations (13 files)
|
|
1943
|
+
│ │ ├── SearchManager.ts # Search orchestrator + compression + analytics
|
|
1944
|
+
│ │ ├── BasicSearch.ts # Text matching
|
|
1945
|
+
│ │ ├── RankedSearch.ts # TF-IDF scoring
|
|
1946
|
+
│ │ ├── BooleanSearch.ts # AND/OR/NOT logic
|
|
1947
|
+
│ │ ├── 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)
|
|
1958
|
+
│ │ ├── TagManager.ts # Tag aliases
|
|
1959
|
+
│ │ ├── AnalyticsManager.ts # Graph stats/validation
|
|
1960
|
+
│ │ ├── ArchiveManager.ts # Entity archival
|
|
1961
|
+
│ │ ├── CompressionManager.ts # Duplicate detection/merging
|
|
1962
|
+
│ │ └── index.ts
|
|
1963
|
+
│ ├── 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)
|
|
1980
|
+
│ ├── unit/ # Unit tests
|
|
1981
|
+
│ ├── integration/ # Integration tests
|
|
1982
|
+
│ ├── e2e/ # End-to-end tests
|
|
1983
|
+
│ └── performance/ # Performance benchmarks
|
|
1984
|
+
├── dist/ # Compiled output
|
|
1985
|
+
├── docs/ # Documentation
|
|
1986
|
+
│ ├── architecture/ # Architecture docs
|
|
1987
|
+
│ ├── 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
|
|
1992
|
+
│ ├── 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
|
|
1996
|
+
├── CHANGELOG.md # Version history
|
|
1997
|
+
└── README.md # This file
|
|
1998
|
+
```
|
|
272
1999
|
|
|
273
|
-
|
|
2000
|
+
### Scripts
|
|
274
2001
|
|
|
275
|
-
```
|
|
276
|
-
|
|
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
|
|
277
2009
|
```
|
|
278
2010
|
|
|
279
|
-
|
|
2011
|
+
## Contributing
|
|
2012
|
+
|
|
2013
|
+
We welcome contributions!
|
|
2014
|
+
|
|
2015
|
+
**See:**
|
|
2016
|
+
- [CONTRIBUTING.md](CONTRIBUTING.md) - Contribution guidelines
|
|
2017
|
+
- [IMPROVEMENT_PLAN.md](IMPROVEMENT_PLAN.md) - Feature roadmap
|
|
2018
|
+
- [CODE_OF_CONDUCT.md](CODE_OF_CONDUCT.md) - Community standards
|
|
2019
|
+
|
|
2020
|
+
**Ways to Help:**
|
|
2021
|
+
- 🐛 Report bugs
|
|
2022
|
+
- ✨ Request features
|
|
2023
|
+
- 🔧 Submit pull requests
|
|
2024
|
+
- 📚 Improve documentation
|
|
2025
|
+
- 🧪 Add tests
|
|
2026
|
+
- 🌍 Translate guides
|
|
2027
|
+
|
|
2028
|
+
## Changelog
|
|
2029
|
+
|
|
2030
|
+
All notable changes to this project are documented in **[CHANGELOG.md](CHANGELOG.md)**.
|
|
2031
|
+
|
|
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
|
|
2039
|
+
|
|
2040
|
+
**Current version**: v9.0.0 - [View full changelog →](CHANGELOG.md)
|
|
280
2041
|
|
|
281
2042
|
## License
|
|
282
2043
|
|
|
283
|
-
|
|
2044
|
+
**MIT License** - see [LICENSE](LICENSE)
|
|
2045
|
+
|
|
2046
|
+
You are free to use, modify, and distribute this software.
|
|
2047
|
+
|
|
2048
|
+
## Acknowledgments
|
|
2049
|
+
|
|
2050
|
+
### Original Project
|
|
2051
|
+
|
|
2052
|
+
Enhanced fork of [Model Context Protocol memory server](https://github.com/modelcontextprotocol/servers) by [Anthropic](https://www.anthropic.com/).
|
|
2053
|
+
|
|
2054
|
+
**Original License:** MIT
|
|
2055
|
+
|
|
2056
|
+
### Enhancements
|
|
2057
|
+
|
|
2058
|
+
**Developer:** [Daniel Simon Jr.](https://github.com/danielsimonjr)
|
|
2059
|
+
|
|
2060
|
+
**Major Features Added:**
|
|
2061
|
+
- Hierarchical nesting with parent-child relationships
|
|
2062
|
+
- Graph algorithms: path finding, centrality, connected components
|
|
2063
|
+
- Semantic search with embedding-based similarity (OpenAI/local models)
|
|
2064
|
+
- Brotli compression for backups, exports, and responses
|
|
2065
|
+
- Memory compression with intelligent duplicate detection
|
|
2066
|
+
- Smart archiving with criteria-based filtering
|
|
2067
|
+
- 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
|
|
2072
|
+
- 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
|
|
2084
|
+
|
|
2085
|
+
---
|
|
2086
|
+
|
|
2087
|
+
**Repository:** https://github.com/danielsimonjr/memory-mcp
|
|
2088
|
+
**Issues:** https://github.com/danielsimonjr/memory-mcp/issues
|
|
2089
|
+
**NPM:** https://www.npmjs.com/package/@danielsimonjr/memory-mcp
|