Elasticsearch Memory MCP
Provides persistent, intelligent memory using Elasticsearch with hierarchical categorization and semantic search for LLM contexts.
README
🧠 Elasticsearch Memory MCP
A powerful Model Context Protocol (MCP) server that provides persistent, intelligent memory using Elasticsearch with hierarchical categorization and semantic search capabilities.
✨ Features
🎯 V6.2 - Latest Release
-
🏷️ Hierarchical Memory Categorization
- 5 category types:
identity,active_context,active_project,technical_knowledge,archived - Automatic category detection with confidence scoring
- Manual reclassification support
- 5 category types:
-
🤖 Intelligent Auto-Detection
- Accumulative scoring system (0.7-0.95 confidence range)
- 23+ specialized keyword patterns
- Context-aware categorization
-
📦 Batch Review System
- Review uncategorized memories in batches
- Approve/reject/reclassify workflows
- 10x faster than individual categorization
-
🔄 Backward Compatible Fallback
- Seamlessly loads v5 uncategorized memories
- No data loss during upgrades
- Graceful degradation
-
🚀 Optimized Context Loading
- Hierarchical priority loading (~30-40 memories vs 117)
- 60-70% token reduction
- Smart relevance ranking
-
💾 Persistent Memory
- Vector embeddings for semantic search
- Session management with checkpoints
- Conversation snapshots
🛠️ Installation
Quick Start (Recommended)
Install directly from PyPI:
pip install elasticsearch-memory-mcp
Prerequisites
- Python 3.8+
- Elasticsearch 8.0+
Step 1: Start Elasticsearch
# Using Docker (recommended)
docker run -d -p 9200:9200 -e "discovery.type=single-node" elasticsearch:8.0.0
# Or install locally
# https://www.elastic.co/guide/en/elasticsearch/reference/current/install-elasticsearch.html
Step 2: Configure MCP
For Claude Desktop
Add to ~/.config/Claude/claude_desktop_config.json:
{
"mcpServers": {
"elasticsearch-memory": {
"command": "uvx",
"args": ["elasticsearch-memory-mcp"],
"env": {
"ELASTICSEARCH_URL": "http://localhost:9200"
}
}
}
}
Note: If you don't have
uvx, install withpip install uvxor usepython -m elasticsearch_memory_mcpinstead.
For Claude Code CLI
claude mcp add elasticsearch-memory uvx elasticsearch-memory-mcp \
-e ELASTICSEARCH_URL=http://localhost:9200
Alternative: Install from Source
If you want to contribute or modify the code:
# Clone repository
git clone https://github.com/fredac100/elasticsearch-memory-mcp.git
cd elasticsearch-memory-mcp
# Create virtual environment
python3 -m venv venv
source venv/bin/activate
# Install in development mode
pip install -e .
Then configure MCP pointing to your local installation:
{
"mcpServers": {
"elasticsearch-memory": {
"command": "/path/to/venv/bin/python",
"args": ["-m", "mcp_server"],
"env": {
"ELASTICSEARCH_URL": "http://localhost:9200"
}
}
}
}
📚 Usage
Available Tools
1. save_memory
Save a new memory with automatic categorization.
{
"content": "Fred prefers direct, brutal communication style",
"type": "user_profile",
"importance": 9,
"tags": ["communication", "preference"]
}
2. load_initial_context (Resource)
Loads hierarchical context with:
- Identity memories (who you are)
- Active context (current work)
- Active projects (ongoing)
- Technical knowledge (relevant facts)
3. review_uncategorized_batch 🆕 V6.2
Review uncategorized memories in batches.
{
"batch_size": 10,
"min_confidence": 0.6
}
Returns suggestions with auto-detected categories and confidence scores.
4. apply_batch_categorization 🆕 V6.2
Apply categorizations in batch after review.
{
"approve": ["id1", "id2"], // Auto-categorize
"reject": ["id3"], // Skip
"reclassify": {"id4": "archived"} // Force category
}
5. search_memory
Semantic search with filters.
{
"query": "SAE project details",
"limit": 5,
"category": "active_project"
}
6. auto_categorize_memories
Batch auto-categorize uncategorized memories.
{
"max_to_process": 50,
"min_confidence": 0.75
}
🏗️ Architecture
┌─────────────────┐
│ Claude (MCP) │
└────────┬────────┘
│
▼
┌─────────────────────────────┐
│ MCP Server (v6.2) │
│ ┌─────────────────────┐ │
│ │ Auto-Detection │ │
│ │ - Keyword matching │ │
│ │ - Confidence score │ │
│ └─────────────────────┘ │
│ │
│ ┌─────────────────────┐ │
│ │ Batch Review │ │
│ │ - Review workflow │ │
│ │ - Bulk operations │ │
│ └─────────────────────┘ │
└──────────┬──────────────────┘
│
▼
┌──────────────────────────────┐
│ Elasticsearch │
│ ┌────────────────────────┐ │
│ │ memories (index) │ │
│ │ - embeddings (vector) │ │
│ │ - memory_category │ │
│ │ - category_confidence │ │
│ └────────────────────────┘ │
└──────────────────────────────┘
📊 Category System
| Category | Description | Examples |
|---|---|---|
| identity | Core identity, values, preferences | "Fred prefers brutal honesty" |
| active_context | Current work, recent conversations | "Working on SAE implementation" |
| active_project | Ongoing projects | "Mirror architecture design" |
| technical_knowledge | Facts, configs, tools | "Elasticsearch index settings" |
| archived | Completed, deprecated, old migrations | "Refactored old auth system" |
🎯 Auto-Detection Examples
High Confidence (0.8-0.95)
"Fred prefere comunicação brutal" → identity (0.9)
"Refatoração do sistema SAE concluída" → archived (0.85)
"Próximos passos: implementar dashboard" → active_context (0.8)
Multiple Keywords (Accumulative Scoring)
"Fred prefere comunicação brutal. Primeira vez usando este estilo."
→ Match 1: "Fred prefere" (+0.9)
→ Match 2: "primeira vez" (+0.8)
→ Total: 0.95 (normalized)
🔄 Migration from V5
The v6.2 system includes automatic fallback for v5 memories:
- Uncategorized memories → Loaded via type/tags fallback
- Visual separation → Categorized vs. fallback sections
- Batch review → Categorize old memories efficiently
# Review and categorize v5 memories
review_uncategorized_batch(batch_size=20)
apply_batch_categorization(approve=[...])
🚀 Performance
- Load initial context: ~10-15s (includes embedding model load)
- Save memory: <1s
- Search: <500ms
- Batch review (10 items): ~2s
- Auto-categorize (50 items): ~5s
🧪 Testing
# Run quick test
python test_quick.py
# Expected output:
# ✅ Elasticsearch connected
# ✅ Context loaded
# ✅ Identity memories found
# ✅ Projects separated from fallback
📝 Changelog
V6.2 (Latest)
- ✅ Improved auto-detection (0.4 → 0.9 confidence)
- ✅ 23 new specialized keywords
- ✅ Batch review tools (review_uncategorized_batch, apply_batch_categorization)
- ✅ Visual separation (categorized vs fallback)
- ✅ Accumulative confidence scoring
V6.1
- ✅ Fallback mechanism for uncategorized memories
- ✅ Backward compatibility with v5
V6.0
- ✅ Memory categorization system
- ✅ Hierarchical context loading
- ✅ Auto-detection with confidence
🤝 Contributing
Contributions are welcome! Please:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
📄 License
This project is licensed under the MIT License - see the LICENSE file for details.
🙏 Acknowledgments
- Built with Model Context Protocol (MCP)
- Powered by Elasticsearch
- Embeddings by Sentence Transformers
📞 Support
- Issues: GitHub Issues
- Discussions: GitHub Discussions
Made with ❤️ for the Claude ecosystem
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。