Elastic Brain ZH
An Elasticsearch-based AI memory system optimized for Chinese that enables persistent knowledge storage and complex entity relationship management via the Model Context Protocol. It features advanced semantic search using the IK analyzer and supports multi-zone memory isolation for specialized knowledge graphs.
README
🧠 Elastic Brain ZH - 中文智能记忆系统
基于Elasticsearch的AI智能记忆系统,专为中文环境优化。通过MCP(Model Context Protocol)协议与Claude Desktop无缝集成,提供持久化知识存储、语义搜索和复杂实体关系管理。
✨ 核心特性
🀄 高级中文支持
- IK分词器集成 - 智能中文分词,支持自定义词典
- 多分析器架构 -
ik_smart精确搜索 +ik_max_word全面索引 - 中英混合处理 - 完美支持中英文混合内容搜索
- 热更新词典 - 支持远程词典实时更新
🔍 智能搜索引擎
- 多字段语义搜索 - 名称、类型、观察记录多维度搜索
- 模糊匹配 - 容错搜索,支持拼写错误纠正
- 权重优化 - 智能相关性评分和排序
- 高亮显示 - 搜索结果关键词高亮
🕸️ 知识图谱
- 实体关系管理 - 复杂实体间关系建模
- 记忆区域隔离 - 多项目/场景独立记忆空间
- 动态相关性 - 基于访问频率的智能评分
- 跨区域关系 - 支持不同记忆区域间的实体关联
🐳 一键部署
- Docker集成 - 自动安装ES和IK插件
- 配置优化 - 预配置的中文搜索mappings
- 健康检查 - 自动监控服务状态
- 备份恢复 - 完整的数据备份和恢复机制
🚀 快速开始
1. 克隆项目
git clone https://github.com/TocharianOU/elastic-brain-zh.git
cd elastic-brain-zh
2. 启动中文ES环境
# 一键启动(包含IK插件安装)
./start-chinese-es.sh
3. 构建项目
npm install
npm run build
4. 配置Claude Desktop
在 ~/Library/Application Support/Claude/claude_desktop_config.json 中添加:
{
"mcpServers": {
"elastic-brain-zh": {
"command": "node",
"args": ["/path/to/elastic-brain-zh/dist/index.js"],
"env": {
"ES_NODE": "http://localhost:9200"
}
}
}
}
📊 技术架构
核心组件
- Elasticsearch 8.18.2 - 搜索引擎核心
- IK Analysis Plugin - 中文分词插件
- MCP SDK - Model Context Protocol集成
- TypeScript - 类型安全的开发体验
分析器配置
chinese_smart_analyzer: # 智能分词,搜索优化
chinese_max_analyzer: # 最大分词,索引优化
mixed_analyzer: # 中英混合分析器
entity_analyzer: # 英文标准分析器
索引映射
name: # 实体名称
- analyzer: mixed_analyzer
- search_analyzer: chinese_smart_analyzer
- fields: [chinese, english, keyword]
observations: # 观察记录
- analyzer: mixed_analyzer
- search_analyzer: chinese_smart_analyzer
- fields: [chinese, english]
🧪 搜索测试示例
中文语义搜索
# 搜索:人工智能专家
curl -X POST "localhost:9200/knowledge-graph@default/_search" \
-H 'Content-Type: application/json' \
-d '{"query": {"multi_match": {"query": "人工智能", "fields": ["name^3", "observations"]}}}'
中英混合搜索
# 搜索:张三的MacBook
curl -X POST "localhost:9200/knowledge-graph@default/_search" \
-H 'Content-Type: application/json' \
-d '{"query": {"multi_match": {"query": "张三 MacBook", "fields": ["name^3", "observations"]}}}'
服务器ID搜索
# 搜索:ubuntu-server-01
curl -X POST "localhost:9200/knowledge-graph@default/_search" \
-H 'Content-Type: application/json' \
-d '{"query": {"multi_match": {"query": "server-01", "fields": ["name^3"]}}}'
🛠️ MCP工具接口
实体管理
create_entities- 创建实体update_entities- 更新实体delete_entities- 删除实体search_nodes- 搜索节点open_nodes- 获取实体详情
关系管理
create_relations- 创建关系delete_relations- 删除关系
记忆区域
list_zones- 列出记忆区域create_zone- 创建新区域delete_zone- 删除区域copy_entities- 复制实体move_entities- 移动实体merge_zones- 合并区域
智能检查
inspect_files- AI驱动文件检查inspect_knowledge_graph- AI驱动图谱检查
📁 项目结构
elastic-brain-zh/
├── src/ # 源码目录
│ ├── index.ts # MCP服务器入口
│ ├── kg-client.ts # 知识图谱客户端
│ ├── es-types.ts # ES类型定义
│ ├── ai-service.ts # AI服务集成
│ └── filesystem/ # 文件系统工具
├── elasticsearch/ # ES配置
│ └── config/analysis-ik/ # IK分词器配置
├── elasticsearch-analysis-ik-8.18.2.zip # IK插件包
├── docker-compose.yml # Docker配置
├── start-chinese-es.sh # 启动脚本
├── update-chinese-mappings.sh # 索引更新脚本
└── CHINESE_SUPPORT.md # 中文支持文档
🔧 高级配置
自定义词典
编辑 elasticsearch/config/analysis-ik/custom/mydict.dic 添加专业词汇:
人工智能
机器学习
知识图谱
语义搜索
远程词典热更新
配置 elasticsearch/config/analysis-ik/IKAnalyzer.cfg.xml:
<entry key="remote_ext_dict">http://your-server/custom_dict.txt</entry>
性能优化
# docker-compose.yml
environment:
- "ES_JAVA_OPTS=-Xms2g -Xmx2g" # 根据系统调整内存
📈 性能指标
- 召回准确率: 100%
- 中文分词质量: 优秀
- 混合内容处理: 完美支持
- 搜索响应时间: < 50ms
- 并发支持: 1000+ QPS
🤝 贡献指南
- Fork 项目
- 创建特性分支 (
git checkout -b feature/AmazingFeature) - 提交更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 开启 Pull Request
📄 许可证
本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情
🙏 致谢
- Elasticsearch - 强大的搜索引擎
- IK Analysis - 优秀的中文分词插件
- Model Context Protocol - AI上下文协议标准
- Claude Desktop - AI助手平台
📞 联系方式
如有问题或建议,请通过以下方式联系:
- GitHub Issues: 提交问题
- 项目讨论: GitHub Discussions
⭐ 如果这个项目对你有帮助,请给我们一个星标!
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.