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 47 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 (9 tools)
Memory Compression: Intelligent duplicate detection and merging with similarity scoring (4 tools)
Advanced Search: TF-IDF ranking, boolean queries, fuzzy matching, date range search (6 tools)
Import/Export: 7 export formats (JSON, CSV, GraphML, GEXF, DOT, Markdown, Mermaid), 3 import formats
Tag Management: Tags, aliases, bulk operations, importance scores (11 tools)
Saved Searches: Store and execute frequent queries (5 tools)
Graph Analytics: Statistics, validation, integrity checks (2 tools)
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 | 47 (+327%) |
Code Structure | Monolithic | Modular (54 files, ~10.7K lines) |
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 (47 Tools)
Entity Operations (4 tools)
create_entities- Create multiple new entitiesdelete_entities- Remove entities and their relationsread_graph- Read entire knowledge graphopen_nodes- Retrieve specific nodes by name
Relation Operations (2 tools)
create_relations- Create multiple new relationsdelete_relations- Remove specific relations
Observation Management (2 tools)
add_observations- Add observations to entitiesdelete_observations- Remove specific observations
Search (6 tools)
search_nodes- Search for nodes by query with filterssearch_by_date_range- Filter by date rangesearch_nodes_ranked- TF-IDF relevance rankingboolean_search- Boolean queries (AND/OR/NOT)fuzzy_search- Typo-tolerant searchget_search_suggestions- Get "Did you mean?" suggestions
Saved Searches (5 tools)
save_search- Save search querylist_saved_searches- List all saved searchesexecute_saved_search- Execute saved searchdelete_saved_search- Delete saved searchupdate_saved_search- Update saved search
Tag Management (6 tools)
add_tags- Add tags to entityremove_tags- Remove tags from entityset_importance- Set entity importance (0-10)add_tags_to_multiple_entities- Add tags to multiple entitiesreplace_tag- Replace tag globallymerge_tags- Merge two tags into one
Tag Aliases (5 tools)
add_tag_alias- Create tag synonymlist_tag_aliases- List all tag aliasesremove_tag_alias- Remove tag aliasget_aliases_for_tag- Get aliases for tagresolve_tag- Resolve alias to canonical form
Hierarchical Nesting (9 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)move_entity- Move entity to new parent
Graph Analytics (2 tools)
get_graph_stats- Get comprehensive graph statisticsvalidate_graph- Validate graph integrity
Compression & Archiving (4 tools)
find_duplicates- Find similar entities by thresholdmerge_entities- Merge multiple entities into onecompress_graph- Automated compression with dry-runarchive_entities- Archive by age, importance, or tags
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:
Move an entity to a new parent (shorthand for set_entity_parent).
Input:
Returns: Updated entity
Features:
Automatic cycle detection
Updates lastModified timestamp
Find similar entities using multi-factor similarity scoring.
Input:
Returns: Array of duplicate entity name groups
Algorithm:
Name similarity: 40% (Levenshtein distance)
Type match: 30% (exact match)
Observation overlap: 20% (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
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:
Validate graph integrity and detect issues.
Input: None
Returns:
Checks:
Orphaned relations
Duplicate entities
Invalid data
Isolated entities (warning)
Empty observations (warning)
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
Documentation
📚 Complete Documentation
Comprehensive documentation organized by category:
Core Documentation
API Reference - Complete API documentation for all 47 tools
Architecture - Technical architecture and system design
Dependency Graph - Module dependencies and structure
Workflow - Development workflow and procedures
User Guides
Hierarchy Guide - Parent-child relationships (9 tools)
Compression Guide - Duplicate detection and merging (4 tools)
Archiving Guide - Memory lifecycle and archiving
Query Language - Boolean search syntax reference
Migration Guide - Version upgrade guide
Project Information
Changelog - Version history and release notes
Sprint Progress - Development progress tracking
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
Architecture Overview
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.48.0 - 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