MCP Hub
Back to servers

memory-mcp

An enterprise-grade knowledge graph memory server featuring hierarchical nesting, semantic search with embeddings, and advanced graph algorithms. It provides a robust dual-storage backend (JSONL/SQLite) for persistent, structured long-term memory management.

Stars
1
Tools
55
Updated
Jan 8, 2026
Validated
Jan 9, 2026

Memory MCP Server

Version NPM License MCP TypeScript Coverage

An enhanced fork of the official Model Context Protocol memory server with advanced features for hierarchical nesting, intelligent compression, semantic search, graph algorithms, archiving, advanced search, and multi-format import/export.

Enterprise-grade knowledge graph with 55 tools, hierarchical organization, semantic search with embeddings, graph traversal algorithms, duplicate detection, smart archiving, and sophisticated search capabilities for long-term memory management.

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 or SQLite storage
  • Dual Storage Backends: JSONL (human-readable) or SQLite with better-sqlite3 (3-10x faster, FTS5 search)
  • Full CRUD Operations: Create, read, update, delete entities and relations
  • Flexible Search: Text-based, fuzzy, boolean, semantic, and TF-IDF ranked search

Advanced Features

CategoryToolsDescription
Hierarchical Nesting9Parent-child relationships for organizing tree structures
Graph Algorithms4Path finding, connected components, centrality metrics
Semantic Search3Embedding-based similarity search with OpenAI or local models
Memory Compression4Intelligent duplicate detection and merging with similarity scoring
Advanced Search7TF-IDF ranking, boolean queries, fuzzy matching, auto-select
Tag Management11Tags, aliases, bulk operations, importance scores
Saved Searches5Store and execute frequent queries
Import/Export27 export formats with brotli compression, 3 import formats
Graph Analytics2Statistics, validation, integrity checks

Comparison with Official Memory Server

FeatureOfficialEnhanced (This Fork)
Entity/Relation/Observation Management
Basic Search
Hierarchical Nesting✅ Parent-child trees
Graph Algorithms✅ Path finding, centrality
Semantic Search✅ Embedding-based similarity
Memory Compression✅ Duplicate detection
Brotli Compression✅ Backups, exports, responses
Smart Archiving✅ Criteria-based
Advanced Search✅ TF-IDF + Boolean + Fuzzy
SQLite Backend✅ better-sqlite3 (3-10x faster)
Full-Text Search✅ FTS5 with BM25 ranking
Timestamps✅ createdAt + lastModified
Import/Export Formats✅ 7 export / 3 import
Input Validation✅ Zod schemas
Backup & Restore✅ Compressed snapshots
Total Tools1155
Code StructureMonolithicModular (58 files)

Quick Start

1. Install from NPM

npm install -g @danielsimonjr/memory-mcp

Or use with npx (no installation required):

npx @danielsimonjr/memory-mcp

2. Configure Claude Desktop

Add to claude_desktop_config.json:

Using NPM Global Install:

{
  "mcpServers": {
    "memory": {
      "command": "mcp-server-memory"
    }
  }
}

Using NPX:

{
  "mcpServers": {
    "memory": {
      "command": "npx",
      "args": ["-y", "@danielsimonjr/memory-mcp"]
    }
  }
}

3. Restart Claude Desktop

Restart Claude Desktop to load the enhanced memory server.

4. Start Using

Tell Claude:

Please remember that I prefer TypeScript over JavaScript.
Tag this as "preferences" with importance 8.
Create a parent entity called "Development Preferences" and nest this under it.

Installation

Local Build

# Clone repository
git clone https://github.com/danielsimonjr/memory-mcp.git
cd memory-mcp

# Install and build
npm install
npm run build

# Run tests (2535 tests, 96.6% coverage)
npm test

# Type check
npm run typecheck

Claude Desktop Configuration

Add to ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows):

{
  "mcpServers": {
    "memory": {
      "command": "node",
      "args": ["<PATH_TO>/memory-mcp/dist/index.js"],
      "env": {
        "MEMORY_FILE_PATH": "<PATH_TO>/memory.jsonl"
      }
    }
  }
}

VS Code

Add to .vscode/mcp.json:

{
  "servers": {
    "memory": {
      "command": "node",
      "args": ["/path/to/memory-mcp/dist/index.js"]
    }
  }
}

Core Concepts

Entities

Primary nodes in the knowledge graph.

interface Entity {
  name: string;           // Unique identifier
  entityType: string;     // Classification
  observations: string[]; // Facts about the entity
  parentId?: string;      // Parent entity name for hierarchical nesting
  tags?: string[];        // Lowercase tags for categorization
  importance?: number;    // 0-10 scale for prioritization
  createdAt?: string;     // ISO 8601 timestamp
  lastModified?: string;  // ISO 8601 timestamp
}

Relations

Directed connections between entities.

interface Relation {
  from: string;           // Source entity name
  to: string;             // Target entity name
  relationType: string;   // Relationship type (active voice)
  createdAt?: string;     // ISO 8601 timestamp
  lastModified?: string;  // ISO 8601 timestamp
}

Observations

Discrete facts about entities. Each observation should be atomic and independently manageable.

API Reference

Complete Tool List (55 Tools)

Entity Operations (4 tools)

ToolDescription
create_entitiesCreate multiple new entities
delete_entitiesRemove entities and their relations
read_graphRead entire knowledge graph
open_nodesRetrieve specific nodes by name

Relation Operations (2 tools)

ToolDescription
create_relationsCreate relations between entities
delete_relationsRemove specific relations

Observation Management (2 tools)

ToolDescription
add_observationsAdd observations to entities
delete_observationsRemove specific observations

Search (7 tools)

ToolDescription
search_nodesSearch with filters (tags, importance)
search_by_date_rangeFilter by date range
search_nodes_rankedTF-IDF relevance ranking
boolean_searchBoolean queries (AND/OR/NOT)
fuzzy_searchTypo-tolerant search
get_search_suggestions"Did you mean?" suggestions
search_autoAuto-select best search method

Semantic Search (3 tools)

ToolDescription
semantic_searchSearch by semantic similarity using embeddings
find_similar_entitiesFind entities similar to a reference entity
index_embeddingsBuild or rebuild the semantic search index

Saved Searches (5 tools)

ToolDescription
save_searchSave search query for reuse
execute_saved_searchExecute a saved search
list_saved_searchesList all saved searches
delete_saved_searchDelete a saved search
update_saved_searchUpdate saved search parameters

Tag Management (6 tools)

ToolDescription
add_tagsAdd tags to an entity
remove_tagsRemove tags from an entity
set_importanceSet entity importance (0-10)
add_tags_to_multiple_entitiesBulk tag operation
replace_tagReplace tag globally
merge_tagsMerge two tags into one

Tag Aliases (5 tools)

ToolDescription
add_tag_aliasCreate tag synonym
list_tag_aliasesList all aliases
remove_tag_aliasRemove an alias
get_aliases_for_tagGet aliases for canonical tag
resolve_tagResolve alias to canonical form

Hierarchical Nesting (9 tools)

ToolDescription
set_entity_parentSet/remove parent relationship
get_childrenGet immediate children
get_parentGet parent entity
get_ancestorsGet all ancestors (parent chain)
get_descendantsGet all descendants (recursive)
get_subtreeGet entity + descendants with relations
get_root_entitiesGet entities with no parent
get_entity_depthGet depth in hierarchy
move_entityMove entity to new parent

Graph Algorithms (4 tools)

ToolDescription
find_shortest_pathShortest path between entities (BFS)
find_all_pathsAll paths with max depth limit
get_connected_componentsDetect isolated subgraphs
get_centralityCalculate centrality metrics (degree, betweenness, PageRank)

Graph Analytics (2 tools)

ToolDescription
get_graph_statsComprehensive graph statistics
validate_graphValidate graph integrity

Compression & Archiving (4 tools)

ToolDescription
find_duplicatesFind similar entities by threshold
merge_entitiesMerge multiple entities into one
compress_graphAuto compression with dry-run
archive_entitiesArchive by age, importance, or tags

Import & Export (2 tools)

ToolDescription
export_graphExport in 7 formats (JSON, CSV, GraphML, GEXF, DOT, Markdown, Mermaid) with compression
import_graphImport from JSON/CSV/GraphML with merge strategies

Configuration

Environment Variables

VariableDescriptionDefault
MEMORY_FILE_PATHPath to storage filememory.jsonl (current directory)
MEMORY_STORAGE_TYPEStorage backend: jsonl or sqlitejsonl
MEMORY_EMBEDDING_PROVIDEREmbedding provider: openai, local, or nonenone
MEMORY_OPENAI_API_KEYOpenAI API key (required if provider is openai)-
MEMORY_EMBEDDING_MODELEmbedding model to usetext-embedding-3-small (OpenAI) / Xenova/all-MiniLM-L6-v2 (local)
MEMORY_AUTO_INDEX_EMBEDDINGSAuto-index entities on creationfalse

Storage Backends

FeatureJSONL (Default)SQLite (better-sqlite3)
FormatHuman-readable textNative binary database
TransactionsBasicFull ACID with WAL mode
Full-Text SearchBasicFTS5 with BM25 ranking
PerformanceGood3-10x faster
ConcurrencySingle-threadedThread-safe with async-mutex
Best ForSmall graphs, debuggingLarge graphs (10k+ entities)

Using SQLite:

{
  "mcpServers": {
    "memory": {
      "command": "node",
      "args": ["/path/to/memory-mcp/dist/index.js"],
      "env": {
        "MEMORY_STORAGE_TYPE": "sqlite",
        "MEMORY_FILE_PATH": "/path/to/data/memory.db"
      }
    }
  }
}

Storage Files

When you set MEMORY_FILE_PATH, the server automatically creates related files:

/your/data/directory/
├── memory.jsonl                    # Main knowledge graph
├── memory-saved-searches.jsonl     # Saved search queries
├── memory-tag-aliases.jsonl        # Tag synonym mappings
└── .backups/                       # Timestamped backups
    ├── backup_2026-01-08_10-30-00-123.jsonl
    └── backup_2026-01-08_10-30-00-123.jsonl.meta.json

Migration Tool

Convert between JSONL and SQLite formats:

cd tools/migrate-from-jsonl-to-sqlite
npm install && npm run build

# JSONL to SQLite
node dist/migrate-from-jsonl-to-sqlite.js --from memory.jsonl --to memory.db

# SQLite to JSONL
node dist/migrate-from-jsonl-to-sqlite.js --from memory.db --to memory.jsonl

Development

Prerequisites

  • Node.js 18+
  • npm 9+
  • TypeScript 5.6+

Build Commands

npm install           # Install dependencies
npm run build         # Build TypeScript
npm test              # Run tests (2535 tests, 96.6% coverage)
npm run typecheck     # Strict type checking
npm run watch         # Development watch mode
npm run clean         # Remove dist/ directory
npm run docs:deps     # Generate dependency graph

Architecture

┌─────────────────────────────────────────────────────┐
│  Layer 1: MCP Protocol Layer                        │
│  server/MCPServer.ts + toolDefinitions (55 tools)   │
│  + toolHandlers + responseCompressor                │
└──────────────────────┬──────────────────────────────┘
                       │
┌──────────────────────┴──────────────────────────────┐
│  Layer 2: Managers + Context (Lazy Initialization)  │
│  ManagerContext (aliased as KnowledgeGraphManager)  │
│  • EntityManager   (CRUD + hierarchy + archive)     │
│  • RelationManager (relation CRUD)                  │
│  • SearchManager   (search + compression + stats)   │
│  • IOManager       (import + export + backup)       │
│  • TagManager      (tag aliases)                    │
│  • GraphTraversal  (path finding, centrality)       │
│  • SemanticSearch  (embeddings, similarity)         │
└──────────────────────┬──────────────────────────────┘
                       │
┌──────────────────────┴──────────────────────────────┐
│  Layer 3: Storage Layer                             │
│  core/GraphStorage.ts (JSONL + in-memory cache)     │
│  core/SQLiteStorage.ts (better-sqlite3 + FTS5)      │
│  core/StorageFactory.ts (backend selection)         │
└─────────────────────────────────────────────────────┘

Project Structure

memory-mcp/
├── src/                            # Source (58 TypeScript files)
│   ├── index.ts                    # Entry point
│   ├── core/                       # Core managers (12 files)
│   │   ├── ManagerContext.ts           # Context holder (lazy init)
│   │   ├── EntityManager.ts            # Entity CRUD + hierarchy
│   │   ├── RelationManager.ts          # Relation CRUD
│   │   ├── GraphStorage.ts             # JSONL I/O + caching
│   │   ├── SQLiteStorage.ts            # SQLite with better-sqlite3
│   │   ├── TransactionManager.ts       # ACID transactions
│   │   ├── StorageFactory.ts           # Storage backend factory
│   │   ├── HierarchyManager.ts         # Tree operations
│   │   ├── ObservationManager.ts       # Observation CRUD
│   │   ├── GraphTraversal.ts           # Path finding, centrality
│   │   ├── GraphEventEmitter.ts        # Event system
│   │   └── index.ts
│   ├── server/                     # MCP protocol (4 files)
│   │   ├── MCPServer.ts                # Server setup
│   │   ├── toolDefinitions.ts          # 55 tool schemas
│   │   ├── toolHandlers.ts             # Handler registry
│   │   └── responseCompressor.ts       # Brotli compression
│   ├── search/                     # Search implementations (15 files)
│   │   ├── SearchManager.ts            # Search orchestrator
│   │   ├── BasicSearch.ts              # Text matching
│   │   ├── RankedSearch.ts             # TF-IDF scoring
│   │   ├── BooleanSearch.ts            # AND/OR/NOT logic
│   │   ├── FuzzySearch.ts              # Typo tolerance
│   │   ├── SemanticSearch.ts           # Embedding-based
│   │   ├── EmbeddingService.ts         # Provider abstraction
│   │   ├── VectorStore.ts              # Vector storage
│   │   └── ...                         # + 7 more
│   ├── features/                   # Advanced capabilities (7 files)
│   │   ├── IOManager.ts                # Import/export/backup
│   │   ├── TagManager.ts               # Tag aliases
│   │   ├── AnalyticsManager.ts         # Graph stats
│   │   ├── ArchiveManager.ts           # Entity archival
│   │   ├── CompressionManager.ts       # Duplicate detection
│   │   ├── StreamingExporter.ts        # Large graph exports
│   │   └── index.ts
│   ├── types/                      # TypeScript definitions (2 files)
│   ├── utils/                      # Shared utilities (15 files)
│   └── workers/                    # Worker pool (2 files)
├── tests/                          # Test suite (74 files, 2535 tests)
│   ├── unit/                       # Unit tests
│   ├── integration/                # Integration tests
│   ├── e2e/                        # End-to-end tests
│   └── performance/                # Benchmarks
├── dist/                           # Compiled output
├── docs/                           # Documentation
│   ├── architecture/               # Architecture docs
│   ├── guides/                     # User guides
│   └── reports/                    # Sprint reports
├── tools/                          # Standalone utilities
│   ├── chunking-for-files/         # File splitting
│   ├── compress-for-context/       # CTON compression
│   ├── create-dependency-graph/    # Dependency analyzer
│   └── migrate-from-jsonl-to-sqlite/
├── CHANGELOG.md                    # Version history
└── README.md                       # This file

Dependencies

Production:

  • @modelcontextprotocol/sdk: ^1.21.1
  • better-sqlite3: ^11.7.0
  • zod: ^4.1.13
  • async-mutex: ^0.5.0
  • @danielsimonjr/workerpool: ^10.0.1

Development:

  • typescript: ^5.6.2
  • vitest: ^4.0.13
  • @vitest/coverage-v8: ^4.0.13
  • @types/better-sqlite3: ^7.6.12

Documentation

Comprehensive documentation in docs/:

Architecture

User Guides

Development

Contributing

We welcome contributions!

See:

Ways to Help:

  • Report bugs
  • Request features
  • Submit pull requests
  • Improve documentation
  • Add tests

Changelog

All notable changes are documented in CHANGELOG.md.

Current version: v9.8.3 - View full changelog

Recent highlights:

  • v9.8.3: SQLite storage support fix, JSON-RPC communication fix
  • v9.8.2: Security hardening (22 vulnerabilities fixed)
  • v9.8.1: Architecture documentation overhaul

License

MIT License - see LICENSE

Acknowledgments

Original Project

Enhanced fork of Model Context Protocol memory server by Anthropic.

Developer

Daniel Simon Jr.

Major Enhancements

  • Hierarchical nesting with parent-child relationships
  • Graph algorithms: path finding, centrality, connected components
  • Semantic search with embedding-based similarity
  • Brotli compression for backups, exports, and responses
  • 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
  • SQLite backend with better-sqlite3 (3-10x faster)
  • Transaction support with ACID guarantees
  • Comprehensive test suite (2535 tests, 96.6% coverage)

Repository: https://github.com/danielsimonjr/memory-mcp NPM: https://www.npmjs.com/package/@danielsimonjr/memory-mcp Issues: https://github.com/danielsimonjr/memory-mcp/issues

Reviews

No reviews yet

Sign in to write a review