@danielsimonjr/memory-mcp 12.2.3 → 12.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,15 +1,15 @@
1
1
  # Memory MCP Server
2
2
 
3
- [![Version](https://img.shields.io/badge/version-12.2.0-blue.svg)](https://github.com/danielsimonjr/memory-mcp)
3
+ [![Version](https://img.shields.io/badge/version-12.7.0-blue.svg)](https://github.com/danielsimonjr/memory-mcp)
4
4
  [![NPM](https://img.shields.io/npm/v/@danielsimonjr/memory-mcp.svg)](https://www.npmjs.com/package/@danielsimonjr/memory-mcp)
5
5
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
6
6
  [![MCP](https://img.shields.io/badge/MCP-1.0-purple.svg)](https://modelcontextprotocol.io)
7
7
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.6-blue.svg)](https://www.typescriptlang.org/)
8
- [![Coverage](https://img.shields.io/badge/coverage-96.6%25-brightgreen.svg)](docs/architecture/TEST_COVERAGE.md)
8
+ [![Coverage](https://img.shields.io/badge/coverage-84.8%25-yellowgreen.svg)](docs/architecture/TEST_COVERAGE.md)
9
9
 
10
10
  An **enhanced fork** of the official [Model Context Protocol](https://modelcontextprotocol.io) memory server with advanced features for **hierarchical nesting**, **intelligent compression**, **semantic search**, **graph algorithms**, **archiving**, **advanced search**, and **multi-format import/export**.
11
11
 
12
- > **Enterprise-grade knowledge graph** with **160 tools** including hierarchical organization, semantic search with embeddings, graph traversal algorithms, duplicate detection, smart archiving, project scoping, temporal knowledge graph, semantic forget, agent diary, **entity bitemporal validity (η.4.4)**, **optimistic concurrency control (η.5.5.c)**, **role-based access control (η.6.1)**, **W3C Linked Data exports** (Turtle / JSON-LD / RDF/XML — η.5.4), **PII redaction on export** (η.6.3), **procedural memory (3B.4)**, **active retrieval (3B.5)**, **causal reasoning (3B.6)**, and **world model (3B.7)** for long-term memory management.
12
+ > **Enterprise-grade knowledge graph** with **241 tools** including hierarchical organization, semantic search with embeddings, graph traversal algorithms, duplicate detection, smart archiving, project scoping, temporal knowledge graph, semantic forget, agent diary, **entity bitemporal validity (η.4.4)**, **optimistic concurrency control (η.5.5.c)**, **role-based access control (η.6.1)**, **W3C Linked Data exports** (Turtle / JSON-LD / RDF/XML — η.5.4), **PII redaction on export** (η.6.3), **procedural memory (3B.4)**, **active retrieval (3B.5)**, **causal reasoning (3B.6)**, **world model (3B.7)**, **`do_not_remember` exclusions**, **decision rationale** (ADR memory + markdown dual-write), **structured project context** (facts / conventions / commands / glossary), **heuristic guidelines**, **tool affordance + ToolCallObserver pipeline** (with MCP shim), **observation dedup**, **spell correction** (memoryjs v2.1.0 — Phase 16), **n-ary event memory**, **reconstructive (Cue–Tag–Content) memory with snapshot persistence**, **relation consolidation**, **agent reflections**, and a **graph-connectivity hybrid-search channel with evidence-path explanations** (memoryjs v3.0.0 — v12.7.0) for long-term memory management.
13
13
 
14
14
  ## Table of Contents
15
15
 
@@ -21,6 +21,7 @@ An **enhanced fork** of the official [Model Context Protocol](https://modelconte
21
21
  - [Configuration](#configuration)
22
22
  - [Development](#development)
23
23
  - [Documentation](#documentation)
24
+ - [Companion Skill](#companion-skill)
24
25
  - [Contributing](#contributing)
25
26
  - [Changelog](#changelog)
26
27
  - [License](#license)
@@ -46,9 +47,10 @@ An **enhanced fork** of the official [Model Context Protocol](https://modelconte
46
47
  | **Memory Compression** | 4 | Intelligent duplicate detection and merging with similarity scoring |
47
48
  | **Advanced Search** | 7 | TF-IDF ranking, boolean queries, fuzzy matching, auto-select |
48
49
  | **Observation Normalization** | 1 | Coreference resolution and temporal anchoring |
49
- | **Tag Management** | 11 | Tags, aliases, bulk operations, importance scores |
50
+ | **Tag Management** | 6 | Tags, bulk operations, importance scores |
51
+ | **Tag Aliases** | 5 | Tag synonym/alias management |
50
52
  | **Saved Searches** | 5 | Store and execute frequent queries |
51
- | **Import/Export** | 2 | 7 export formats with brotli compression, 3 import formats |
53
+ | **Import/Export** | 2 | 7 export formats (incl. W3C Linked Data: Turtle / JSON-LD / RDF/XML) with brotli + PII redaction; 3 import formats |
52
54
  | **Graph Analytics** | 2 | Statistics, validation, integrity checks |
53
55
  | **Ref Index** | 4 | Cross-session symbolic reference registration and resolution |
54
56
  | **Artifacts** | 3 | Named versioned content blobs attached to entities |
@@ -64,6 +66,7 @@ An **enhanced fork** of the official [Model Context Protocol](https://modelconte
64
66
  | **Collaborative** | 1 | Multi-agent context synthesis |
65
67
  | **Failure Handling** | 2 | Session failure distillation and graceful session end |
66
68
  | **Cognitive Load** | 2 | Working-memory load analysis and adaptive reduction |
69
+ | **Dream Engine** | 3 | Background memory maintenance: 8-phase sleep-cycle consolidation |
67
70
  | **Project Scoping** | 1 | List and filter entities by project |
68
71
  | **Memory Versioning** | 2 | Entity version chains and per-entity version history |
69
72
  | **Semantic Forget** | 1 | Two-tier deletion: exact match → semantic similarity fallback |
@@ -71,6 +74,21 @@ An **enhanced fork** of the official [Model Context Protocol](https://modelconte
71
74
  | **Temporal KG** | 3 | Temporal relation invalidation, time-travel queries, relation timeline |
72
75
  | **Ingestion** | 1 | Format-agnostic conversation/document ingestion pipeline |
73
76
  | **Agent Diary** | 2 | Per-agent persistent journal write and read |
77
+ | **Session & Working Memory** | 9 | Session lifecycle, working memory CRUD, TTL, promotion, context wake-up *(Phase 14)* |
78
+ | **Auto-Enhancement** | 3 | Auto-link entity mentions, fact extraction, contradiction detection *(Phase 14)* |
79
+ | **Context Compression** | 1 | N-gram text abbreviation with legend for token savings *(Phase 14)* |
80
+ | **Consolidation Pipeline** | 3 | Session consolidation, pattern detection, entity summarization *(Phase 14)* |
81
+ | **Decay & Salience** | 5 | Time-based decay, importance scoring, weak memory cleanup, reinforcement *(Phase 14)* |
82
+ | **Multi-Agent** | 5 | Agent registration, cross-agent search, visibility, conflict resolution *(Phase 14)* |
83
+ | **Observability** | 4 | D3.js graph visualization, transcript splitting, query cost estimation *(Phase 14)* |
84
+ | **Dedup** | 1 | Priority-based smart deduplication *(Phase 14)* |
85
+ | **Entity Bitemporal** | 5 | Time-travel queries: invalidate entities/observations, entity_as_of, timelines *(Phase 15 / η.4.4)* |
86
+ | **Optimistic Concurrency** | 1 | `update_entity` with `expectedVersion` → `VersionConflictError` on stale *(Phase 15 / η.5.5.c)* |
87
+ | **RBAC** | 4 | Role-based access control: assign/revoke/check/list reader/writer/admin/owner permissions *(Phase 15 / η.6.1)* |
88
+ | **Procedural Memory** | 5 | Executable how-to sequences with EWMA-refined success rate *(Phase 15 / 3B.4)* |
89
+ | **Active Retrieval** | 1 | Iterative query rewriting until coverage threshold met *(Phase 15 / 3B.5)* |
90
+ | **Causal Reasoning** | 4 | Chain discovery, counterfactual queries, cycle detection *(Phase 15 / 3B.6)* |
91
+ | **World Model** | 3 | Graph snapshots, fact validation, outcome prediction *(Phase 15 / 3B.7)* |
74
92
 
75
93
  ### Comparison with Official Memory Server
76
94
 
@@ -93,8 +111,8 @@ An **enhanced fork** of the official [Model Context Protocol](https://modelconte
93
111
  | **Backup & Restore** | ❌ | ✅ Compressed snapshots |
94
112
  | **Intelligent Search** | ❌ | ✅ Hybrid + Query Analysis + Reflection |
95
113
  | **Observation Normalization** | ❌ | ✅ Coreference resolution + temporal anchoring |
96
- | **Total Tools** | 11 | **106** |
97
- | **Code Structure** | Monolithic | **Modular** (77 files) |
114
+ | **Total Tools** | 11 | **160** |
115
+ | **Code Structure** | Monolithic | **Modular** (5 src files in this repo; core graph in [`@danielsimonjr/memoryjs`](https://www.npmjs.com/package/@danielsimonjr/memoryjs)) |
98
116
 
99
117
  ## Quick Start
100
118
 
@@ -163,7 +181,7 @@ cd memory-mcp
163
181
  npm install
164
182
  npm run build
165
183
 
166
- # Run tests (2800+ tests)
184
+ # Run tests (791 tests, ~85% statement coverage)
167
185
  npm test
168
186
 
169
187
  # Type check
@@ -242,9 +260,9 @@ Discrete facts about entities. Each observation should be atomic and independent
242
260
 
243
261
  ## API Reference
244
262
 
245
- ### Complete Tool List (160 Tools)
263
+ ### Complete Tool List (241 Tools)
246
264
 
247
- > Tool count: 160 tools across 51 categories. The 23 newest tools (Phase 15 / memoryjs v1.14+) are documented at the end under **Phase 15** sections. For full per-tool schemas see [docs/architecture/API.md](docs/architecture/API.md).
265
+ > Tool count: 241 tools across 65 categories. The newest tools are documented at the end under the **Phase 15**, **Phase 16 (memoryjs v2.1.0)**, **v12.3.2 / v12.5.0**, and **v12.7.0 (memoryjs v3.0.0)** sections. For full per-tool schemas see [docs/architecture/API.md](docs/architecture/API.md) or `src/server/toolDefinitions.ts`.
248
266
 
249
267
  #### Entity Operations (4 tools)
250
268
  | Tool | Description |
@@ -545,6 +563,142 @@ Discrete facts about entities. Each observation should be atomic and independent
545
563
  - **`create_entities`** — Now accepts v1.6 freshness fields (`ttl`, `confidence`), v1.8 project scope (`projectId`), and η.4.4 bitemporal fields (`validFrom`, `validUntil`, `observationMeta`) per entity.
546
564
  - **`set_memory_visibility`** — Auto-promotes plain entities to `AgentEntity` (stamps `agentId` / `memoryType` / `confidence`) instead of silently returning `null`. Supports η.5.5.b extensions (`allowedRoles`, `visibleFrom`, `visibleUntil`).
547
565
 
566
+ #### Tool Affordance (11 tools) — Phase 16 / memoryjs v2.1.0
567
+ | Tool | Description |
568
+ |------|-------------|
569
+ | `record_tool_outcome` | Record a tool call outcome (success/failure) into affordance stats |
570
+ | `get_tool_affordance_stats` | Per-tool success-rate and usage statistics |
571
+ | `suggest_tool` | Suggest the best tool for a task based on recorded affordances |
572
+ | `list_tool_affordances` | List all recorded tool affordances |
573
+ | `remove_tool_affordance` | Remove one tool's affordance record |
574
+ | `observe_tool_start` | `ToolCallObserver` lifecycle: mark a tool call started |
575
+ | `observe_tool_complete` | Mark an observed tool call completed successfully |
576
+ | `observe_tool_error` | Mark an observed tool call failed |
577
+ | `observe_tool_partial` | Mark an observed tool call partially successful |
578
+ | `observe_tool_cancel` | Cancel an in-flight tool observation |
579
+ | `tool_observer_in_flight_count` | Count of currently in-flight observed tool calls |
580
+
581
+ #### Heuristic Guidelines (10 tools) — Phase 16 / memoryjs v2.1.0
582
+ | Tool | Description |
583
+ |------|-------------|
584
+ | `add_heuristic` | Store a heuristic guideline ("when X, prefer Y") |
585
+ | `get_heuristic` | Fetch one heuristic by id |
586
+ | `list_heuristics` | List stored heuristics |
587
+ | `heuristic_count` | Count of stored heuristics |
588
+ | `match_heuristics` | Heuristics matching a context string |
589
+ | `reinforce_heuristic` | Strengthen a heuristic after successful application |
590
+ | `record_heuristic_contradiction` | Record evidence contradicting a heuristic |
591
+ | `detect_heuristic_conflicts` | Detect mutually contradictory heuristics |
592
+ | `remove_heuristic` | Remove one heuristic |
593
+ | `clear_heuristics` | Remove all heuristics |
594
+
595
+ #### Project Context (12 tools) — Phase 16 / memoryjs v2.1.0
596
+ | Tool | Description |
597
+ |------|-------------|
598
+ | `upsert_project_context` | Create/replace a project's structured context record |
599
+ | `get_project_context` | Fetch a project's context record |
600
+ | `append_project_fact` | Append a fact to a project context |
601
+ | `append_project_convention` | Append a coding/workflow convention |
602
+ | `append_project_command` | Append a named command (e.g. build/test invocations) |
603
+ | `append_project_glossary_term` | Append a glossary term + definition |
604
+ | `remove_project_fact` | Remove a fact by index/value |
605
+ | `remove_project_convention` | Remove a convention |
606
+ | `remove_project_command` | Remove a command |
607
+ | `remove_project_glossary_term` | Remove a glossary term |
608
+ | `clear_project_context` | Delete a project's context record |
609
+ | `format_project_context_for_llm` | Render the context as LLM-ready markdown |
610
+
611
+ #### Decision Rationale (10 tools) — Phase 16 / memoryjs v2.1.0
612
+ | Tool | Description |
613
+ |------|-------------|
614
+ | `propose_decision` | Record a proposed decision with rationale |
615
+ | `accept_decision` | Mark a decision accepted |
616
+ | `reject_decision` | Mark a decision rejected |
617
+ | `supersede_decision` | Supersede a decision with a newer one |
618
+ | `find_decisions_by_context` | Decisions matching a context string |
619
+ | `get_decision_chain` | Follow a decision's supersession chain |
620
+ | `list_decisions` | List decisions (filterable by status) |
621
+ | `get_decision` | Fetch one decision by id |
622
+ | `export_decision_as_adr_markdown` | Render a decision as ADR markdown |
623
+ | `parse_adr_markdown` | Parse ADR markdown back into a decision record |
624
+
625
+ #### Exclusion / `do_not_remember` (5 tools) — Phase 16 / memoryjs v2.1.0
626
+ | Tool | Description |
627
+ |------|-------------|
628
+ | `add_exclusion_rule` | Add a rule for content that must not be remembered |
629
+ | `list_exclusion_rules` | List exclusion rules |
630
+ | `remove_exclusion_rule` | Remove one exclusion rule |
631
+ | `check_exclusion` | Check whether a text would be excluded |
632
+ | `find_matching_memories_for_rule` | Existing memories matching an exclusion rule |
633
+
634
+ #### Observation Dedup (2 tools) — Phase 16 / memoryjs v2.1.0
635
+ | Tool | Description |
636
+ |------|-------------|
637
+ | `find_duplicate_observations` | Exact duplicate observations across entities |
638
+ | `find_jaccard_duplicate_observations` | Near-duplicates via Jaccard token similarity |
639
+
640
+ #### Spell Correction (3 tools) — Phase 16 / memoryjs v2.1.0
641
+ | Tool | Description |
642
+ |------|-------------|
643
+ | `spell_suggest` | "Did you mean?" suggestions for a query term |
644
+ | `spell_rebuild_vocabulary` | Rebuild the spell-check vocabulary from the graph |
645
+ | `spell_vocabulary_size` | Current vocabulary size |
646
+
647
+ #### Active Project Scope (2 tools) — v12.3.2
648
+ | Tool | Description |
649
+ |------|-------------|
650
+ | `set_project_scope` | Set the server's active project-scope filter (per-session mutable state) |
651
+ | `get_project_scope` | Get the active project scope (`{ projectId }`, null when unscoped) |
652
+
653
+ #### Engineering / Diagnostics (10 tools) — v12.5.0
654
+ | Tool | Description |
655
+ |------|-------------|
656
+ | `diag` | Server + storage diagnostic snapshot |
657
+ | `health` | Quick health check |
658
+ | `check_graph` | Graph integrity check |
659
+ | `reindex` | Rebuild search indexes |
660
+ | `cache_stats` | Stats for the global search caches |
661
+ | `cache_clear` | Bust all global search caches |
662
+ | `graph_size` | Entity/relation/observation counts + on-disk footprint |
663
+ | `inspect_entity` | Verbose single-entity snapshot (observations, relations, hierarchy) |
664
+ | `hierarchy_tree` | Hierarchy as nested JSON |
665
+ | `entity_neighbors` | Incoming/outgoing relations + degree counts for one entity |
666
+
667
+ #### Event Memory (5 tools) — v12.7.0 / memoryjs v3.0.0
668
+ | Tool | Description |
669
+ |------|-------------|
670
+ | `record_event` | Reify an action as an event hub entity with role-typed relations (`actor_of` / `targeted` / `occurred_in` / `participant_in`) and optional `flow:<key>` grouping |
671
+ | `get_event` | Load one event with its resolved role endpoints |
672
+ | `query_events` | Query by actor / target / action / flowKey / time range, chronologically ordered |
673
+ | `get_event_flow` | Full timeline of a named flow (e.g. a release or incident) |
674
+ | `who_did_what` | "Who did what (to target / in context / within range)?" join over events |
675
+
676
+ #### Reconstructive Memory (5 tools) — v12.7.0 / memoryjs v3.0.0
677
+ | Tool | Description |
678
+ |------|-------------|
679
+ | `ingest_dialogue` | Distill dialogue turns into the Cue–Tag–Content associative graph (also persisted into the live knowledge graph) |
680
+ | `reconstruct_memory` | Answer a query via active multi-step traversal; returns evidence + trajectory |
681
+ | `reconstructive_memory_stats` | CTC graph size statistics |
682
+ | `save_reconstructive_memory` | Serialize the CTC graph to a `<basename>-reconstructive.json` sidecar |
683
+ | `load_reconstructive_memory` | Restore the CTC graph from the sidecar (survives restarts) |
684
+
685
+ #### Relation Consolidation (2 tools) — v12.7.0 / memoryjs v3.0.0
686
+ | Tool | Description |
687
+ |------|-------------|
688
+ | `analyze_relation_duplicates` | Dry-run the three-tier relation janitor: spelling variants, inverse duplicates, semantic duplicates (with embeddings) |
689
+ | `consolidate_relations` | Apply tier 1+2 merges (`apply: true`) or dry-run (default) |
690
+
691
+ #### Agent Reflection (4 tools) — v12.7.0 / memoryjs v3.0.0
692
+ | Tool | Description |
693
+ |------|-------------|
694
+ | `create_reflection` | Persist an evidence-backed generalized lesson (scope: session / project / global) |
695
+ | `list_reflections` | List reflections, filterable by scope / source / confidence |
696
+ | `get_relevant_reflections` | Reflections relevant to a session (sourceSessionId + evidence overlap) |
697
+ | `archive_reflection` | Soft-delete a reflection out of default listings |
698
+
699
+ #### v12.7.0 enhancements to existing tools
700
+ - **`hybrid_search`** — Now accepts memoryjs v3's additive options: `graphWeight` (graph-connectivity channel via normalized PageRank), `expandNeighbors` (one-hop expansion of top results with damped scores), `explain` (annotate results with evidence paths from query anchors), and `lookFor` (rank expansion neighbors by a free-text connection description).
701
+
548
702
  ## Configuration
549
703
 
550
704
  ### Environment Variables
@@ -628,7 +782,7 @@ node dist/migrate-from-jsonl-to-sqlite.js --from memory.db --to memory.jsonl
628
782
  ```bash
629
783
  npm install # Install dependencies
630
784
  npm run build # Build TypeScript
631
- npm test # Run tests (2800+ tests)
785
+ npm test # Run tests (791 tests across 36 files; ~85% coverage)
632
786
  npm run typecheck # Strict type checking
633
787
  npm run watch # Development watch mode
634
788
  npm run clean # Remove dist/ directory
@@ -637,120 +791,85 @@ npm run docs:deps # Generate dependency graph
637
791
 
638
792
  ### Architecture
639
793
 
794
+ After the **Phase 13 extraction**, this repo is a thin MCP wrapper. All graph logic, managers, and storage live in [`@danielsimonjr/memoryjs`](https://www.npmjs.com/package/@danielsimonjr/memoryjs) (currently `^3.0.0`).
795
+
640
796
  ```
641
- ┌─────────────────────────────────────────────────────┐
642
- │ Layer 1: MCP Protocol Layer │
643
- server/MCPServer.ts + toolDefinitions (160 tools)
644
- + toolHandlers + responseCompressor
645
- └──────────────────────┬──────────────────────────────┘
646
-
647
- ┌──────────────────────┴──────────────────────────────┐
648
- │ Layer 2: Managers + Context (Lazy Initialization) │
649
- │ ManagerContext (aliased as KnowledgeGraphManager)
650
- │ • EntityManager (CRUD + hierarchy + archive) │
651
- │ • RelationManager (relation CRUD) │
652
- │ • SearchManager (search + compression + stats) │
653
- │ • IOManager (import + export + backup) │
654
- │ • TagManager (tag aliases) │
655
- │ • GraphTraversal (path finding, centrality) │
656
- │ • SemanticSearch (embeddings, similarity) │
657
- └──────────────────────┬──────────────────────────────┘
658
-
659
- ┌──────────────────────┴──────────────────────────────┐
660
- │ Layer 3: Storage Layer │
661
- │ core/GraphStorage.ts (JSONL + in-memory cache) │
662
- │ core/SQLiteStorage.ts (better-sqlite3 + FTS5) │
663
- │ core/StorageFactory.ts (backend selection) │
664
- └─────────────────────────────────────────────────────┘
797
+ memory-mcp (this repo) @danielsimonjr/memoryjs (npm dep)
798
+ ┌──────────────────────────┐ ┌──────────────────────────────────┐
799
+ src/index.ts │ │ ManagerContext (lazy init)
800
+ src/server/MCPServer.ts │───────▶│ EntityManager, RelationManager
801
+ │ src/server/toolDefs.ts │imports │ SearchManager, IOManager, etc. │
802
+ src/server/toolHandlers │ │ GraphStorage / SQLiteStorage │
803
+ │ src/server/responseComp.│ │ StorageFactory + 100+ modules │
804
+ └──────────────────────────┘ └──────────────────────────────────┘
805
+ 5 source files 77+ source files (extracted)
806
+ MCP protocol + dispatch All graph + search + storage
665
807
  ```
666
808
 
809
+ | Layer | Lives in | Files |
810
+ |-------|----------|-------|
811
+ | MCP protocol (stdio transport, tool registration, dispatch) | `memory-mcp` | 5 |
812
+ | Tool schemas (241 tools across 65 categories) | `memory-mcp` (`toolDefinitions.ts`) | 1 |
813
+ | Handler registry + Zod validation + response compression | `memory-mcp` (`toolHandlers.ts` + `responseCompressor.ts`) | 2 |
814
+ | Managers (Entity / Relation / Search / IO / Tag / Hierarchy / Analytics / Compression / Archive / GraphTraversal / SemanticSearch / RankedSearch / etc.) | `memoryjs` | 100+ |
815
+ | Storage (JSONL + SQLite with FTS5 + StorageFactory + TransactionManager) | `memoryjs` | — |
816
+ | Embedding providers (OpenAI / local / none) + VectorStore | `memoryjs` | — |
817
+
667
818
  ### Project Structure
668
819
 
669
820
  ```
670
821
  memory-mcp/
671
- ├── src/ # Source (77 TypeScript files)
672
- │ ├── index.ts # Entry point
673
- ├── core/ # Core managers (12 files)
674
- ├── ManagerContext.ts # Context holder (lazy init)
675
- ├── EntityManager.ts # Entity CRUD + hierarchy
676
- ├── RelationManager.ts # Relation CRUD
677
- │ ├── GraphStorage.ts # JSONL I/O + caching
678
- │ │ ├── SQLiteStorage.ts # SQLite with better-sqlite3
679
- ├── TransactionManager.ts # ACID transactions
680
- ├── StorageFactory.ts # Storage backend factory
681
- ├── HierarchyManager.ts # Tree operations
682
- ├── ObservationManager.ts # Observation CRUD
683
- │ ├── GraphTraversal.ts # Path finding, centrality
684
- │ │ ├── GraphEventEmitter.ts # Event system
685
- │ │ └── index.ts
686
- │ ├── server/ # MCP protocol (4 files)
687
- ├── MCPServer.ts # Server setup
688
- ├── toolDefinitions.ts # 160 tool schemas
689
- ├── toolHandlers.ts # Handler registry
690
- └── responseCompressor.ts # Brotli compression
691
- ├── search/ # Search implementations (29 files)
692
- ├── SearchManager.ts # Search orchestrator
693
- ├── BasicSearch.ts # Text matching
694
- ├── RankedSearch.ts # TF-IDF scoring
695
- │ ├── BooleanSearch.ts # AND/OR/NOT logic
696
- │ │ ├── FuzzySearch.ts # Typo tolerance
697
- │ │ ├── SemanticSearch.ts # Embedding-based
698
- │ │ ├── EmbeddingService.ts # Provider abstraction
699
- │ │ ├── VectorStore.ts # Vector storage
700
- │ │ └── ... # + 12 more
701
- │ ├── features/ # Advanced capabilities (9 files)
702
- │ │ ├── IOManager.ts # Import/export/backup
703
- │ │ ├── TagManager.ts # Tag aliases
704
- │ │ ├── AnalyticsManager.ts # Graph stats
705
- │ │ ├── ArchiveManager.ts # Entity archival
706
- │ │ ├── CompressionManager.ts # Duplicate detection
707
- │ │ ├── StreamingExporter.ts # Large graph exports
708
- │ │ ├── ObservationNormalizer.ts # Coreference resolution
709
- │ │ ├── KeywordExtractor.ts # Keyword extraction
710
- │ │ └── index.ts
711
- │ ├── types/ # TypeScript definitions (2 files)
712
- │ ├── utils/ # Shared utilities (18 files)
713
- │ └── workers/ # Worker pool (2 files)
714
- ├── tests/ # Test suite (97 files, 2800+ tests)
715
- │ ├── unit/ # Unit tests
716
- │ ├── integration/ # Integration tests
717
- │ ├── e2e/ # End-to-end tests
718
- │ └── performance/ # Benchmarks
719
- ├── dist/ # Compiled output
720
- ├── docs/ # Documentation
721
- │ ├── architecture/ # Architecture docs
722
- │ ├── guides/ # User guides
723
- │ └── reports/ # Sprint reports
724
- ├── tools/ # Standalone utilities
725
- │ ├── chunking-for-files/ # File splitting
726
- │ ├── compress-for-context/ # CTON compression
727
- │ ├── create-dependency-graph/ # Dependency analyzer
728
- │ └── migrate-from-jsonl-to-sqlite/
729
- ├── CHANGELOG.md # Version history
730
- └── README.md # This file
822
+ ├── src/ # Source (5 TypeScript files)
823
+ │ ├── index.ts # Entry point: ManagerContext + start MCPServer; re-exports memoryjs types
824
+ └── server/
825
+ ├── MCPServer.ts # MCP Server setup, stdio transport, request handlers
826
+ ├── toolDefinitions.ts # 241 tool schemas (name, description, inputSchema)
827
+ ├── toolHandlers.ts # Handler registry: validate args → call manager → format response
828
+ └── responseCompressor.ts # Brotli + base64 wrapper for >256KB payloads
829
+ ├── tests/ # Test suite (36 files, 791 tests, ~85% statement coverage)
830
+ │ ├── unit/ # Unit tests (response compressor, tool defs, validate-fact handler)
831
+ │ ├── integration/ # MCP server lifecycle
832
+ │ ├── e2e/tools/ # Per-category tool tests + handler-smoke broad coverage
833
+ │ ├── knowledge-graph.test.ts # Core graph operations (smoke against memoryjs)
834
+ └── file-path.test.ts # Storage path resolution
835
+ ├── dist/ # Compiled output (rebuilt on `npm install` via `prepare`)
836
+ ├── docs/ # Documentation
837
+ │ ├── architecture/ # API.md, ARCHITECTURE.md, COMPONENTS.md, OVERVIEW.md, TEST_COVERAGE.md
838
+ │ ├── guides/ # HIERARCHY.md, COMPRESSION.md, ARCHIVING.md, QUERY_LANGUAGE.md
839
+ │ ├── development/ # WORKFLOW.md
840
+ │ ├── roadmap/ # FUTURE_FEATURES.md, PERFORMANCE_AND_CAPABILITIES.md
841
+ │ └── reports/ # Historical sprint reports
842
+ ├── tools/ # Standalone utilities (each builds independently)
843
+ │ ├── chunking-for-files/ # File splitting
844
+ │ ├── compress-for-context/ # CTON compression
845
+ │ ├── create-dependency-graph/ # Dependency analyzer
846
+ └── migrate-from-jsonl-to-sqlite/ # Storage backend converter
847
+ ├── CHANGELOG.md # Version history
848
+ └── README.md # This file
731
849
  ```
732
850
 
733
851
  ### Dependencies
734
852
 
735
- **Production:**
736
- - `@modelcontextprotocol/sdk`: ^1.21.1
737
- - `better-sqlite3`: ^11.7.0
738
- - `zod`: ^4.1.13
739
- - `async-mutex`: ^0.5.0
740
- - `@danielsimonjr/workerpool`: ^10.0.1
853
+ **Production** (3 direct deps — everything else is transitive via memoryjs):
854
+ - `@danielsimonjr/memoryjs`: ^1.15.0 — knowledge graph engine (storage, managers, search, embeddings, RBAC, OCC, bitemporal, causal, etc.)
855
+ - `@modelcontextprotocol/sdk`: ^1.21.1 — MCP protocol implementation
856
+ - `zod`: ^3.24.1 — runtime input validation (schemas re-exported from memoryjs)
741
857
 
742
858
  **Development:**
743
859
  - `typescript`: ^5.6.2
744
860
  - `vitest`: ^4.0.13
745
861
  - `@vitest/coverage-v8`: ^4.0.13
746
- - `@types/better-sqlite3`: ^7.6.12
862
+ - `shx`: ^0.4.0 — cross-platform shell commands for `clean` script
863
+ - `@types/node`: ^22
864
+
865
+ > Note: `better-sqlite3`, `async-mutex`, `@danielsimonjr/workerpool`, and the embedding providers (OpenAI / `@xenova/transformers`) are **transitive deps via `@danielsimonjr/memoryjs`** since the Phase 13 extraction. They are not listed in this repo's `package.json`.
747
866
 
748
867
  ## Documentation
749
868
 
750
869
  Comprehensive documentation in `docs/`:
751
870
 
752
871
  **Architecture**
753
- - [API.md](docs/architecture/API.md) - Complete API documentation for all 160 tools
872
+ - [API.md](docs/architecture/API.md) - Complete API documentation for all 241 tools
754
873
  - [ARCHITECTURE.md](docs/architecture/ARCHITECTURE.md) - Technical architecture and system design
755
874
  - [COMPONENTS.md](docs/architecture/COMPONENTS.md) - Component breakdown and responsibilities
756
875
  - [OVERVIEW.md](docs/architecture/OVERVIEW.md) - High-level project overview
@@ -766,6 +885,10 @@ Comprehensive documentation in `docs/`:
766
885
  - [WORKFLOW.md](docs/development/WORKFLOW.md) - Development procedures
767
886
  - [MIGRATION.md](docs/guides/MIGRATION.md) - Version upgrade guide
768
887
 
888
+ ## Companion skill
889
+
890
+ This plugin ships a `memory` skill (`memory-mcp:memory`, `/memory`) — a playbook over the knowledge-graph tools covering graph CRUD/search/maintenance, project indexing, and storage migration. See [skills/memory/SKILL.md](skills/memory/SKILL.md).
891
+
769
892
  ## Contributing
770
893
 
771
894
  We welcome contributions!
@@ -785,9 +908,16 @@ We welcome contributions!
785
908
 
786
909
  All notable changes are documented in **[CHANGELOG.md](CHANGELOG.md)**.
787
910
 
788
- **Current version**: v12.2.0 - [View full changelog](CHANGELOG.md)
911
+ **Current version**: v12.7.0 - [View full changelog](CHANGELOG.md)
789
912
 
790
913
  Recent highlights:
914
+ - **v12.7.0** (241 tools): Upgraded `@danielsimonjr/memoryjs` `^2.8.1` → `^3.0.0` and surfaced its new features as 16 tools — event memory (5), reconstructive Cue–Tag–Content memory + snapshot persistence (5), relation consolidation (2), agent reflection (4) — plus v3 graph-channel / evidence-path options on `hybrid_search`. Refactored handlers onto the new `ManagerContext` accessors (`hybridSearchManager`, `governanceManager`, `eventManager`, `reflectionManager`, `reconstructiveMemory()`, `close()`).
915
+ - **v12.5.0** (225 tools): 10 engineering / diagnostic tools mirroring the memoryjs CLI surface (`diag`, `health`, `check_graph`, `reindex`, cache stats/clear, `graph_size`, `inspect_entity`, `hierarchy_tree`, `entity_neighbors`).
916
+ - **v12.3.2** (215 tools): Backport of the deferred `set_project_scope` / `get_project_scope` pair.
917
+ - **v12.3.0** (213 tools): **Phase 16** — 53 new tools surfacing memoryjs v2.1.0 across seven new manager surfaces: `do_not_remember` exclusion rules (5), decision rationale + ADR markdown dual-write (10), structured project context (12), heuristic guidelines (10), tool affordance + `ToolCallObserver` producer pipeline (11), observation dedup (2), spell correction (3). Bumped `@danielsimonjr/memoryjs` dep `^1.15.0` → `^2.1.0`.
918
+ - **v12.2.3**: Publishability — switched `@danielsimonjr/memoryjs` dep from local `file:` link to published `^1.15.0` (npm rejects `file:` deps for published packages).
919
+ - **v12.2.2**: Doc-only — roadmap completion audit grading Phase 6-15 status against current code.
920
+ - **v12.2.1**: Doc-only — comprehensive consistency pass across 68 markdown documents to align with v12.2.0's 160-tool surface.
791
921
  - **v12.2.0** (160 tools): 23 new tools — entity bitemporal validity (η.4.4), OCC update (η.5.5.c), RBAC (η.6.1), procedural memory (3B.4), active retrieval (3B.5), causal reasoning (3B.6), world model (3B.7), plus W3C Linked Data exports (η.5.4) and PII redaction (η.6.3) wired into existing `export_graph`. Plus four pre-publish fixes from end-to-end MCP smoke testing (memoryjs v1.14+).
792
922
  - **v12.1.0** (106 tools): 12 new tools — Project Scoping, Memory Versioning, Semantic Forget, Profiles, Temporal KG, Ingestion, Agent Diary (memoryjs v1.8.0/v1.9.0)
793
923
  - **v12.0.0** (94 tools): 32 new tools — Ref Index, Artifacts, Temporal Search, Distillation, Freshness, LLM Query, Governance, Role Profiles, Entropy, Consolidation, Formatter, Collaborative, Failure Handling, Cognitive Load
@@ -820,7 +950,7 @@ Enhanced fork of [Model Context Protocol memory server](https://github.com/model
820
950
  - Multi-format import/export with merge strategies
821
951
  - SQLite backend with better-sqlite3 (3-10x faster)
822
952
  - Transaction support with ACID guarantees
823
- - Comprehensive test suite (2800+ tests, 97 test files)
953
+ - Comprehensive test suite (791 tests, 36 test files in this wrapper repo; full-coverage core graph tests live in `@danielsimonjr/memoryjs`)
824
954
 
825
955
  ---
826
956
 
package/dist/index.js CHANGED
@@ -16,6 +16,18 @@ export { ManagerContext };
16
16
  // Backward compatibility alias
17
17
  export { ManagerContext as KnowledgeGraphManager };
18
18
  let managerContext;
19
+ // Exit cleanly when our stdio pipe closes (e.g., Claude Code's /reload-plugins
20
+ // tearing down the connection). Without this, other event-loop refs — file
21
+ // watchers, the embeddings pool, the consolidation timer — can keep the
22
+ // process alive as an orphan until manually killed.
23
+ // ctx.close() (memoryjs v3) releases storage handles before exit; it is a
24
+ // no-op for JSONL but closes the SQLite handle when MEMORY_STORAGE_TYPE=sqlite.
25
+ function shutdown() {
26
+ managerContext?.close();
27
+ process.exit(0);
28
+ }
29
+ process.stdin.on("end", shutdown);
30
+ process.stdin.on("close", shutdown);
19
31
  async function main() {
20
32
  // Initialize memory file path with backward compatibility
21
33
  const memoryFilePath = await ensureMemoryFilePath();
@@ -1 +1 @@
1
- {"version":3,"file":"MCPServer.d.ts","sourceRoot":"","sources":["../../src/server/MCPServer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOtE;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;gBAEhB,GAAG,EAAE,cAAc;IAiB/B,OAAO,CAAC,oBAAoB;IAetB,KAAK;CAKZ"}
1
+ {"version":3,"file":"MCPServer.d.ts","sourceRoot":"","sources":["../../src/server/MCPServer.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AASH,OAAO,EAAU,KAAK,cAAc,EAAE,MAAM,yBAAyB,CAAC;AAOtE;;;GAGG;AACH,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,GAAG,CAAiB;IAE5B,YAAY,GAAG,EAAE,cAAc,EAe9B;IAED,OAAO,CAAC,oBAAoB;IAetB,KAAK,kBAIV;CACF"}
@@ -2,7 +2,7 @@
2
2
  * MCP Tool Definitions
3
3
  *
4
4
  * Extracted from MCPServer.ts to reduce file size and improve maintainability.
5
- * Contains all 106 tool schemas for the Knowledge Graph MCP Server.
5
+ * Contains all 241 tool schemas for the Knowledge Graph MCP Server.
6
6
  *
7
7
  * @module server/toolDefinitions
8
8
  */
@@ -1 +1 @@
1
- {"version":3,"file":"toolDefinitions.d.ts","sourceRoot":"","sources":["../../src/server/toolDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC;CACH;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,EAqlF3C,CAAC"}
1
+ {"version":3,"file":"toolDefinitions.d.ts","sourceRoot":"","sources":["../../src/server/toolDefinitions.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE;QACX,IAAI,EAAE,QAAQ,CAAC;QACf,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QACpC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;QACpB,oBAAoB,CAAC,EAAE,OAAO,CAAC;KAChC,CAAC;CACH;AAED;;;GAGG;AACH,eAAO,MAAM,eAAe,EAAE,cAAc,EAokH3C,CAAC"}