Memory MCP Server
An enhanced fork of the official Model Context Protocol memory server with advanced features for hierarchical nesting, intelligent compression, archiving, advanced search, and multi-format import/export.
Enterprise-grade knowledge graph with 45 tools, hierarchical organization, duplicate detection, smart archiving, and sophisticated search capabilities for long-term memory management.
Table of Contents
Features
Core Memory Capabilities
Knowledge Graph Storage: Entity-Relation-Observation model for structured memory
Persistent Memory: Information persists across chat sessions with JSONL storage
Full CRUD Operations: Create, read, update, delete entities and relations
Flexible Search: Text-based, fuzzy, boolean, and TF-IDF ranked search
Advanced Features
Hierarchical Nesting: Parent-child relationships for organizing tree structures (8 tools)
Memory Compression: Intelligent duplicate detection and merging with similarity scoring (3 tools)
Smart Archiving: Criteria-based archiving by age, importance, or tags (1 tool)
Advanced Search: TF-IDF ranking, boolean queries, fuzzy matching (3 tools)
Import/Export: 7 formats (JSON, CSV, GraphML, GEXF, DOT, Markdown, Mermaid)
Tag Management: Aliases, bulk operations, and validation (11 tools)
Saved Searches: Store and execute frequent queries (5 tools)
Graph Validation: Integrity checks and orphan detection (1 tool)
Data Management
Automatic Timestamps:
createdAtandlastModifiedfields with smart updatesDate Range Search: Filter entities/relations by creation or modification date
Graph Statistics: Comprehensive analytics with counts, types, and temporal data
Tags System: Categorize entities with case-insensitive tags and aliases
Importance Levels: 0-10 scale for entity prioritization
Advanced Filtering: Combine text, tags, importance, and date ranges
Comparison with Official Memory Server
Feature | Official | Enhanced (This Fork) |
Entity Management | ✅ | ✅ |
Relation Management | ✅ | ✅ |
Observation Tracking | ✅ | ✅ |
Basic Search | ✅ | ✅ |
Hierarchical Nesting | ❌ | ✅ Parent-child trees |
Memory Compression | ❌ | ✅ Duplicate detection (50x faster) |
Smart Archiving | ❌ | ✅ Criteria-based |
Advanced Search | ❌ | ✅ TF-IDF + Boolean |
Fuzzy Search | ❌ | ✅ Typo-tolerant |
Saved Searches | ❌ | ✅ Store queries |
Tag Aliases | ❌ | ✅ Synonyms |
Graph Validation | ❌ | ✅ Integrity checks |
Timestamps | ❌ | ✅ createdAt + lastModified |
Importance Levels | ❌ | ✅ 0-10 scale |
Export Formats | ❌ | ✅ 7 formats |
Import | ❌ | ✅ 3 formats + merge |
Input Validation | ❌ | ✅ Zod schemas (14 validators) |
Caching Layer | ❌ | ✅ In-memory (instant reads) |
Backup & Restore | ❌ | ✅ Point-in-time recovery |
Transactions | ❌ | ✅ ACID guarantees |
Security | Basic | ✅ Input validation |
Reliability | Basic | ✅ Backups & Transactions |
Performance | Basic | ✅ Caching & Optimizations |
Total Tools | 11 | 45 (+309%) |
Code Structure | Monolithic | Modular (40+ files) |
Key Features
Production-Ready Enterprise Capabilities
🔐 Security & Data Integrity
Input Validation: Zod-based schemas validate all inputs, preventing malformed data and injection attacks
Transaction Support: ACID-compliant transactions with automatic rollback on failures
Backup & Restore: Point-in-time recovery with timestamped backups and metadata
Data Protection: Comprehensive validation with size limits, range checks, and format enforcement
⚡ Performance Optimizations
Smart Caching: In-memory cache with write-through invalidation for instant reads
Optimized Algorithms: 50x faster duplicate detection using two-level bucketing (O(n²) → O(n·k))
Efficient Storage: JSONL format with modular architecture for better tree-shaking
🏗️ Architecture
Modular Design: Clean separation of concerns across 40+ focused modules
Type Safety: Full TypeScript strict mode with comprehensive type definitions
Dependency Injection: Flexible, testable design with clear module boundaries
Developer Experience: Barrel exports, JSDoc documentation, and comprehensive test coverage
Quick Start
1. Install from NPM (Recommended)
Or use with npx (no installation required):
2. Configure Claude Desktop
Add to claude_desktop_config.json:
Using NPM Global Install:
Using NPX:
3. Restart Claude Desktop
Restart Claude Desktop to load the enhanced memory server.
4. Start Using
Tell Claude:
Claude will automatically use the enhanced tools!
Installation
Local Build (Recommended)
Claude Desktop Configuration
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
Replace <PATH_TO> with your actual paths.
VS Code
Add to .vscode/mcp.json:
Core Concepts
Entities
Primary nodes in the knowledge graph.
Fields:
name(string): Unique identifierentityType(string): Classificationobservations(string[]): Facts about the entityparentId(string, optional): Parent entity name for hierarchical nestingcreatedAt(string, optional): ISO 8601 timestamplastModified(string, optional): ISO 8601 timestamptags(string[], optional): Lowercase tags for categorizationimportance(number, optional): 0-10 scale for prioritization
Example:
Relations
Directed connections between entities.
Fields:
from(string): Source entity nameto(string): Target entity namerelationType(string): Relationship typecreatedAt(string, optional): ISO 8601 timestamplastModified(string, optional): ISO 8601 timestamp
Example:
Observations
Discrete facts about entities.
Principles:
One fact per observation
Atomic information
Independently manageable
API Reference
Complete Tool List (45 Tools)
Core Entity & Relation Management (9 tools)
create_entities- Create multiple new entitiescreate_relations- Create multiple new relationsadd_observations- Add observations to entitiesdelete_entities- Remove entities and their relationsdelete_observations- Remove specific observationsdelete_relations- Remove specific relationsread_graph- Read entire knowledge graphsearch_nodes- Search for nodes by queryopen_nodes- Retrieve specific nodes by name
Hierarchical Nesting (8 tools)
set_entity_parent- Set or remove parent relationshipget_children- Get immediate childrenget_parent- Get parent entityget_ancestors- Get all ancestors (parent chain)get_descendants- Get all descendants (recursive)get_subtree- Get entity + descendants with relationsget_root_entities- Get all entities with no parentget_entity_depth- Get depth in hierarchy (0 = root)
Memory Compression (3 tools)
find_duplicates- Find similar entities by thresholdmerge_entities- Merge multiple entities into onecompress_graph- Automated compression with dry-run
Memory Archiving (1 tool)
archive_entities- Archive by age, importance, or tags
Advanced Search (3 tools)
search_nodes_ranked- TF-IDF relevance rankingboolean_search- Boolean queries (AND/OR/NOT)fuzzy_search- Typo-tolerant search
Search Management (6 tools)
save_search- Save search querylist_saved_searches- List all saved searchesget_saved_search- Get saved search detailsexecute_saved_search- Execute saved searchdelete_saved_search- Delete saved searchupdate_saved_search- Update saved searchget_search_suggestions- Get "Did you mean?" suggestions
Tag Management (8 tools)
add_tags- Add tags to entityremove_tags- Remove tags from entityadd_tags_to_multiple- Add tags to multiple entitiesreplace_tag- Replace tag globallymerge_tags- Merge two tags into oneadd_tag_alias- Create tag synonymlist_tag_aliases- List all tag aliasesget_aliases_for_tag- Get aliases for tagremove_tag_alias- Remove tag aliasresolve_tag- Resolve alias to canonical form
Graph Analytics & Validation (3 tools)
get_graph_stats- Get comprehensive graph statisticssearch_by_date_range- Filter by date rangevalidate_graph- Validate graph integrityset_importance- Set entity importance (0-10)
Import & Export (2 tools)
export_graph- Export in 7 formatsimport_graph- Import from JSON/CSV/GraphML
Detailed API Documentation
Create multiple new entities in the knowledge graph.
Input:
Returns: Array of created entities with timestamps
Example:
Create multiple new relations between entities.
Input:
Returns: Array of created relations with timestamps
Example:
Add new observations to existing entities.
Input:
Returns: Array with added observations per entity
Example:
Remove entities and all their relations from the graph.
Input:
Returns: Confirmation
Note: Cascade deletes all relations to/from these entities.
Remove specific observations from entities.
Input:
Returns: Confirmation
Remove specific relations from the graph.
Input:
Returns: Confirmation
Read the entire knowledge graph (all entities and relations).
Input: None
Returns: Complete knowledge graph
Search for nodes by query string with optional filters.
Input:
Returns: Matching entities and their relations
Example:
Retrieve specific nodes by exact name match.
Input:
Returns: Requested entities and relations between them
Example:
Set or remove parent-child relationship for hierarchical nesting.
Input:
Returns: Updated entity
Features:
Automatic cycle detection
Updates lastModified timestamp
Example:
Get immediate children of an entity.
Input:
Returns: Array of child entities
Example:
Get parent entity (or null if root).
Input:
Returns: Parent entity or null
Get all ancestors (parent chain to root).
Input:
Returns: Array of ancestors (closest to furthest)
Example: Task → Feature → Project → Root
Get all descendants recursively (BFS traversal).
Input:
Returns: Array of all descendant entities
Get entity + all descendants with their relations.
Input:
Returns: Subtree (entities + relations)
Use cases: Export branches, analyze sections, filter by scope
Get all entities with no parent (top-level entities).
Input: None
Returns: Array of root entities
Get depth in hierarchy (0 = root, 1 = child of root, etc.).
Input:
Returns:
Find similar entities using multi-factor similarity scoring.
Input:
Returns: Array of duplicate entity name groups
Algorithm:
Name similarity: 40% (Levenshtein distance)
Type match: 20% (exact match)
Observation overlap: 30% (Jaccard similarity)
Tag overlap: 10% (Jaccard similarity)
Example:
Merge multiple entities into one target entity.
Input:
Returns: Merged entity
Merge behavior:
Combines unique observations and tags
Keeps highest importance
Redirects all relations to target
Preserves earliest createdAt
Example:
Automated duplicate detection and merging.
Input:
Returns: Compression statistics
Example:
Archive entities based on criteria (OR logic).
Input:
Second parameter: dryRun (boolean, default false)
Returns:
Criteria (OR logic): Archive if ANY criterion matches
Example:
Full-text search with TF-IDF relevance ranking.
Input:
Returns: Ranked results with scores
Example:
Advanced boolean queries with logical operators.
Input:
Operators:
AND,OR,NOT,()Field-specific:
name:,type:,observation:,tag:Quoted strings:
"exact phrase"
Example:
Typo-tolerant search using Levenshtein distance.
Input:
Returns: Matching entities (sorted by similarity)
Example:
Save a search query for reuse.
Input:
Returns: Saved search object
List all saved searches.
Input: None
Returns: Array of saved searches with metadata
Get details of a saved search.
Input:
Returns: Saved search object
Execute a saved search (updates usage count).
Input:
Returns: Search results
Delete a saved search.
Input:
Returns: Confirmation
Update a saved search.
Input:
Returns: Updated saved search
Get "Did you mean?" suggestions for typos.
Input:
Returns: Array of suggestions with scores
Add tags to an entity (normalized to lowercase).
Input:
Returns: Entity with added tags
Remove tags from an entity.
Input:
Returns: Entity with remaining tags
Add tags to multiple entities at once (bulk operation).
Input:
Returns: Array of results per entity
Replace a tag globally across all entities.
Input:
Returns: Count of entities updated
Merge two tags into one (all entities with tag1 get tag2).
Input:
Returns: Count of entities updated
Create a tag synonym (alias → canonical).
Input:
Example: "ai" → "artificial-intelligence"
Returns: Tag alias object
List all tag aliases.
Input: None
Returns: Array of tag aliases
Get all aliases for a canonical tag.
Input:
Returns: Array of aliases
Remove a tag alias.
Input:
Returns: Confirmation
Resolve an alias to its canonical form.
Input:
Returns: Canonical tag name (or original if no alias)
Get comprehensive graph statistics.
Input: None
Returns:
Filter entities and relations by date range.
Input:
Returns: Filtered knowledge graph
Example:
Validate graph integrity and detect issues.
Input: None
Returns:
Checks:
Orphaned relations
Duplicate entities
Invalid data
Isolated entities (warning)
Empty observations (warning)
Set importance level for an entity (0-10).
Input:
Returns: Updated entity
Scale:
9-10: Critical
7-8: High
5-6: Medium
3-4: Low
0-2: Minimal
Export knowledge graph in multiple formats.
Input:
Formats:
JSON: Pretty-printed with all data
CSV: Entities + relations sections
GraphML: XML for Gephi, Cytoscape, yEd
GEXF: Gephi native format
DOT: GraphViz for publication
Markdown: Human-readable documentation
Mermaid: Embedded diagrams
Example:
Import knowledge graph from JSON, CSV, or GraphML.
Input:
Merge strategies:
replace: Overwrite existing entities
skip: Keep existing, skip imports
merge: Combine observations/tags
fail: Error on conflicts
Returns: Import statistics
Data Model
Entity Schema
Relation Schema
Storage Files
The server automatically creates and manages these files:
memory.jsonl: Main knowledge graph storage (entities and relations)memory-saved-searches.jsonl: Saved search queries with metadatamemory-tag-aliases.jsonl: Tag synonym mappings (alias → canonical).backups/: Backup directory with timestamped snapshots
All files use JSONL (JSON Lines) format where each line is a valid JSON object.
Custom path: Set MEMORY_FILE_PATH environment variable (see Configuration)
Usage Examples
Example 1: Hierarchical Project Structure
Example 2: Duplicate Detection and Merging
Example 3: Smart Archiving
Example 4: Advanced Search
Example 5: Tag Management
Comprehensive Guides
Detailed documentation for advanced features:
HIERARCHY_GUIDE.md - Complete guide to parent-child relationships (8 tools)
COMPRESSION_GUIDE.md - Intelligent duplicate detection and merging (3 tools)
ARCHIVING_GUIDE.md - Memory lifecycle and long-term storage (1 tool)
QUERY_LANGUAGE.md - Boolean search syntax reference
MIGRATION_GUIDE.md - Upgrade guide from v0.7.0 to v0.8.0
CHANGELOG.md - Complete version history and release notes
Configuration
Environment Variables
MEMORY_FILE_PATH: Path to the main memory storage fileDefault:
memory.jsonlin the current working directoryFormat: JSONL (JSON Lines) format
Sets the location for the primary knowledge graph storage
Storage File Organization
When you set MEMORY_FILE_PATH, the server automatically creates related files in the same directory:
Note: All auxiliary files use the same base filename as MEMORY_FILE_PATH with descriptive suffixes.
Example Configuration
Claude Desktop (
Default behavior (no environment variable):
Creates memory.jsonl in the current working directory.
Development
Prerequisites
Node.js 18+
npm 9+
TypeScript 5.6+
Build
Test
Project Structure
Scripts
Contributing
We welcome contributions!
See:
CONTRIBUTING.md - Contribution guidelines
IMPROVEMENT_PLAN.md - Feature roadmap
CODE_OF_CONDUCT.md - Community standards
Ways to Help:
🐛 Report bugs
✨ Request features
🔧 Submit pull requests
📚 Improve documentation
🧪 Add tests
🌍 Translate guides
Changelog
All notable changes to this project are documented in CHANGELOG.md.
The changelog follows Keep a Changelog format and tracks:
Added: New features and capabilities
Changed: Changes to existing functionality
Deprecated: Soon-to-be removed features
Removed: Removed features
Fixed: Bug fixes
Security: Security improvements
Current version: v0.11.6 - View full changelog →
License
MIT License - see LICENSE
You are free to use, modify, and distribute this software.
Acknowledgments
Original Project
Enhanced fork of Model Context Protocol memory server by Anthropic.
Original License: MIT
Enhancements
Developer: Daniel Simon Jr.
Major Features Added:
Hierarchical nesting with parent-child relationships
Memory compression with intelligent duplicate detection
Smart archiving with criteria-based filtering
Advanced search: TF-IDF, boolean, and fuzzy matching
Multi-format import/export with merge strategies
Enhanced tag management with aliases and bulk operations
Saved searches with usage tracking
Graph validation and integrity checks
Transaction support with ACID guarantees
Backup and restore capabilities
Input validation and security hardening
Performance optimizations and caching
Comprehensive documentation and guides
Community
Thanks to:
📚 MCP community and contributors
Technologies: Vitest, TypeScript, Node.js
Repository: https://github.com/danielsimonjr/memory-mcp Issues: https://github.com/danielsimonjr/memory-mcp/issues NPM: https://www.npmjs.com/package/@danielsimonjr/memory-mcp
Made with ❤️ for the MCP community