Enhanced Memory MCP Server
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Enhanced Memory MCP Serversearch my memories for references to 'MCP' and 'RAG'"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Enhanced Memory MCP Server
A high-performance memory management system for AI agents built on the Model Context Protocol. Provides 200+ tools across compressed SQLite storage, 4-tier memory architecture, Git-like versioning, multi-strategy RAG, AGI cognitive phases, and modular tool loading with profile-based scaling.
Features
4-Tier Memory Architecture: Core, Working, Reference, and Archive tiers with automatic promotion/demotion
200+ MCP Tools: Modular registration system with profile-based loading (full vs orchestrator mode)
Advanced RAG Pipeline: 4-tier retrieval strategy — hybrid search, re-ranking, query expansion, agentic RAG, GraphRAG
Neural Memory Fabric (NMF): Letta-style memory blocks with open/edit/close semantics
Git-Like Versioning: Branch, diff, and restore memory states across sessions
Real Compression: 2.4x data reduction with zlib level 9, SHA256 checksums
AGI Cognitive Phases: Identity, temporal reasoning, emotional tagging, meta-cognition (4 phases)
Intelligent Router: Multi-provider LLM routing with uncertainty scoring
Anti-Hallucination Engine: Causal inference, strange loop detection, continuous learning
Code Execution Sandbox: RestrictedPython-based secure execution with PII tokenization
Semantic Cache: LLM reasoning result caching (30-40% hit rate in production)
Manifold Working Memory: High-dimensional working memory with trajectory compression
Triple-Signal Search: Three-way ranking combining BM25, vector similarity, and graph proximity
Entropy Scoring: Information-theoretic importance scoring for memory prioritization
Tool Usage Analytics: Track which tools are invoked to optimize profile loading
Cluster Intelligence: Multi-node coordination via cluster brain and SAFLA remote integration
Related MCP server: Engram
Performance
Based on production testing:
Write Speed: ~0.04ms per entity
Read Speed: ~0.01ms per query
Compression: 2.4x average reduction
Semantic Cache Hit Rate: 30-40%
Storage: SQLite database at
~/.claude/enhanced_memories/memory.db
Installation
Prerequisites
Python 3.11+
uv (recommended) or pip
Quick Start
git clone https://github.com/marc-shade/enhanced-memory-mcp.git
cd enhanced-memory-mcp
uv venv --python 3.11 .venv
source .venv/bin/activate
uv pip install -r requirements.txtConfigure in Claude Code
Add to your ~/.claude.json:
{
"mcpServers": {
"enhanced-memory": {
"command": "python3",
"args": ["/path/to/enhanced-memory-mcp/server.py"]
}
}
}Configure in Claude Desktop
Add to your Claude Desktop MCP configuration:
{
"mcpServers": {
"enhanced-memory": {
"command": "/path/to/enhanced-memory-mcp/.venv/bin/python3",
"args": ["/path/to/enhanced-memory-mcp/server.py"]
}
}
}Architecture
Memory Tiers
Tier | Purpose | Access Pattern |
Core | System roles, AI agent library, execution patterns | Pre-loaded on startup, sub-ms access |
Working | Active projects, current context, agent assignments | Session-scoped, frequent read/write |
Reference | Documentation, code patterns, error solutions | Full-text search, lazy loaded |
Archive | Historical data, metrics, decision logs | Maximum compression, date-partitioned |
Module Architecture
server.py # Main FastMCP entry point
├── server/ # Core server modules
│ ├── config.py # Configuration and logging
│ ├── database.py # SQLite connection management
│ ├── compression.py # zlib compression engine
│ ├── compaction.py # Entity compaction and cleanup
│ ├── integrity.py # SHA256 integrity verification
│ ├── versioning.py # Git-like memory versioning
│ └── modules.py # Profile-based module loader
├── router/ # Intelligent LLM routing
│ ├── router.py # Multi-provider router
│ ├── intelligent_router.py # Uncertainty-aware routing
│ ├── uncertainty.py # Uncertainty scoring
│ └── providers/ # Provider implementations
├── sandbox/ # Code execution sandbox
│ ├── executor.py # RestrictedPython execution
│ ├── security.py # Safety checks
│ ├── pii_tokenizer.py # PII detection and tokenization
│ ├── lazy_loader.py # Deferred module loading
│ └── tool_discovery.py # Dynamic tool discovery
├── agi/ # AGI cognitive modules (22 files)
│ ├── consolidation.py # Sleep-like memory consolidation
│ ├── metacognition.py # Self-awareness tracking
│ ├── belief_tracking.py # Probabilistic belief states
│ ├── temporal_reasoning.py # Causal chains
│ ├── emotional_memory.py # Emotional tagging
│ └── ...
├── *_tools.py (31 files) # MCP tool modules
└── test_*.py (67 files) # Test suiteRAG Strategy Pipeline
Tier | Strategy | Tools | File |
1 | Hybrid Search (BM25 + Vector) |
|
|
1 | Re-ranking (Cross-Encoder) |
|
|
2 | Query Expansion |
|
|
2 | Multi-Query RAG |
|
|
3.1 | Contextual Retrieval |
|
|
3.2 | Context-Aware Chunking |
|
|
3.3 | Hierarchical RAG |
|
|
4.1 | Agentic + Self-Reflective RAG |
|
|
4.2 | GraphRAG |
|
|
4.3 | Visual Memory |
|
|
-- | Triple-Signal Search |
|
|
-- | Semantic Cache |
|
|
-- | FACT Cache |
|
|
-- | Unified Search |
|
|
Memory Profiles
Control tool loading via the MEMORY_PROFILE environment variable:
# Full mode (default): All 200+ tools loaded
MEMORY_PROFILE=full python3 server.py
# Orchestrator mode: ~15 essential tools for coordination
MEMORY_PROFILE=orchestrator python3 server.pyOrchestrator mode loads only: nmf_tools, safla_remote_integration, fact_integration, unified_search_api, semantic_cache_tools, reasoning_bank.
Database Schema
Primary tables in ~/.claude/enhanced_memories/memory.db:
-- Core memory storage with compression and versioning
CREATE TABLE entities (
id INTEGER PRIMARY KEY,
name TEXT UNIQUE NOT NULL,
entity_type TEXT NOT NULL,
tier TEXT DEFAULT 'working',
compressed_data BLOB,
original_size INTEGER,
compressed_size INTEGER,
compression_ratio REAL,
checksum TEXT,
created_at TIMESTAMP,
accessed_at TIMESTAMP,
access_count INTEGER DEFAULT 0
);
-- Entity relationships with causal tracking
CREATE TABLE relations (
id INTEGER PRIMARY KEY,
from_entity TEXT NOT NULL,
to_entity TEXT NOT NULL,
relation_type TEXT NOT NULL,
weight REAL DEFAULT 1.0,
causal INTEGER DEFAULT 0,
created_at TIMESTAMP,
UNIQUE(from_entity, to_entity, relation_type)
);
-- Git-like version history
CREATE TABLE entity_versions (
id INTEGER PRIMARY KEY,
entity_name TEXT NOT NULL,
version INTEGER NOT NULL,
branch TEXT DEFAULT 'main',
compressed_data BLOB,
checksum TEXT,
created_at TIMESTAMP
);Additional tables: observations, entity_branches, working_memory, episodic_memory, semantic_memory, procedural_memory, visual_episodes.
API Examples
Create Entities
await create_entities({
"entities": [
{
"name": "project_alpha",
"entityType": "project",
"observations": ["Architecture uses microservices", "Deployed on Kubernetes"]
}
]
})Search Nodes
await search_nodes({
"query": "microservices architecture",
"entity_types": ["project"],
"limit": 10
})Unified Search (Intelligent Routing)
await unified_search({
"query": "How does authentication work?",
"strategy": "auto" # Automatically selects best RAG strategy
})Agentic RAG (Self-Reflective Retrieval)
await agentic_retrieve({
"query": "memory consolidation patterns",
"max_iterations": 3,
"quality_threshold": 0.7
})Neural Memory Fabric
# Open a memory block for editing
await nmf_open_block({"block_id": "working_context"})
# Edit the block
await nmf_edit_block({
"block_id": "working_context",
"content": "Current focus: implementing authentication module"
})
# Recall related memories
await nmf_recall({"query": "authentication patterns"})
# Close the block
await nmf_close_block({"block_id": "working_context"})Semantic Cache
# Cache an LLM reasoning result
await semantic_cache_store({
"query": "Explain transformer attention mechanisms",
"result": "Transformers use self-attention to...",
"ttl_hours": 24
})
# Retrieve cached result (fuzzy match)
await semantic_cache_get({
"query": "How do transformer attention heads work?"
})Memory Versioning
# Create a branch
await memory_branch({"branch_name": "experiment-v2"})
# Make changes, then diff
await memory_diff({"branch": "experiment-v2", "base": "main"})
# Revert if needed
await memory_revert({"entity_name": "project_alpha", "version": 3})Tool Modules
Core Tools (always loaded)
Module | Tools | Description |
|
| Core CRUD + versioning |
AGI Cognitive Tools
Module | Phase | Description |
| Phase 1 | Identity, action tracking, agent registry |
| Phase 2 | Temporal reasoning, sleep-like consolidation |
| Phase 3 | Emotional tagging, associative networks |
| Phase 4 | Meta-cognition, self-improvement cycles |
RAG & Search Tools
Module | Description |
| BM25 + vector hybrid search |
| Cross-encoder re-ranking (ms-marco-MiniLM) |
| LLM-powered query expansion |
| Multi-perspective query generation |
| Context-enhanced chunk retrieval |
| Multi-level document indexing |
| Autonomous self-reflective retrieval |
| Graph-enhanced search |
| Three-way ranking (BM25 + vector + graph) |
| Visual episode storage and similarity search |
Memory Management Tools
Module | Description |
| Neural Memory Fabric (Letta-style blocks) |
| 75/15 rule prioritization |
| LLM reasoning result caching |
| Fast cache-first fact retrieval |
| Intelligent search strategy routing |
| Persistent learning from reasoning outcomes |
| High-dimensional working memory |
| Memory trajectory compression |
| Information-theoretic importance scoring |
| LRU caching for hot entities |
Intelligence Tools
Module | Description |
| Hallucination detection and prevention |
| Causal relationship discovery |
| Self-referential loop detection |
| Online learning from interactions |
| Multi-provider LLM routing |
| Memory activation field dynamics |
| Procedural memory evolution |
| Learned query routing optimization |
| Surprise-based memory consolidation |
| Provenance tracking and L-Score validation |
Integration Tools
Module | Description |
| SAFLA 4-tier memory integration |
| Remote SAFLA cluster bridge |
| Multi-node cluster intelligence |
| Letta sleeptime compute integration |
| Tool invocation analytics |
Testing
# Run comprehensive test suite
python3 comprehensive_test.py
# RAG integration tests (22 tests)
python3 test_rag_integration_comprehensive.py
# Test specific subsystems
python3 test_graphrag_integration.py
python3 test_manifold_working_memory.py
python3 test_triple_signal_search.py
python3 test_surprise_consolidation.py
python3 test_trajectory_compression.py
python3 test_anti_hallucination.py
python3 test_causal_inference.py
# AGI phase tests
python3 test_agi_phase1.py
python3 test_agi_phase2.py
python3 test_agi_phase3.py
python3 test_agi_phase4.py
# Code execution sandbox
python3 test_advanced_tool_use.pyAdding New Tools
Create
{feature}_tools.pywith the registration pattern:
def register_{feature}_tools(app, *args):
@app.tool()
async def my_new_tool(param: str) -> str:
"""Tool description shown in MCP."""
return resultRegister in
server/modules.py:
if should_load_module("{feature}_tools"):
try:
from {feature}_tools import register_{feature}_tools
register_{feature}_tools(app)
except Exception as e:
logger.warning(f"{feature} integration skipped: {e}")Add to
tool_catalog.pyfor progressive tool discovery.Write tests in
test_{feature}.py.
Environment Variables
Variable | Default | Description |
|
| Tool loading profile ( |
|
| Enable tool invocation analytics |
|
| Root path for agentic system |
|
| Ollama server for LLM operations |
|
| Qdrant vector database host |
|
| Qdrant vector database port |
| -- | For contextual prefix generation |
| -- | For query expansion (optional) |
Dependencies
Key dependencies (see requirements.txt for full list):
fastmcp— MCP protocol implementationsentence-transformers— Cross-encoder re-ranking (ms-marco-MiniLM-L-6-v2)qdrant-client— Hybrid search with BM25 + vectorRestrictedPython— Secure sandbox code executionanthropic— Claude API for contextual retrievalnumpy— Vector operations and entropy scoring
License
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/marc-shade/enhanced-memory-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server