mcp-memory-keeper 0.10.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 (98) hide show
  1. package/CHANGELOG.md +433 -0
  2. package/LICENSE +21 -0
  3. package/README.md +1051 -0
  4. package/bin/mcp-memory-keeper +52 -0
  5. package/dist/__tests__/helpers/database-test-helper.js +160 -0
  6. package/dist/__tests__/helpers/test-server.js +92 -0
  7. package/dist/__tests__/integration/advanced-features.test.js +614 -0
  8. package/dist/__tests__/integration/backward-compatibility.test.js +245 -0
  9. package/dist/__tests__/integration/batchOperationsE2E.test.js +396 -0
  10. package/dist/__tests__/integration/batchOperationsHandler.test.js +1230 -0
  11. package/dist/__tests__/integration/channelManagementHandler.test.js +1291 -0
  12. package/dist/__tests__/integration/channels.test.js +376 -0
  13. package/dist/__tests__/integration/checkpoint.test.js +251 -0
  14. package/dist/__tests__/integration/concurrent-access.test.js +190 -0
  15. package/dist/__tests__/integration/context-operations.test.js +243 -0
  16. package/dist/__tests__/integration/contextDiff.test.js +852 -0
  17. package/dist/__tests__/integration/contextDiffHandler.test.js +976 -0
  18. package/dist/__tests__/integration/contextExportHandler.test.js +510 -0
  19. package/dist/__tests__/integration/contextGetPaginationDefaults.test.js +298 -0
  20. package/dist/__tests__/integration/contextReassignChannelHandler.test.js +908 -0
  21. package/dist/__tests__/integration/contextRelationshipsHandler.test.js +1151 -0
  22. package/dist/__tests__/integration/contextSearch.test.js +938 -0
  23. package/dist/__tests__/integration/contextSearchHandler.test.js +552 -0
  24. package/dist/__tests__/integration/contextWatchActual.test.js +165 -0
  25. package/dist/__tests__/integration/contextWatchHandler.test.js +1500 -0
  26. package/dist/__tests__/integration/cross-session-sharing.test.js +302 -0
  27. package/dist/__tests__/integration/database-initialization.test.js +134 -0
  28. package/dist/__tests__/integration/enhanced-context-operations.test.js +1082 -0
  29. package/dist/__tests__/integration/enhancedContextGetHandler.test.js +915 -0
  30. package/dist/__tests__/integration/enhancedContextTimelineHandler.test.js +716 -0
  31. package/dist/__tests__/integration/error-cases.test.js +407 -0
  32. package/dist/__tests__/integration/export-import.test.js +367 -0
  33. package/dist/__tests__/integration/feature-flags.test.js +542 -0
  34. package/dist/__tests__/integration/file-operations.test.js +264 -0
  35. package/dist/__tests__/integration/git-integration.test.js +237 -0
  36. package/dist/__tests__/integration/index-tools.test.js +496 -0
  37. package/dist/__tests__/integration/issue11-actual-bug-demo.test.js +304 -0
  38. package/dist/__tests__/integration/issue11-search-filters-bug.test.js +561 -0
  39. package/dist/__tests__/integration/issue12-checkpoint-restore-behavior.test.js +621 -0
  40. package/dist/__tests__/integration/issue13-key-validation.test.js +433 -0
  41. package/dist/__tests__/integration/knowledge-graph.test.js +338 -0
  42. package/dist/__tests__/integration/migrations.test.js +528 -0
  43. package/dist/__tests__/integration/multi-agent.test.js +546 -0
  44. package/dist/__tests__/integration/pagination-critical-fix.test.js +296 -0
  45. package/dist/__tests__/integration/paginationDefaultsHandler.test.js +600 -0
  46. package/dist/__tests__/integration/project-directory.test.js +283 -0
  47. package/dist/__tests__/integration/resource-cleanup.test.js +149 -0
  48. package/dist/__tests__/integration/retention.test.js +513 -0
  49. package/dist/__tests__/integration/search.test.js +333 -0
  50. package/dist/__tests__/integration/semantic-search.test.js +266 -0
  51. package/dist/__tests__/integration/server-initialization.test.js +307 -0
  52. package/dist/__tests__/integration/session-management.test.js +219 -0
  53. package/dist/__tests__/integration/simplified-sharing.test.js +346 -0
  54. package/dist/__tests__/integration/smart-compaction.test.js +230 -0
  55. package/dist/__tests__/integration/summarization.test.js +308 -0
  56. package/dist/__tests__/integration/watcher-migration-validation.test.js +544 -0
  57. package/dist/__tests__/security/input-validation.test.js +115 -0
  58. package/dist/__tests__/utils/agents.test.js +473 -0
  59. package/dist/__tests__/utils/database.test.js +177 -0
  60. package/dist/__tests__/utils/git.test.js +122 -0
  61. package/dist/__tests__/utils/knowledge-graph.test.js +297 -0
  62. package/dist/__tests__/utils/migrationHealthCheck.test.js +302 -0
  63. package/dist/__tests__/utils/project-directory-messages.test.js +188 -0
  64. package/dist/__tests__/utils/timezone-safe-dates.js +119 -0
  65. package/dist/__tests__/utils/validation.test.js +200 -0
  66. package/dist/__tests__/utils/vector-store.test.js +231 -0
  67. package/dist/handlers/contextWatchHandlers.js +206 -0
  68. package/dist/index.js +4310 -0
  69. package/dist/index.phase1.backup.js +410 -0
  70. package/dist/index.phase2.backup.js +704 -0
  71. package/dist/migrations/003_add_channels.js +174 -0
  72. package/dist/migrations/004_add_context_watch.js +151 -0
  73. package/dist/migrations/005_add_context_watch.js +98 -0
  74. package/dist/migrations/simplify-sharing.js +117 -0
  75. package/dist/repositories/BaseRepository.js +30 -0
  76. package/dist/repositories/CheckpointRepository.js +140 -0
  77. package/dist/repositories/ContextRepository.js +1873 -0
  78. package/dist/repositories/FileRepository.js +104 -0
  79. package/dist/repositories/RepositoryManager.js +62 -0
  80. package/dist/repositories/SessionRepository.js +66 -0
  81. package/dist/repositories/WatcherRepository.js +252 -0
  82. package/dist/repositories/index.js +15 -0
  83. package/dist/server.js +384 -0
  84. package/dist/test-helpers/database-helper.js +128 -0
  85. package/dist/types/entities.js +3 -0
  86. package/dist/utils/agents.js +791 -0
  87. package/dist/utils/channels.js +150 -0
  88. package/dist/utils/database.js +731 -0
  89. package/dist/utils/feature-flags.js +476 -0
  90. package/dist/utils/git.js +145 -0
  91. package/dist/utils/knowledge-graph.js +264 -0
  92. package/dist/utils/migrationHealthCheck.js +373 -0
  93. package/dist/utils/migrations.js +452 -0
  94. package/dist/utils/retention.js +460 -0
  95. package/dist/utils/timestamps.js +112 -0
  96. package/dist/utils/validation.js +296 -0
  97. package/dist/utils/vector-store.js +247 -0
  98. package/package.json +84 -0
package/README.md ADDED
@@ -0,0 +1,1051 @@
1
+ # MCP Memory Keeper - Claude Code Context Management
2
+
3
+ [![CI](https://github.com/mkreyman/mcp-memory-keeper/actions/workflows/ci.yml/badge.svg)](https://github.com/mkreyman/mcp-memory-keeper/actions/workflows/ci.yml)
4
+ [![codecov](https://codecov.io/gh/mkreyman/mcp-memory-keeper/branch/main/graph/badge.svg)](https://codecov.io/gh/mkreyman/mcp-memory-keeper)
5
+ [![npm version](https://badge.fury.io/js/mcp-memory-keeper.svg)](https://badge.fury.io/js/mcp-memory-keeper)
6
+
7
+ A Model Context Protocol (MCP) server that provides persistent context management for Claude AI coding assistants. Never lose context during compaction again! This MCP server helps Claude Code maintain context across sessions, preserving your work history, decisions, and progress.
8
+
9
+ ## Why MCP Memory Keeper?
10
+
11
+ Claude Code users often face context loss when the conversation window fills up. This MCP server solves that problem by providing a persistent memory layer for Claude AI. Whether you're working on complex refactoring, multi-file changes, or long debugging sessions, Memory Keeper ensures your Claude assistant remembers important context, decisions, and progress.
12
+
13
+ ### Perfect for:
14
+
15
+ - Long coding sessions with Claude Code
16
+ - Complex projects requiring context preservation
17
+ - Teams using Claude AI for collaborative development
18
+ - Developers who want persistent context across Claude sessions
19
+
20
+ ## Features
21
+
22
+ - 🔄 Save and restore context between Claude Code sessions
23
+ - 📁 File content caching with change detection
24
+ - 🏷️ Organize context with categories and priorities
25
+ - 📺 **Channels** - Persistent topic-based organization (auto-derived from git branch)
26
+ - 📸 Checkpoint system for complete context snapshots
27
+ - 🤖 Smart compaction helper that never loses critical info
28
+ - 🔍 Full-text search across all saved context
29
+ - 🕐 **Enhanced filtering** - Time-based queries, regex patterns, pagination
30
+ - 📊 **Change tracking** - See what's been added, modified, or deleted since any point
31
+ - 💾 Export/import for backup and sharing
32
+ - 🌿 Git integration with automatic context correlation
33
+ - 📊 AI-friendly summarization with priority awareness
34
+ - 🚀 Fast SQLite-based storage optimized for Claude
35
+ - 🔁 **Batch operations** - Save, update, or delete multiple items atomically
36
+ - 🔄 **Channel reassignment** - Move items between channels based on patterns
37
+ - 🔗 **Context relationships** - Link related items with typed relationships
38
+ - 👁️ **Real-time monitoring** - Watch for context changes with filters
39
+
40
+ ## Installation
41
+
42
+ ### Method 1: NPX (Recommended)
43
+
44
+ The simplest way to use memory-keeper with Claude:
45
+
46
+ ```bash
47
+ claude mcp add memory-keeper npx mcp-memory-keeper
48
+ ```
49
+
50
+ That's it! This will:
51
+
52
+ - Always use the latest version
53
+ - Handle all dependencies automatically
54
+ - Create the data directory at `~/mcp-data/memory-keeper/`
55
+ - Work across different platforms
56
+
57
+ ### Method 2: Global Installation
58
+
59
+ If you prefer a global installation:
60
+
61
+ ```bash
62
+ npm install -g mcp-memory-keeper
63
+ claude mcp add memory-keeper mcp-memory-keeper
64
+ ```
65
+
66
+ ### Method 3: From Source
67
+
68
+ ```bash
69
+ # 1. Clone the repository
70
+ git clone https://github.com/mkreyman/mcp-memory-keeper.git
71
+ cd mcp-memory-keeper
72
+
73
+ # 2. Install dependencies
74
+ npm install
75
+
76
+ # 3. Build the project
77
+ npm run build
78
+
79
+ # 4. Add to Claude
80
+ claude mcp add memory-keeper node /absolute/path/to/mcp-memory-keeper/dist/index.js
81
+ ```
82
+
83
+ ## Configuration
84
+
85
+ ### Environment Variables
86
+
87
+ - `DATA_DIR` - Directory for database storage (default: `~/mcp-data/memory-keeper/`)
88
+ - `MEMORY_KEEPER_INSTALL_DIR` - Installation directory (default: `~/.local/mcp-servers/memory-keeper/`)
89
+ - `MEMORY_KEEPER_AUTO_UPDATE` - Set to `1` to enable auto-updates
90
+
91
+ ### Claude Code (CLI)
92
+
93
+ #### Configuration Scopes
94
+
95
+ Choose where to save the configuration:
96
+
97
+ ```bash
98
+ # Project-specific (default) - only for you in this project
99
+ claude mcp add memory-keeper node /path/to/mcp-memory-keeper/dist/index.js
100
+
101
+ # Shared with team via .mcp.json
102
+ claude mcp add --scope project memory-keeper node /path/to/mcp-memory-keeper/dist/index.js
103
+
104
+ # Available across all your projects
105
+ claude mcp add --scope user memory-keeper node /path/to/mcp-memory-keeper/dist/index.js
106
+ ```
107
+
108
+ #### Verify Configuration
109
+
110
+ ```bash
111
+ # List all configured servers
112
+ claude mcp list
113
+
114
+ # Get details for Memory Keeper
115
+ claude mcp get memory-keeper
116
+ ```
117
+
118
+ ### Claude Desktop App
119
+
120
+ 1. Open Claude Desktop settings
121
+ 2. Navigate to "Developer" → "Model Context Protocol"
122
+ 3. Click "Add MCP Server"
123
+ 4. Add the following configuration:
124
+
125
+ ```json
126
+ {
127
+ "mcpServers": {
128
+ "memory-keeper": {
129
+ "command": "node",
130
+ "args": ["/absolute/path/to/mcp-memory-keeper/dist/index.js"]
131
+ }
132
+ }
133
+ }
134
+ ```
135
+
136
+ **Important**: Replace `/absolute/path/to/mcp-memory-keeper` with the actual path where you cloned/installed the project.
137
+
138
+ ### Example paths:
139
+
140
+ - macOS: `/Users/username/projects/mcp-memory-keeper/dist/index.js`
141
+ - Windows: `C:\\Users\\username\\projects\\mcp-memory-keeper\\dist\\index.js`
142
+ - Linux: `/home/username/projects/mcp-memory-keeper/dist/index.js`
143
+
144
+ ### Verify Installation
145
+
146
+ #### For Claude Code:
147
+
148
+ 1. Restart Claude Code or start a new session
149
+ 2. The Memory Keeper tools should be available automatically
150
+ 3. Test with: `mcp_memory_save({ key: "test", value: "Hello Memory Keeper!" })`
151
+ 4. If not working, check server status:
152
+ ```bash
153
+ claude mcp list # Should show memory-keeper as "running"
154
+ ```
155
+
156
+ #### For Claude Desktop:
157
+
158
+ 1. Restart Claude Desktop after adding the configuration
159
+ 2. In a new conversation, the Memory Keeper tools should be available
160
+ 3. Test with the same command above
161
+
162
+ ### Troubleshooting
163
+
164
+ If Memory Keeper isn't working:
165
+
166
+ ```bash
167
+ # Remove and re-add the server
168
+ claude mcp remove memory-keeper
169
+ claude mcp add memory-keeper node /absolute/path/to/mcp-memory-keeper/dist/index.js
170
+
171
+ # Check logs for errors
172
+ # The server output will appear in Claude Code's output panel
173
+ ```
174
+
175
+ ### Updating to Latest Version
176
+
177
+ To get the latest features and bug fixes:
178
+
179
+ ```bash
180
+ # 1. Navigate to your Memory Keeper directory
181
+ cd /path/to/mcp-memory-keeper
182
+
183
+ # 2. Pull the latest changes
184
+ git pull
185
+
186
+ # 3. Install any new dependencies (if package.json changed)
187
+ npm install
188
+
189
+ # 4. Rebuild the project
190
+ npm run build
191
+
192
+ # 5. Start a new Claude session
193
+ # The updated features will be available immediately
194
+ ```
195
+
196
+ **Note**: You don't need to reconfigure the MCP server in Claude after updating. Just pull, build, and start a new session!
197
+
198
+ ## Usage
199
+
200
+ ### Session Management
201
+
202
+ ```javascript
203
+ // Start a new session
204
+ mcp_context_session_start({
205
+ name: 'Feature Development',
206
+ description: 'Working on user authentication',
207
+ });
208
+
209
+ // Start a session with project directory for git tracking
210
+ mcp_context_session_start({
211
+ name: 'Feature Development',
212
+ description: 'Working on user authentication',
213
+ projectDir: '/path/to/your/project',
214
+ });
215
+
216
+ // Start a session with a default channel
217
+ mcp_context_session_start({
218
+ name: 'Feature Development',
219
+ description: 'Working on user authentication',
220
+ projectDir: '/path/to/your/project',
221
+ defaultChannel: 'auth-feature', // Will auto-derive from git branch if not specified
222
+ });
223
+
224
+ // Set project directory for current session
225
+ mcp_context_set_project_dir({
226
+ projectDir: '/path/to/your/project',
227
+ });
228
+
229
+ // List recent sessions
230
+ mcp_context_session_list({ limit: 5 });
231
+
232
+ // Continue from a previous session
233
+ mcp_context_session_start({
234
+ name: 'Feature Dev Continued',
235
+ continueFrom: 'previous-session-id',
236
+ });
237
+ ```
238
+
239
+ ### Working with Channels (NEW in v0.10.0)
240
+
241
+ Channels provide persistent topic-based organization that survives session crashes and restarts:
242
+
243
+ ```javascript
244
+ // Channels are auto-derived from git branch (if projectDir is set)
245
+ // Branch "feature/auth-system" becomes channel "feature-auth-system" (20 chars max)
246
+
247
+ // Save to a specific channel
248
+ mcp_context_save({
249
+ key: 'auth_design',
250
+ value: 'Using JWT with refresh tokens',
251
+ category: 'decision',
252
+ priority: 'high',
253
+ channel: 'auth-feature', // Explicitly set channel
254
+ });
255
+
256
+ // Get items from a specific channel
257
+ mcp_context_get({ channel: 'auth-feature' });
258
+
259
+ // Get items across all channels (default behavior)
260
+ mcp_context_get({ category: 'task' });
261
+
262
+ // Channels persist across sessions - perfect for:
263
+ // - Multi-branch development
264
+ // - Feature-specific context
265
+ // - Team collaboration on different topics
266
+ ```
267
+
268
+ ### Enhanced Context Storage
269
+
270
+ ```javascript
271
+ // Save with categories and priorities
272
+ mcp_context_save({
273
+ key: 'current_task',
274
+ value: 'Implement OAuth integration',
275
+ category: 'task',
276
+ priority: 'high',
277
+ });
278
+
279
+ // Save decisions
280
+ mcp_context_save({
281
+ key: 'auth_strategy',
282
+ value: 'Using JWT tokens with 24h expiry',
283
+ category: 'decision',
284
+ priority: 'high',
285
+ });
286
+
287
+ // Save progress notes
288
+ mcp_context_save({
289
+ key: 'progress_auth',
290
+ value: 'Completed user model, working on token generation',
291
+ category: 'progress',
292
+ priority: 'normal',
293
+ });
294
+
295
+ // Retrieve by category
296
+ mcp_context_get({ category: 'task' });
297
+
298
+ // Retrieve specific item
299
+ mcp_context_get({ key: 'current_task' });
300
+
301
+ // Get context from specific session
302
+ mcp_context_get({
303
+ sessionId: 'session-id-here',
304
+ category: 'decision',
305
+ });
306
+
307
+ // Enhanced filtering (NEW in v0.10.0)
308
+ mcp_context_get({
309
+ category: 'task',
310
+ priorities: ['high', 'normal'],
311
+ includeMetadata: true, // Get timestamps, size info
312
+ sort: 'created_desc', // created_asc/desc, updated_asc/desc, priority
313
+ limit: 10, // Pagination
314
+ offset: 0,
315
+ });
316
+
317
+ // Time-based queries (NEW in v0.10.0)
318
+ mcp_context_get({
319
+ createdAfter: '2025-01-20T00:00:00Z',
320
+ createdBefore: '2025-01-26T23:59:59Z',
321
+ includeMetadata: true,
322
+ });
323
+
324
+ // Pattern matching (NEW in v0.10.0)
325
+ mcp_context_get({
326
+ keyPattern: 'auth_.*', // Regex to match keys
327
+ category: 'decision',
328
+ });
329
+ ```
330
+
331
+ ### File Caching
332
+
333
+ ```javascript
334
+ // Cache file content for change detection
335
+ mcp_context_cache_file({
336
+ filePath: '/src/auth/user.model.ts',
337
+ content: fileContent,
338
+ });
339
+
340
+ // Check if file has changed
341
+ mcp_context_file_changed({
342
+ filePath: '/src/auth/user.model.ts',
343
+ currentContent: newFileContent,
344
+ });
345
+
346
+ // Get current session status
347
+ mcp_context_status();
348
+ ```
349
+
350
+ ### Complete Workflow Example
351
+
352
+ ```javascript
353
+ // 1. Start a new session
354
+ mcp_context_session_start({
355
+ name: 'Settings Refactor',
356
+ description: 'Refactoring settings module for better performance',
357
+ });
358
+
359
+ // 2. Save high-priority task
360
+ mcp_context_save({
361
+ key: 'main_task',
362
+ value: 'Refactor Settings.Context to use behaviors',
363
+ category: 'task',
364
+ priority: 'high',
365
+ });
366
+
367
+ // 3. Cache important files
368
+ mcp_context_cache_file({
369
+ filePath: 'lib/settings/context.ex',
370
+ content: originalFileContent,
371
+ });
372
+
373
+ // 4. Save decisions as you work
374
+ mcp_context_save({
375
+ key: 'architecture_decision',
376
+ value: 'Split settings into read/write modules',
377
+ category: 'decision',
378
+ priority: 'high',
379
+ });
380
+
381
+ // 5. Track progress
382
+ mcp_context_save({
383
+ key: 'progress_1',
384
+ value: 'Completed behavior definition, 5 modules remaining',
385
+ category: 'progress',
386
+ priority: 'normal',
387
+ });
388
+
389
+ // 6. Before context window fills up
390
+ mcp_context_status(); // Check what's saved
391
+
392
+ // 7. After Claude Code restart
393
+ mcp_context_get({ category: 'task', priority: 'high' }); // Get high priority tasks
394
+ mcp_context_get({ key: 'architecture_decision' }); // Get specific decisions
395
+ mcp_context_file_changed({ filePath: 'lib/settings/context.ex' }); // Check for changes
396
+ ```
397
+
398
+ ### Checkpoints (Phase 2)
399
+
400
+ Create named snapshots of your entire context that can be restored later:
401
+
402
+ ```javascript
403
+ // Create a checkpoint before major changes
404
+ mcp_context_checkpoint({
405
+ name: 'before-refactor',
406
+ description: 'State before major settings refactor',
407
+ includeFiles: true, // Include cached files
408
+ includeGitStatus: true, // Capture git status
409
+ });
410
+
411
+ // Continue working...
412
+ // If something goes wrong, restore from checkpoint
413
+ mcp_context_restore_checkpoint({
414
+ name: 'before-refactor',
415
+ restoreFiles: true, // Restore cached files too
416
+ });
417
+
418
+ // Or restore the latest checkpoint
419
+ mcp_context_restore_checkpoint({});
420
+ ```
421
+
422
+ ### Context Summarization (Phase 2)
423
+
424
+ Get AI-friendly summaries of your saved context:
425
+
426
+ ```javascript
427
+ // Get a summary of all context
428
+ mcp_context_summarize();
429
+
430
+ // Get summary of specific categories
431
+ mcp_context_summarize({
432
+ categories: ['task', 'decision'],
433
+ maxLength: 2000,
434
+ });
435
+
436
+ // Summarize a specific session
437
+ mcp_context_summarize({
438
+ sessionId: 'session-id-here',
439
+ categories: ['progress'],
440
+ });
441
+ ```
442
+
443
+ Example summary output:
444
+
445
+ ```markdown
446
+ # Context Summary
447
+
448
+ ## High Priority Items
449
+
450
+ - **main_task**: Refactor Settings.Context to use behaviors
451
+ - **critical_bug**: Fix memory leak in subscription handler
452
+
453
+ ## Task
454
+
455
+ - implement_auth: Add OAuth2 authentication flow
456
+ - update_tests: Update test suite for new API
457
+
458
+ ## Decision
459
+
460
+ - architecture_decision: Split settings into read/write modules
461
+ - db_choice: Use PostgreSQL for better JSON support
462
+ ```
463
+
464
+ ### Batch Operations
465
+
466
+ Perform multiple operations atomically:
467
+
468
+ ```javascript
469
+ // Save multiple items at once
470
+ mcp_context_batch_save({
471
+ items: [
472
+ { key: 'config_api_url', value: 'https://api.example.com', category: 'note' },
473
+ { key: 'config_timeout', value: '30000', category: 'note' },
474
+ { key: 'config_retries', value: '3', category: 'note' },
475
+ ],
476
+ });
477
+
478
+ // Update multiple items
479
+ mcp_context_batch_update({
480
+ updates: [
481
+ { key: 'task_1', priority: 'high' },
482
+ { key: 'task_2', priority: 'high' },
483
+ { key: 'task_3', value: 'Updated task description' },
484
+ ],
485
+ });
486
+
487
+ // Delete by pattern
488
+ mcp_context_batch_delete({
489
+ keyPattern: 'temp_*',
490
+ dryRun: true, // Preview first
491
+ });
492
+ ```
493
+
494
+ ### Channel Management
495
+
496
+ Reorganize context items between channels:
497
+
498
+ ```javascript
499
+ // Move items to a new channel
500
+ mcp_context_reassign_channel({
501
+ keyPattern: 'auth_*',
502
+ toChannel: 'feature-authentication',
503
+ });
504
+
505
+ // Move from one channel to another
506
+ mcp_context_reassign_channel({
507
+ fromChannel: 'sprint-14',
508
+ toChannel: 'sprint-15',
509
+ category: 'task',
510
+ priorities: ['high'],
511
+ });
512
+ ```
513
+
514
+ ### Context Relationships
515
+
516
+ Build a graph of related items:
517
+
518
+ ```javascript
519
+ // Link related items
520
+ mcp_context_link({
521
+ sourceKey: 'epic_user_management',
522
+ targetKey: 'task_create_user_api',
523
+ relationship: 'contains',
524
+ });
525
+
526
+ // Find related items
527
+ mcp_context_get_related({
528
+ key: 'epic_user_management',
529
+ relationship: 'contains',
530
+ depth: 2,
531
+ });
532
+ ```
533
+
534
+ ### Real-time Monitoring
535
+
536
+ Watch for context changes:
537
+
538
+ ```javascript
539
+ // Create a watcher
540
+ const watcher = await mcp_context_watch({
541
+ action: 'create',
542
+ filters: {
543
+ categories: ['task'],
544
+ priorities: ['high'],
545
+ },
546
+ });
547
+
548
+ // Poll for changes
549
+ const changes = await mcp_context_watch({
550
+ action: 'poll',
551
+ watcherId: watcher.watcherId,
552
+ });
553
+ ```
554
+
555
+ ### Smart Compaction (Phase 3)
556
+
557
+ Never lose critical context when Claude's window fills up:
558
+
559
+ ```javascript
560
+ // Before context window fills
561
+ mcp_context_prepare_compaction();
562
+
563
+ // This automatically:
564
+ // - Creates a checkpoint
565
+ // - Identifies high-priority items
566
+ // - Captures unfinished tasks
567
+ // - Saves all decisions
568
+ // - Generates a summary
569
+ // - Prepares restoration instructions
570
+ ```
571
+
572
+ ### Git Integration (Phase 3)
573
+
574
+ Track git changes in your project directory and save context with commits:
575
+
576
+ ```javascript
577
+ // First, set your project directory (if not done during session start)
578
+ mcp_context_set_project_dir({
579
+ projectDir: '/path/to/your/project',
580
+ });
581
+
582
+ // Commit with auto-save
583
+ mcp_context_git_commit({
584
+ message: 'feat: Add user authentication',
585
+ autoSave: true, // Creates checkpoint with commit
586
+ });
587
+
588
+ // Context is automatically linked to the commit
589
+ // Note: If no project directory is set, you'll see a helpful message
590
+ // explaining how to enable git tracking for your project
591
+ ```
592
+
593
+ ### Context Search (Phase 3)
594
+
595
+ Find anything in your saved context:
596
+
597
+ ```javascript
598
+ // Search in keys and values
599
+ mcp_context_search({ query: 'authentication' });
600
+
601
+ // Search only in keys
602
+ mcp_context_search({
603
+ query: 'config',
604
+ searchIn: ['key'],
605
+ });
606
+
607
+ // Search in specific session
608
+ mcp_context_search({
609
+ query: 'bug',
610
+ sessionId: 'session-id',
611
+ });
612
+ ```
613
+
614
+ ### Export/Import (Phase 3)
615
+
616
+ Share context or backup your work:
617
+
618
+ ```javascript
619
+ // Export current session
620
+ mcp_context_export(); // Creates memory-keeper-export-xxx.json
621
+
622
+ // Export specific session
623
+ mcp_context_export({
624
+ sessionId: 'session-id',
625
+ format: 'json',
626
+ });
627
+
628
+ // Import from file
629
+ mcp_context_import({
630
+ filePath: 'memory-keeper-export-xxx.json',
631
+ });
632
+
633
+ // Merge into current session
634
+ mcp_context_import({
635
+ filePath: 'backup.json',
636
+ merge: true,
637
+ });
638
+ ```
639
+
640
+ ### Knowledge Graph (Phase 4)
641
+
642
+ Automatically extract entities and relationships from your context:
643
+
644
+ ```javascript
645
+ // Analyze context to build knowledge graph
646
+ mcp_context_analyze();
647
+
648
+ // Or analyze specific categories
649
+ mcp_context_analyze({
650
+ categories: ['task', 'decision'],
651
+ });
652
+
653
+ // Find related entities
654
+ mcp_context_find_related({
655
+ key: 'AuthService',
656
+ maxDepth: 2,
657
+ });
658
+
659
+ // Generate visualization data
660
+ mcp_context_visualize({
661
+ type: 'graph',
662
+ });
663
+
664
+ // Timeline view
665
+ mcp_context_visualize({
666
+ type: 'timeline',
667
+ });
668
+
669
+ // Category/priority heatmap
670
+ mcp_context_visualize({
671
+ type: 'heatmap',
672
+ });
673
+ ```
674
+
675
+ ### Semantic Search (Phase 4.2)
676
+
677
+ Find context using natural language queries:
678
+
679
+ ```javascript
680
+ // Search with natural language
681
+ mcp_context_semantic_search({
682
+ query: 'how are we handling user authentication?',
683
+ topK: 5,
684
+ });
685
+
686
+ // Find the most relevant security decisions
687
+ mcp_context_semantic_search({
688
+ query: 'security concerns and decisions',
689
+ minSimilarity: 0.5,
690
+ });
691
+
692
+ // Search with specific similarity threshold
693
+ mcp_context_semantic_search({
694
+ query: 'database performance optimization',
695
+ topK: 10,
696
+ minSimilarity: 0.3,
697
+ });
698
+ ```
699
+
700
+ ### Multi-Agent System (Phase 4.3)
701
+
702
+ Delegate complex analysis tasks to specialized agents:
703
+
704
+ ```javascript
705
+ // Analyze patterns in your context
706
+ mcp_context_delegate({
707
+ taskType: 'analyze',
708
+ input: {
709
+ analysisType: 'patterns',
710
+ categories: ['task', 'decision'],
711
+ },
712
+ });
713
+
714
+ // Get comprehensive analysis
715
+ mcp_context_delegate({
716
+ taskType: 'analyze',
717
+ input: {
718
+ analysisType: 'comprehensive',
719
+ },
720
+ });
721
+
722
+ // Analyze relationships between entities
723
+ mcp_context_delegate({
724
+ taskType: 'analyze',
725
+ input: {
726
+ analysisType: 'relationships',
727
+ maxDepth: 3,
728
+ },
729
+ });
730
+
731
+ // Create intelligent summaries
732
+ mcp_context_delegate({
733
+ taskType: 'synthesize',
734
+ input: {
735
+ synthesisType: 'summary',
736
+ maxLength: 1000,
737
+ },
738
+ });
739
+
740
+ // Get actionable recommendations
741
+ mcp_context_delegate({
742
+ taskType: 'synthesize',
743
+ input: {
744
+ synthesisType: 'recommendations',
745
+ analysisResults: {}, // Can pass previous analysis results
746
+ },
747
+ });
748
+
749
+ // Chain multiple agent tasks
750
+ mcp_context_delegate({
751
+ chain: true,
752
+ taskType: ['analyze', 'synthesize'],
753
+ input: [{ analysisType: 'comprehensive' }, { synthesisType: 'recommendations' }],
754
+ });
755
+ ```
756
+
757
+ Agent Types:
758
+
759
+ - **Analyzer Agent**: Detects patterns, analyzes relationships, tracks trends
760
+ - **Synthesizer Agent**: Creates summaries, merges insights, generates recommendations
761
+
762
+ ### Session Branching & Merging (Phase 4.4)
763
+
764
+ Explore alternatives without losing your original work:
765
+
766
+ ```javascript
767
+ // Create a branch to try something new
768
+ mcp_context_branch_session({
769
+ branchName: 'experimental-refactor',
770
+ copyDepth: 'shallow', // Only copy high-priority items
771
+ });
772
+
773
+ // Or create a full copy
774
+ mcp_context_branch_session({
775
+ branchName: 'feature-complete-copy',
776
+ copyDepth: 'deep', // Copy everything
777
+ });
778
+
779
+ // Later, merge changes back
780
+ mcp_context_merge_sessions({
781
+ sourceSessionId: 'branch-session-id',
782
+ conflictResolution: 'keep_newest', // or "keep_current", "keep_source"
783
+ });
784
+ ```
785
+
786
+ ### Journal Entries (Phase 4.4)
787
+
788
+ Track your thoughts and progress with timestamped journal entries:
789
+
790
+ ```javascript
791
+ // Add a journal entry
792
+ mcp_context_journal_entry({
793
+ entry: 'Completed the authentication module. Tests are passing!',
794
+ tags: ['milestone', 'authentication'],
795
+ mood: 'accomplished',
796
+ });
797
+
798
+ // Entries are included in timeline views
799
+ mcp_context_timeline({
800
+ groupBy: 'day',
801
+ });
802
+ ```
803
+
804
+ ### Timeline & Activity Tracking (Phase 4.4)
805
+
806
+ Visualize your work patterns over time:
807
+
808
+ ```javascript
809
+ // Get activity timeline
810
+ mcp_context_timeline({
811
+ startDate: '2024-01-01',
812
+ endDate: '2024-01-31',
813
+ groupBy: 'day', // or "hour", "week"
814
+ });
815
+
816
+ // Enhanced timeline (NEW in v0.10.0)
817
+ mcp_context_timeline({
818
+ groupBy: 'hour',
819
+ includeItems: true, // Show actual items, not just counts
820
+ categories: ['task', 'progress'], // Filter by categories
821
+ relativeTime: true, // Show "2 hours ago" format
822
+ itemsPerPeriod: 10, // Limit items shown per time period
823
+ });
824
+
825
+ // Shows:
826
+ // - Context items created per day/hour
827
+ // - Category distribution over time
828
+ // - Journal entries with moods and tags
829
+ // - Actual item details when includeItems: true
830
+ ```
831
+
832
+ ### Progressive Compression (Phase 4.4)
833
+
834
+ Save space by intelligently compressing old context:
835
+
836
+ ```javascript
837
+ // Compress items older than 30 days
838
+ mcp_context_compress({
839
+ olderThan: '2024-01-01',
840
+ preserveCategories: ['decision', 'critical'], // Keep these
841
+ targetSize: 1000, // Target size in KB (optional)
842
+ });
843
+
844
+ // Compression summary shows:
845
+ // - Items compressed
846
+ // - Space saved
847
+ // - Compression ratio
848
+ // - Categories affected
849
+ ```
850
+
851
+ ### Cross-Tool Integration (Phase 4.4)
852
+
853
+ Track events from other MCP tools:
854
+
855
+ ```javascript
856
+ // Record events from other tools
857
+ mcp_context_integrate_tool({
858
+ toolName: 'code-analyzer',
859
+ eventType: 'security-scan-complete',
860
+ data: {
861
+ vulnerabilities: 0,
862
+ filesScanned: 150,
863
+ important: true, // Creates high-priority context item
864
+ },
865
+ });
866
+ ```
867
+
868
+ ## Documentation
869
+
870
+ - **[Quick Start Examples](./EXAMPLES.md)** - Real-world scenarios and workflows
871
+ - **[API Reference](./API.md)** - Complete tool documentation with all parameters and examples
872
+ - **[Recipe Book](./RECIPES.md)** - Common patterns and best practices for daily development
873
+ - **[Troubleshooting Guide](./TROUBLESHOOTING.md)** - Common issues and solutions
874
+ - **[Architecture Overview](./ARCHITECTURE.md)** - System design and technical details
875
+ - **[Contributing Guide](./CONTRIBUTING.md)** - How to contribute to the project
876
+ - **[Changelog](./CHANGELOG.md)** - Version history and release notes
877
+
878
+ ## Development
879
+
880
+ ### Running in Development Mode
881
+
882
+ ```bash
883
+ # Install dependencies
884
+ npm install
885
+
886
+ # Run tests
887
+ npm test
888
+
889
+ # Run tests with coverage
890
+ npm run test:coverage
891
+
892
+ # Run with auto-reload
893
+ npm run dev
894
+
895
+ # Build for production
896
+ npm run build
897
+
898
+ # Start production server
899
+ npm start
900
+ ```
901
+
902
+ ### Project Structure
903
+
904
+ ```
905
+ mcp-memory-keeper/
906
+ ├── src/
907
+ │ ├── index.ts # Main MCP server implementation
908
+ │ ├── utils/ # Utility modules
909
+ │ │ ├── database.ts # Database management
910
+ │ │ ├── validation.ts # Input validation
911
+ │ │ ├── git.ts # Git operations
912
+ │ │ ├── knowledge-graph.ts # Knowledge graph management
913
+ │ │ ├── vector-store.ts # Vector embeddings
914
+ │ │ └── agents.ts # Multi-agent system
915
+ │ └── __tests__/ # Test files
916
+ ├── dist/ # Compiled JavaScript (generated)
917
+ ├── context.db # SQLite database (auto-created)
918
+ ├── EXAMPLES.md # Quick start examples
919
+ ├── TROUBLESHOOTING.md # Common issues and solutions
920
+ ├── package.json # Project configuration
921
+ ├── tsconfig.json # TypeScript configuration
922
+ ├── jest.config.js # Test configuration
923
+ └── README.md # This file
924
+ ```
925
+
926
+ ### Testing
927
+
928
+ The project includes comprehensive test coverage:
929
+
930
+ ```bash
931
+ # Run all tests
932
+ npm test
933
+
934
+ # Run tests in watch mode
935
+ npm run test:watch
936
+
937
+ # Generate coverage report
938
+ npm run test:coverage
939
+
940
+ # Run specific test file
941
+ npm test -- summarization.test.ts
942
+ ```
943
+
944
+ Test categories:
945
+
946
+ - **Unit Tests**: Input validation, database operations, git integration
947
+ - **Integration Tests**: Full tool workflows, error scenarios, edge cases
948
+ - **Coverage**: 97%+ coverage on critical modules
949
+
950
+ ## Feature Status
951
+
952
+ | Feature | Maturity | Version | Use Case |
953
+ | ---------------- | --------- | ------- | -------------------------- |
954
+ | Basic Save/Get | ✅ Stable | v0.1+ | Daily context management |
955
+ | Sessions | ✅ Stable | v0.2+ | Multi-project work |
956
+ | File Caching | ✅ Stable | v0.2+ | Track file changes |
957
+ | Checkpoints | ✅ Stable | v0.3+ | Context preservation |
958
+ | Smart Compaction | ✅ Stable | v0.3+ | Pre-compaction prep |
959
+ | Git Integration | ✅ Stable | v0.3+ | Commit context tracking |
960
+ | Search | ✅ Stable | v0.3+ | Find saved items |
961
+ | Export/Import | ✅ Stable | v0.3+ | Backup & sharing |
962
+ | Knowledge Graph | ✅ Stable | v0.5+ | Code relationship analysis |
963
+ | Visualization | ✅ Stable | v0.5+ | Context exploration |
964
+ | Semantic Search | ✅ Stable | v0.6+ | Natural language queries |
965
+ | Multi-Agent | ✅ Stable | v0.7+ | Intelligent processing |
966
+
967
+ ### Current Features (v0.10.0)
968
+
969
+ - ✅ **Session Management**: Create, list, and continue sessions with branching support
970
+ - ✅ **Channels**: Persistent topic-based organization (auto-derived from git branch)
971
+ - ✅ **Context Storage**: Save/retrieve context with categories (task, decision, progress, note) and priorities
972
+ - ✅ **Enhanced Filtering**: Time-based queries, regex patterns, sorting, pagination
973
+ - ✅ **File Caching**: Track file changes with SHA-256 hashing
974
+ - ✅ **Checkpoints**: Create and restore complete context snapshots
975
+ - ✅ **Smart Compaction**: Never lose critical context when hitting limits
976
+ - ✅ **Git Integration**: Auto-save context on commits with branch tracking
977
+ - ✅ **Search**: Full-text search across all saved context
978
+ - ✅ **Export/Import**: Backup and share context as JSON
979
+ - ✅ **SQLite Storage**: Persistent, reliable data storage with WAL mode
980
+ - ✅ **Knowledge Graph**: Automatic entity and relationship extraction from context
981
+ - ✅ **Visualization**: Generate graph, timeline, and heatmap data for context exploration
982
+ - ✅ **Semantic Search**: Natural language search using lightweight vector embeddings
983
+ - ✅ **Multi-Agent System**: Intelligent analysis with specialized analyzer and synthesizer agents
984
+ - ✅ **Session Branching**: Create branches to explore alternatives without losing original context
985
+ - ✅ **Session Merging**: Merge branches back with conflict resolution options
986
+ - ✅ **Journal Entries**: Time-stamped entries with tags and mood tracking
987
+ - ✅ **Enhanced Timeline**: Activity patterns with item details and relative time
988
+ - ✅ **Progressive Compression**: Intelligently compress old context to save space
989
+ - ✅ **Cross-Tool Integration**: Track events from other MCP tools
990
+
991
+ ### Roadmap
992
+
993
+ #### Phase 4: Advanced Features (In Development)
994
+
995
+ - 🚧 **Knowledge Graph**: Entity-relation tracking for code understanding
996
+ - 🚧 **Vector Search**: Semantic search using natural language
997
+ - 📋 **Multi-Agent Processing**: Intelligent analysis and synthesis
998
+ - 📋 **Time-Aware Context**: Timeline views and journal entries
999
+
1000
+ #### Phase 5: Documentation & Polish
1001
+
1002
+ - ✅ **Examples**: Comprehensive quick-start scenarios
1003
+ - ✅ **Troubleshooting**: Common issues and solutions
1004
+ - 🚧 **Recipes**: Common patterns and workflows
1005
+ - 📋 **Video Tutorials**: Visual guides for key features
1006
+
1007
+ #### Future Enhancements
1008
+
1009
+ - [ ] Web UI for browsing context history
1010
+ - [ ] Multi-user/team collaboration features
1011
+ - [ ] Cloud sync and sharing
1012
+ - [ ] Integration with other AI assistants
1013
+ - [ ] Advanced analytics and insights
1014
+ - [ ] Custom context templates
1015
+ - [ ] Automatic retention policies
1016
+
1017
+ ## Contributing
1018
+
1019
+ Contributions are welcome! Please feel free to submit a Pull Request.
1020
+
1021
+ 1. Fork the repository
1022
+ 2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
1023
+ 3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
1024
+ 4. Push to the branch (`git push origin feature/AmazingFeature`)
1025
+ 5. Open a Pull Request
1026
+
1027
+ ## License
1028
+
1029
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
1030
+
1031
+ ## Author
1032
+
1033
+ Mark Kreyman
1034
+
1035
+ ## Acknowledgments
1036
+
1037
+ - Built for the Claude Code community
1038
+ - Inspired by the need for better context management in AI coding sessions
1039
+ - Thanks to Anthropic for the MCP protocol
1040
+
1041
+ ## Support
1042
+
1043
+ If you encounter any issues or have questions:
1044
+
1045
+ - Open an issue on [GitHub](https://github.com/mkreyman/mcp-memory-keeper/issues)
1046
+ - Check the [MCP documentation](https://modelcontextprotocol.io/)
1047
+ - Join the Claude Code community discussions
1048
+
1049
+ ## Keywords
1050
+
1051
+ Claude Code context management, MCP server, Claude AI memory, persistent context, Model Context Protocol, Claude assistant memory, AI coding context, Claude Code MCP, context preservation, Claude AI tools