An enhanced fork of the official Model Context Protocol memory server. The fork adds hierarchical nesting, intelligent compression, semantic search, graph algorithms, archiving, advanced search, and multi-format import/export.
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, optimistic concurrency control, role-based access control, W3C Linked Data exports (Turtle / JSON-LD / RDF/XML), PII redaction on export, procedural memory, active retrieval, causal reasoning, world model, 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, 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 for long-term memory management.
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
bun install
bun run build
# Run tests
bun run test
# Type check
bun run typecheck
Claude Desktop Configuration
Add to ~/Library/Application Support/Claude/claude_desktop_config.json (Mac) or %APPDATA%\Claude\claude_desktop_config.json (Windows):
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 (241 Tools)
Tool count: 241 tools across 65 categories. The sections Extended Tools and Hybrid Search Options list the options that existing tools accept. For full per-tool schemas see docs/architecture/API.md or src/server/toolDefinitions.ts.
List entities that have exceeded their staleness threshold
get_expired_entities
List entities past their explicit expiry date
refresh_entity
Reset the freshness timestamp on an entity
freshness_report
Generate a full freshness report across the graph
LLM Query (1 tool)
Tool
Description
query_natural_language
Answer natural-language questions over the knowledge graph
Governance (4 tools)
Tool
Description
governance_transaction
Execute a governed, audited graph transaction
audit_query
Query the audit log with filters
audit_history
Retrieve full audit history for an entity
rollback_operation
Roll back a previously recorded operation
Role Profiles (2 tools)
Tool
Description
set_agent_role
Assign a role profile to the current agent context
list_role_profiles
List all available agent role profiles
Entropy (2 tools)
Tool
Description
enable_entropy_filter
Enable entropy-based noise filtering for search results
compute_entropy
Compute information-density entropy score for an entity
Consolidation (3 tools)
Tool
Description
start_consolidation
Start the background memory consolidation service
stop_consolidation
Stop the background memory consolidation service
run_consolidation_now
Trigger an immediate consolidation pass
Formatter (1 tool)
Tool
Description
format_with_salience_budget
Format context output respecting a token salience budget
Collaborative (1 tool)
Tool
Description
synthesize_collaborative_context
Synthesize a unified context view from multiple agent memory spaces
Failure Handling (2 tools)
Tool
Description
distill_failure
Distill and store key observations from a failed session
end_session
Gracefully end a session and persist in-flight state
Cognitive Load (2 tools)
Tool
Description
analyze_cognitive_load
Analyze working-memory load in the current context
adaptive_reduce_memories
Adaptively reduce memory set to fit cognitive load target
Project Scoping (1 tool)
Tool
Description
list_projects
List all project IDs present in the graph and filter entities by project
Memory Versioning (2 tools)
Tool
Description
get_entity_versions
Retrieve all versions of a versioned entity by name
get_version_chain
Get the full version chain from root to latest for an entity
Semantic Forget (1 tool)
Tool
Description
forget_memory
Delete an entity by exact name, falling back to semantic similarity if no exact match found
Profiles (2 tools)
Tool
Description
get_profile
Retrieve a user or agent profile entity
update_profile
Update observations and metadata on a profile entity
Temporal KG (3 tools)
Tool
Description
invalidate_relation
Mark a relation as ended by setting its temporal validity end date
query_as_of
Retrieve all relations for an entity that were valid at a given point in time
timeline
Return a chronological list of relation events for an entity
Ingestion (1 tool)
Tool
Description
ingest
Ingest a conversation, document, or free-form text into the knowledge graph
Agent Diary (2 tools)
Tool
Description
diary_write
Append an entry to the agent's persistent diary
diary_read
Read diary entries for an agent, optionally filtered by date range
Entity Bitemporal Validity (5 tools)
Tool
Description
invalidate_entity
Stamp validUntil on an entity (idempotent; entity remains queryable for past timestamps via entity_as_of)
entity_as_of
Time-travel query: returns entity state at a given ISO 8601 timestamp, or null if invalidated then
entity_timeline
All temporal versions of an entity in chronological order; integrates the supersession chain
invalidate_observation
Per-observation invalidation via parallel observationMeta[] entry on the entity
observations_as_of
Filter observations valid at a given timestamp; observations without meta are treated as unbounded
Optimistic Concurrency Control (1 tool)
Tool
Description
update_entity
Update an entity with optional expectedVersion; throws VersionConflictError on stale version. OCC-guarded writes auto-increment version. Omit expectedVersion for legacy last-write-wins.
RBAC (4 tools)
Tool
Description
rbac_assign_role
Grant reader / writer / admin / owner (or custom) role to an agent; optional resourceType, scope prefix, validFrom / validUntil window
rbac_revoke_role
Remove a specific role assignment matched by agentId + role + resourceType
rbac_check_permission
Check whether an agent can perform read / write / delete / manage on a resource type; falls back to defaultRole=reader for unassigned agents
rbac_list_assignments
List all role assignments for an agent; optional activeOnly filter
Procedural Memory (5 tools)
Tool
Description
add_procedure
Persist an executable how-to sequence: 1-indexed steps with optional fallback chains and free-form trigger phrases
get_procedure
Load a procedure by id
match_procedure
Token-overlap match a context description against stored procedures; returns ranked Jaccard-like scores
refine_procedure
Apply caller feedback after execution; updates successRate via EWMA (α=0.2)
get_procedure_step
Load step by 1-indexed order, or get the next step relative to currentOrder
Active Retrieval (1 tool)
Tool
Description
adaptive_retrieve
Iterative query-rewriting retrieval (search → score coverage → rewrite); up to 3 rounds, and it stops early when the coverage reaches 0.6. Pure symbolic — no LLM provider required.
Causal Reasoning (4 tools)
Tool
Description
find_causes
Causal chains ending at the named effect; sorted by product-of-edge causalStrength
find_effects
Symmetric counterpart starting at the named cause
counterfactual_query
"If we remove edge (removeFrom → removeTo), is predict still reachable from seed?" Returns surviving chains. Pure: does not mutate the graph.
detect_causal_cycles
Detect cycles in the causal subgraph rooted at seed
World Model (3 tools)
Tool
Description
get_world_state
Capture a fresh snapshot of the live graph (capped at 1000 entities; over-cap prefers high-importance)
validate_fact_against_world
Validate a candidate observation against a target entity via MemoryValidator.validateConsistency. Returns {result: null, reason: 'embedding_provider_unavailable'} when the local embedding provider is selected without @xenova/transformers installed.
predict_outcome
Predict downstream effects of an action by walking the causal subgraph (delegates to find_effects)
Extended Tools
export_graph — Accepts format: 'turtle' | 'rdf-xml' | 'json-ld' for W3C Linked Data exports. Accepts redactPii: true to scrub PII (email / SSN / credit-card / phone / IPv4) from observations with the PiiRedactor.
create_entities — Accepts freshness fields (ttl, confidence), project scope (projectId), and bitemporal fields (validFrom, validUntil, observationMeta) per entity.
set_memory_visibility — Auto-promotes plain entities to AgentEntity (stamps agentId / memoryType / confidence) instead of silently returning null. Supports a time window and a role gate (allowedRoles, visibleFrom, visibleUntil).
Tool Affordance (11 tools)
Tool
Description
record_tool_outcome
Record a tool call outcome (success/failure) into affordance stats
get_tool_affordance_stats
Per-tool success-rate and usage statistics
suggest_tool
Suggest the best tool for a task based on recorded affordances
list_tool_affordances
List all recorded tool affordances
remove_tool_affordance
Remove one tool's affordance record
observe_tool_start
ToolCallObserver lifecycle: mark a tool call started
observe_tool_complete
Mark an observed tool call completed successfully
observe_tool_error
Mark an observed tool call failed
observe_tool_partial
Mark an observed tool call partially successful
observe_tool_cancel
Cancel an in-flight tool observation
tool_observer_in_flight_count
Count of currently in-flight observed tool calls
Heuristic Guidelines (10 tools)
Tool
Description
add_heuristic
Store a heuristic guideline ("when X, prefer Y")
get_heuristic
Fetch one heuristic by id
list_heuristics
List stored heuristics
heuristic_count
Count of stored heuristics
match_heuristics
Heuristics matching a context string
reinforce_heuristic
Strengthen a heuristic after successful application
record_heuristic_contradiction
Record evidence contradicting a heuristic
detect_heuristic_conflicts
Detect mutually contradictory heuristics
remove_heuristic
Remove one heuristic
clear_heuristics
Remove all heuristics
Project Context (12 tools)
Tool
Description
upsert_project_context
Create/replace a project's structured context record
get_project_context
Fetch a project's context record
append_project_fact
Append a fact to a project context
append_project_convention
Append a coding/workflow convention
append_project_command
Append a named command (e.g. build/test invocations)
append_project_glossary_term
Append a glossary term + definition
remove_project_fact
Remove a fact by index/value
remove_project_convention
Remove a convention
remove_project_command
Remove a command
remove_project_glossary_term
Remove a glossary term
clear_project_context
Delete a project's context record
format_project_context_for_llm
Render the context as LLM-ready markdown
Decision Rationale (10 tools)
Tool
Description
propose_decision
Record a proposed decision with rationale
accept_decision
Mark a decision accepted
reject_decision
Mark a decision rejected
supersede_decision
Supersede a decision with a newer one
find_decisions_by_context
Decisions matching a context string
get_decision_chain
Follow a decision's supersession chain
list_decisions
List decisions (filterable by status)
get_decision
Fetch one decision by id
export_decision_as_adr_markdown
Render a decision as ADR markdown
parse_adr_markdown
Parse ADR markdown back into a decision record
Exclusion / do_not_remember (5 tools)
Tool
Description
add_exclusion_rule
Add a rule for content that must not be remembered
list_exclusion_rules
List exclusion rules
remove_exclusion_rule
Remove one exclusion rule
check_exclusion
Check whether a text would be excluded
find_matching_memories_for_rule
Existing memories matching an exclusion rule
Observation Dedup (2 tools)
Tool
Description
find_duplicate_observations
Exact duplicate observations across entities
find_jaccard_duplicate_observations
Near-duplicates via Jaccard token similarity
Spell Correction (3 tools)
Tool
Description
spell_suggest
"Did you mean?" suggestions for a query term
spell_rebuild_vocabulary
Rebuild the spell-check vocabulary from the graph
spell_vocabulary_size
Current vocabulary size
Active Project Scope (2 tools)
Tool
Description
set_project_scope
Set the server's active project-scope filter (per-session mutable state)
get_project_scope
Get the active project scope ({ projectId }, null when unscoped)
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
Bun 1.4+ (install + scripts; bun.lock is authoritative)
Node.js 22+ (shipped runtime — CI smokes dist/ under Node)
TypeScript 7+
Build Commands
bun install # Install dependencies
bun run build # Build TypeScript
bun run test # Run tests
bun run typecheck # Strict type checking
bun run watch # Development watch mode
bun run clean # Remove dist/ directory
bun run docs:deps # Generate dependency graph
Architecture
This repo is a thin MCP wrapper. All graph logic, managers, and storage live in @danielsimonjr/memoryjs. The version range is in package.json.
@modelcontextprotocol/server: ^2.0.0 — MCP protocol implementation (Server and the stdio transport)
zod: ^4.6.5 — runtime input validation (schemas re-exported from memoryjs)
Development:
typescript: ^7.0.2
typescript6: npm:typescript@6.0.3 — the createProgram API for the API.md Returns gate (version 7 of typescript has none)
vitest: ^5.0.5
@vitest/coverage-v8: ^5.0.5
esbuild: ^0.28.2 — builds the plugin bundle (scripts/build-bundle.mjs)
shx: ^0.4.0 — cross-platform shell commands for clean script
@types/node: ^26
Note: better-sqlite3, async-mutex, @danielsimonjr/workerpool, and the embedding providers (OpenAI / @xenova/transformers) are transitive deps via @danielsimonjr/memoryjs. They are not listed in this repo's package.json.
Documentation
Comprehensive documentation in docs/:
Architecture
API.md - Complete API documentation for all 241 tools
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.