Claude Advanced Memory Engine
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., "@Claude Advanced Memory Enginesave that my preferred coding style is tabs over spaces"
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.
Claude Advanced Memory Engine
A production-grade MCP (Model Context Protocol) server that maintains structured local memory for Claude Desktop, reducing token usage by 95%+ without losing important context.
Problem: Traditional conversation summarization replays massive chat histories, wasting 80%+ of token budget.
Solution: Build structured memory once, retrieve intelligently. Never replay history.
Key Features
✅ 95%+ Token Reduction - Structured facts instead of full conversation replay ✅ Local First - Everything runs locally, no cloud, no telemetry, no data leaving your computer ✅ 4-Layer Memory - Hierarchical storage (L1: current, L2: working, L3: semantic, L4: archive) ✅ Intelligent Retrieval - Multi-factor ranking: keyword, semantic, recency, importance, frequency, relationships ✅ Auto Extraction - Automatically extracts facts, decisions, tasks, preferences from responses ✅ Deduplication - Merges equivalent facts, keeps only newest truth ✅ Smart Cleanup - Automatic garbage collection, archival, promotion to hot layers ✅ Context Budgeting - Configurable token limits (minimal/balanced/comprehensive) ✅ Performance - <20ms lookup, <50ms prompt assembly, scales to millions of records
Related MCP server: Memory MCP Server
Architecture
Claude Desktop Instance
↓ (MCP Protocol)
┌─────────────────────────────────────────┐
│ Memory Engine MCP Server │
│ │
│ ┌────────────────────────────────────┐ │
│ │ MCP Tool Layer │ │
│ │ (save, search, retrieve, optimize) │ │
│ └──────────────┬─────────────────────┘ │
│ ↓ │
│ ┌────────────────────────────────────┐ │
│ │ Prompt Builder & Optimizer │ │
│ └──────────────┬─────────────────────┘ │
│ ↓ │
│ ┌────────────────────────────────────┐ │
│ │ Intelligent Retrieval Engine │ │
│ │ (multi-factor ranking) │ │
│ └──────────────┬─────────────────────┘ │
│ ↓ │
│ ┌────────────────────────────────────┐ │
│ │ Memory Layer System (L1-L4) │ │
│ └──────────────┬─────────────────────┘ │
│ ↓ │
│ ┌────────────────────────────────────┐ │
│ │ SQLite Database (~/.cache/claude) │ │
│ └────────────────────────────────────┘ │
└─────────────────────────────────────────┘Memory Layers
Layer | Scope | TTL | Retrieval | Use Case |
L1 | Current conversation | Session | Always | Active request context |
L2 | Working memory | 24h | High | Recent tasks, active decisions |
L3 | Semantic memory | 30d | Medium | Long-term facts, patterns |
L4 | Archive | ∞ | Explicit | Historical, rarely accessed |
Installation
Prerequisites
Node.js 18+
Claude Desktop (latest)
~50MB disk space
Setup
# Clone repository
git clone https://github.com/yourusername/claude-memory-engine.git
cd claude-memory-engine
# Install dependencies
npm install
# Build TypeScript
npm run build
# Initialize database
npm run init-db
# Start MCP server
npm startConfigure Claude Desktop
Add to claude_desktop_config.json:
{
"mcpServers": {
"claude-memory": {
"command": "node",
"args": ["/path/to/claude-memory-engine/dist/index.js"],
"env": {
"CLAUDE_MEMORY_BUDGET": "2000",
"LOG_LEVEL": "info"
}
}
}
}Usage
Automatic Memory Capture
After every Claude response, the system automatically:
Extracts facts, decisions, tasks, preferences
Identifies entities and relationships
Deduplicates and merges equivalent records
Stores in appropriate memory layer
Promotes/archives based on usage
Manual Tools
/save_memory - Save facts/decisions/tasks explicitly
/search_memory - Search by keyword, entity, type
/retrieve_context - Get optimized context for request
/update_memory - Modify existing record
/delete_memory - Remove record
/optimize_prompt - Compress prompt within budget
/memory_stats - View memory metrics and recommendations
/explain_context - Show why a record was retrieved
/export_memory - Export to JSON/CSV/Markdown
/import_memory - Restore from exportConfiguration
Environment Variables
# Database location
CLAUDE_MEMORY_DB=~/.cache/claude-memory/memory.db
# Token budget (1000-∞)
CLAUDE_MEMORY_BUDGET=2000
# Enable compression
CLAUDE_MEMORY_COMPRESSION=true
# Enable deduplication
CLAUDE_MEMORY_DEDUP=true
# Enable embeddings (requires model)
CLAUDE_MEMORY_EMBEDDINGS=false
# Auto cleanup interval (ms)
CLAUDE_MEMORY_CLEANUP_INTERVAL=3600000
# Log level
LOG_LEVEL=infoPresets
// Minimal mode (1000 tokens)
CLAUDE_MEMORY_BUDGET=1000
CLAUDE_MEMORY_COMPRESSION=true
// Balanced mode (2000 tokens) - Default
CLAUDE_MEMORY_BUDGET=2000
// Comprehensive mode (4000 tokens)
CLAUDE_MEMORY_BUDGET=4000
// No limit (not recommended)
CLAUDE_MEMORY_BUDGET=-1Database Schema
Core Tables
facts - Key-value pairs linked to entities
entities - People, projects, technologies, files, code
relationships - Connections between entities
decisions - Architectural/technical decisions
tasks - Work items and todos
preferences - User/project settings
documents - Indexed files and metadata
code_index - Code symbols (functions, classes, etc.)
conversations - Message tracking for extraction status
memory_usage - Historical metrics
embeddings - Optional semantic vectors
See docs/SCHEMA.md for detailed schema reference.
Performance
Benchmarks
Operation | Target | Typical |
Memory lookup | <20ms | 8ms |
Prompt assembly | <50ms | 25ms |
Database query | <100ms | 45ms |
Deduplication | <200ms | 80ms |
Cleanup cycle | <500ms | 150ms |
Scalability
Million records: ~200ms query time with indexes
Database size: ~500MB per million facts
Memory overhead: <50MB RAM
Token Reduction Examples
Traditional approach:
User: "What was our database decision?"
Needed: Retrieve last 50 messages (~3000 tokens)
Summarize into context (~1000 tokens overhead)
Answer query (~500 tokens)
Total: ~4500 tokensMemory Engine approach:
User: "What was our database decision?"
Needed: Search "decision" entity (~50ms)
Find 2-3 relevant records (~100 tokens)
Return with relationships (~200 tokens)
Total: ~300 tokens (93% reduction)Development
Project Structure
src/
├── index.ts # MCP server entry
├── config.ts # Configuration
├── types.ts # TypeScript types
├── database/
│ ├── connection.ts # SQLite management
│ ├── schema.ts # Database schema
│ └── migrations.ts # Schema versions
├── memory/
│ ├── layers.ts # L1-L4 layer system
│ ├── retrieval.ts # Search & ranking
│ ├── extraction.ts # Fact extraction
│ └── deduplication.ts # Merging logic
├── prompt/
│ ├── builder.ts # Prompt assembly
│ ├── tokenizer.ts # Token counting
│ └── budget.ts # Budget management
├── tools/
│ ├── memory-tools.ts # CRUD operations
│ ├── retrieval-tools.ts # Context retrieval
│ └── optimization-tools.ts
└── utils/
├── logger.ts # Structured logging
├── ranking.ts # Scoring engine
├── text-processing.ts # NLP helpers
└── tokenizer.ts # Token counterRunning Tests
# All tests
npm test
# Watch mode
npm test:watch
# Coverage report
npm test:coverage
# Specific suite
npm test -- memory.test.tsBenchmarking
# Run performance benchmarks
npm run benchmark
# Profile specific operation
npm run benchmark -- --profile retrievalBuilding
# Development
npm run dev
# Production build
npm run build
# Type checking
npx tsc --noEmitAdvanced Usage
Custom Extraction Rules
import { ExtractionEngine } from './memory/extraction';
const engine = new ExtractionEngine({
minFactImportance: 5,
extractCodeReferences: true,
customPatterns: {
'technology_stack': /stack:?\s*([^,\n]+)/gi,
'api_endpoint': /endpoint:\s*([^\s]+)/gi,
}
});
const result = engine.extract(claudeResponse);Semantic Search with Embeddings
import { EmbeddingModel } from './memory/embeddings';
const embedder = new EmbeddingModel('all-MiniLM-L6-v2');
await embedder.initialize();
// Embeddings automatically generated on save
const results = await retrievalEngine.semanticSearch(
'database architecture',
{ useEmbeddings: true }
);Export/Import Memory
# Export all decisions to Markdown
curl -X POST http://localhost:3000/export \
-d '{"format": "markdown", "type": "decision"}'
# Export facts as CSV
npm run export -- --type facts --format csv --output facts.csv
# Import from backup
npm run import -- --file backup.json --strategy mergeExtensibility
Add Custom Retrievers
class DomainSpecificRetriever extends BaseRetriever {
async retrieve(query: RetrievalQuery): Promise<RetrievalResult> {
// Custom logic
}
}Add Custom Extractors
class CustomExtractor extends BaseExtractor {
extractCustomType(text: string): CustomItem[] {
// Domain-specific extraction
}
}Add Rerankers
class CrossEncoderReranker {
rerank(items: RetrievalResult[]): RetrievalResult[] {
// Use larger model for final ranking
}
}Troubleshooting
Memory growing too fast
# Analyze memory distribution
npm run analyze
# Adjust retention policy in config.ts
# Increase MEMORY_RETENTION_POLICY archiveAfterDays
# Lower minFactImportance threshold
# Manually cleanup old records
curl -X POST http://localhost:3000/cleanup --data '{"olderThanDays": 60}'Slow retrieval
# Check indexes are present
npm run analyze -- --indexes
# Consider enabling embeddings
CLAUDE_MEMORY_EMBEDDINGS=true npm start
# Reduce context budget
CLAUDE_MEMORY_BUDGET=1000 npm startHigh disk usage
# Run VACUUM
npm run analyze -- --optimize
# Export important records, delete others
npm run export -- --type decision --output decisions.jsonPerformance Tuning
For Limited Resources
# Minimize mode
CLAUDE_MEMORY_BUDGET=1000
CLAUDE_MEMORY_COMPRESSION=true
CLAUDE_MEMORY_CLEANUP_INTERVAL=7200000 # 2 hoursFor Maximum Accuracy
# Maximum mode
CLAUDE_MEMORY_BUDGET=4000
CLAUDE_MEMORY_EMBEDDINGS=true
CLAUDE_MEMORY_DEDUP=trueFuture Enhancements
Semantic embeddings with local models
Multi-user support
PostgreSQL backend option
Obsidian/Roam export plugins
Custom extraction templates
Graph visualization of relationships
Memory import from ChatGPT
Audio note support
Contributing
Contributions welcome! See CONTRIBUTING.md.
License
MIT - See LICENSE file
Support
📧 Email: support@example.com
🐛 Issues: GitHub Issues
💬 Discussions: GitHub Discussions
📖 Docs: https://claude-memory-engine.dev
Acknowledgments
Built with ❤️ for Claude Desktop users who need smarter memory management.
Inspired by:
Obsidian's note-taking system
Roam Research's bidirectional linking
RAG (Retrieval Augmented Generation) patterns
Modern database optimization techniques
Ready to 95x your Claude context efficiency? Start building smarter memory today.
git clone https://github.com/yourusername/claude-memory-engine.git
cd claude-memory-engine
npm install && npm run build && npm startThis 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.
Related MCP Servers
- Alicense-qualityDmaintenanceProvides a tiered, persistent memory architecture for Claude to automatically capture and retrieve user preferences, facts, and conversation history across sessions. It supports semantic search and seamless integration with the Claude desktop application using the Model Context Protocol.Last updatedMIT
- AlicenseBqualityBmaintenanceProvides a persistent "second brain" for Claude featuring zero-latency hot caching, semantic cold storage, and automatic pattern mining from activity logs. It enables users to store, search, and automatically extract project facts and code patterns for enhanced contextual recall.Last updated567MIT
- AlicenseBqualityCmaintenanceLocal workspace memory for Claude Desktop. Indexes documents into a vector store with hybrid search, cross-session memory, auto-learn, and knowledge graph.Last updated5815AGPL 3.0
- AlicenseAqualityBmaintenancePersistent memory for Claude Code. Automatically indexes every conversation and provides production-grade hybrid search (BM25 + vectors + reranker) via MCP tools. 100% local, zero config, zero API keys, zero invoice.Last updated16847MIT
Related MCP Connectors
Persistent context for Claude. Your AI always knows your projects and next actions across sessions.
Hosted memory for AI agents that learns and forgets — one key across Claude, Cursor & ChatGPT.
User-owned memory for AI agents, Copilot, Claude, IDEs, CLIs, and chat apps over remote MCP.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- 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/AugustianRajesh/claude-save-token'
If you have feedback or need assistance with the MCP directory API, please join our Discord server