Skip to main content

๐Ÿง  Elasticsearch-powered MCP server with hierarchical memory categorization, intelligent auto-detection, and batch review capabilities

Project description

๐Ÿง  Elasticsearch Memory MCP

MCP License: MIT

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
  • ๐Ÿค– 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

Prerequisites

  • Python 3.8+
  • Elasticsearch 8.0+
  • Git

Step 1: Clone the Repository

git clone https://github.com/fredac100/elasticsearch-memory-mcp.git
cd elasticsearch-memory-mcp

Step 2: Install Dependencies

# Create virtual environment
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate

# Install requirements
pip install -r requirements.txt

Step 3: Start Elasticsearch

# Using Docker
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 4: Configure MCP

For Claude Desktop

Add to ~/.config/Claude/claude_desktop_config.json:

{
  "mcpServers": {
    "elasticsearch-memory": {
      "command": "/path/to/elasticsearch-memory-mcp/venv/bin/python",
      "args": [
        "/path/to/elasticsearch-memory-mcp/mcp_server.py"
      ],
      "env": {
        "ELASTICSEARCH_URL": "http://localhost:9200"
      }
    }
  }
}

For Claude Code CLI

claude mcp add elasticsearch-memory "/path/to/venv/bin/python /path/to/mcp_server.py" \
  -e 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:

  1. Uncategorized memories โ†’ Loaded via type/tags fallback
  2. Visual separation โ†’ Categorized vs. fallback sections
  3. 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:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

๐Ÿ“ž Support


Made with โค๏ธ for the Claude ecosystem

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

elasticsearch_memory_mcp-6.2.0.tar.gz (35.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

elasticsearch_memory_mcp-6.2.0-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

Details for the file elasticsearch_memory_mcp-6.2.0.tar.gz.

File metadata

File hashes

Hashes for elasticsearch_memory_mcp-6.2.0.tar.gz
Algorithm Hash digest
SHA256 1ae9ae6746d2abf12ce0a6361e7ab607e0c0dba1546dc278d2f91152d9ad01e9
MD5 43c95e58c42b454ecfe3cbb17ab6d766
BLAKE2b-256 959d4bd58fa68cd9ccfdec6fbf0e08347592fc179a6a0ad3423b2b34f9e519c6

See more details on using hashes here.

File details

Details for the file elasticsearch_memory_mcp-6.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for elasticsearch_memory_mcp-6.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cd3165642a907873b5d2475bf0a60d6e38888b8272c8b03663f430fc6e590ecf
MD5 2ad7412496bbd3c3eb367b30b4bb0d83
BLAKE2b-256 24bbd2ae52c934652a12ecfc08df1de1ed6435f278496633acc7d81f31689c4c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page