
Elasticsearch Knowledge Graph for MCP
A powerful MCP memory using a knowledge graph powered by elastic search - j3k0/mcp-elastic-memory
README
Elasticsearch Knowledge Graph for MCP
A scalable knowledge graph implementation for Model Context Protocol (MCP) using Elasticsearch as the backend. This implementation is designed to replace the previous JSON file-based approach with a more scalable, performant solution.
Key Features
- Scalable Storage: Elasticsearch provides distributed, scalable storage for knowledge graph entities and relations
- Advanced Search: Full-text search with fuzzy matching and relevancy ranking
- Memory-like Behavior: Tracks access patterns to prioritize recently viewed and important entities
- Import/Export Tools: Easy migration from existing JSON-based knowledge graphs
- Rich Query API: Advanced querying capabilities not possible with the previous implementation
- Admin Tools: Management CLI for inspecting and maintaining the knowledge graph
- Complete CRUD Operations: Full create, read, update, and delete capabilities for entities and relations
- Elasticsearch Query Support: Native support for Elasticsearch query DSL for advanced search capabilities
- Multi-Zone Architecture: Separate memory zones for organizing domain-specific knowledge
- Cross-Zone Relations: Relations between entities in different memory zones
Architecture
The knowledge graph system consists of:
- Elasticsearch Cluster: Core data store for entities and relations
- Knowledge Graph Library: TypeScript interface to Elasticsearch with all core operations
- MCP Server: Protocol-compliant server for AI models to interact with the knowledge graph
- Admin CLI: Command-line tools for maintenance and management
- Import/Export Tools: Utilities for data migration and backup
- Multiple Memory Zones: Ability to partition knowledge into separate zones/indices
Getting Started
Prerequisites
- Node.js 18+
- Docker and Docker Compose
Installation
-
Clone the repository:
git clone https://github.com/mcp-servers/mcp-servers.git cd mcp-servers/memory
-
Install dependencies:
-
Start the Elasticsearch cluster:
-
Build the project:
Migration from JSON
If you have an existing JSON-based knowledge graph, you can import it:
node dist/admin-cli.js init node dist/admin-cli.js import memory.json
Running the MCP Server
Start the MCP server that connects to Elasticsearch:
Configuration
The system can be configured via environment variables:
ES_NODE
: Elasticsearch node URL (default:http://localhost:9200
)ES_USERNAME
: Elasticsearch username (if authentication is enabled)ES_PASSWORD
: Elasticsearch password (if authentication is enabled)MEMORY_FILE_PATH
: Path to memory JSON file (for import/export)KG_DEFAULT_ZONE
: Default memory zone to use (default:default
)KG_INDEX_PREFIX
: Prefix for Elasticsearch indices (default:knowledge-graph
)
Admin CLI Commands
The admin CLI provides tools for managing the knowledge graph:
Initialize Elasticsearch index
node dist/admin-cli.js init
Import data from JSON file to a specific zone
node dist/admin-cli.js import memory.json [zone]
Export data from a specific zone to JSON file
node dist/admin-cli.js export backup.json [zone]
Backup all zones and relations
node dist/admin-cli.js backup full-backup.json
Restore from a full backup
node dist/admin-cli.js restore full-backup.json [--yes]
Show statistics about all zones or a specific zone
node dist/admin-cli.js stats [zone]
Search the knowledge graph with optional zone parameter
node dist/admin-cli.js search "search query" [zone]
Show details about a specific entity
node dist/admin-cli.js entity "John Smith" [zone]
Show relations for a specific entity
node dist/admin-cli.js relations "John Smith" [zone]
List all memory zones
node dist/admin-cli.js zones list
Add a new memory zone
node dist/admin-cli.js zones add projectX "Project X knowledge zone"
Delete a memory zone
node dist/admin-cli.js zones delete projectX [--yes]
Show statistics for a specific zone
node dist/admin-cli.js zones stats projectX
Reset all zones or a specific zone
node dist/admin-cli.js reset [zone] [--yes]
Show help
node dist/admin-cli.js help
Memory Zones
The knowledge graph supports multiple memory zones to organize domain-specific knowledge. This allows you to:
- Partition Knowledge: Separate data into different domains (projects, departments, etc.)
- Improve Query Performance: Search within specific zones for faster and more relevant results
- Maintain Context: Keep context-specific information isolated but connected
Working with Zones
Create a new zone
node dist/admin-cli.js zones add projectX "Project X knowledge zone"
List all zones
node dist/admin-cli.js zones list
Import data into a specific zone
node dist/admin-cli.js import project-data.json projectX
Search within a specific zone
node dist/admin-cli.js search "feature" projectX
Cross-Zone Relations
Entities in different zones can be related to each other. When creating a relation, you can specify the zones for both entities:
{ "type": "relation", "from": "Project Feature", "fromZone": "projectX", "to": "General Concept", "toZone": "default", "relationType": "implements" }
Automation Support
For scripting and automation, you can use the --yes
or -y
flag to skip confirmation prompts:
Reset without confirmation
node dist/admin-cli.js reset --yes
Delete a zone without confirmation
node dist/admin-cli.js zones delete projectX --yes
Restore from backup without confirmation
node dist/admin-cli.js restore backup.json --yes
Search Examples
The Elasticsearch-backed knowledge graph provides powerful search capabilities:
Basic search
node dist/admin-cli.js search "cordova plugin"
Search in a specific zone
node dist/admin-cli.js search "feature" projectX
Fuzzy search (will find "subscription" even with typo)
node dist/admin-cli.js search "subscrption"
Person search
node dist/admin-cli.js search "Jean"
Search results include:
- Relevancy scoring
- Highlighted matches showing where the terms were found
- Entity types and observation counts
- Sorted by most relevant first
MCP Server Tools
The MCP server exposes the following tools for interacting with the knowledge graph:
Entity Operations
Tool | Description |
---|---|
create_entities |
Create one or more entities in the knowledge graph |
update_entities |
Update properties of existing entities |
delete_entities |
Delete one or more entities from the knowledge graph |
add_observations |
Add observations to an existing entity |
mark_important |
Mark an entity as important or not |
Relation Operations
Tool | Description |
---|---|
create_relations |
Create relations between entities |
delete_relations |
Delete relations between entities |
Query Operations
Tool | Description |
---|---|
search_nodes |
Search for entities using Elasticsearch query capabilities |
open_nodes |
Get details about specific entities by name |
get_recent |
Get recently accessed entities |
Each tool can include an optional memory_zone
parameter to specify which zone to operate on.
Relevancy Ranking
The knowledge graph implements a sophisticated relevancy ranking system that considers:
- Text Relevance: How well entities match the search query
- Recency: Prioritizes recently accessed entities
- Importance: Entities marked as important receive higher ranking
- Usage Frequency: Entities accessed more frequently rank higher
This approach simulates memory-like behavior where important, recent, and frequently accessed information is prioritized.
Benefits Over JSON Implementation
- Scalability: Handles millions of entities efficiently
- Performance: Optimized for fast queries even with large datasets
- Rich Queries: Advanced search capabilities like fuzzy matching and relevancy ranking
- Resiliency: Better handling of concurrent operations
- Observability: Built-in monitoring and diagnostics
- Complete CRUD: Full lifecycle management for entities and relations
License
MIT
推荐服务器
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。
Playwright MCP Server
提供一个利用模型上下文协议的服务器,以实现类人浏览器的自动化,该服务器使用 Playwright,允许控制浏览器行为,例如导航、元素交互和滚动。
Apple MCP Server
通过 MCP 协议与 Apple 应用(如“信息”、“备忘录”和“通讯录”)进行交互,从而使用自然语言发送消息、搜索和打开应用内容。
contentful-mcp
在你的 Contentful Space 中更新、创建、删除内容、内容模型和资源。

Supabase MCP Server
一个模型上下文协议(MCP)服务器,它提供对 Supabase 管理 API 的编程访问。该服务器允许 AI 模型和其他客户端通过标准化的接口来管理 Supabase 项目和组织。
serper-search-scrape-mcp-server
这个 Serper MCP 服务器支持搜索和网页抓取,并且支持 Serper API 引入的所有最新参数,例如位置信息。
The Verge News MCP Server
提供从The Verge的RSS feed获取和搜索新闻的工具,允许用户获取今日新闻、检索过去一周的随机文章,以及在最近的Verge内容中搜索特定关键词。