Elastic Brain ZH MCP Server

Local setup required. This server has to be cloned and prepared on your machine before you register it in Claude Code.
1

Set the server up locally

Run this once to clone and prepare the server before adding it to Claude Code.

Run in terminal
git clone https://github.com/TocharianOU/elastic-brain-zh.git
cd elastic-brain-zh
npm install
npm run build
2

Register it in Claude Code

After the local setup is done, run this command to point Claude Code at the built server.

Run in terminal
claude mcp add -e "ES_NODE=${ES_NODE}" elastic-brain-zh -- node "<FULL_PATH_TO_ELASTIC_BRAIN_ZH>/dist/index.js"

Replace <FULL_PATH_TO_ELASTIC_BRAIN_ZH>/dist/index.js with the actual folder you prepared in step 1.

Required:ES_NODE
README.md

An Elasticsearch-based AI memory system optimized for Chinese.

🧠 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

🤝 贡献指南

  1. Fork 项目
  2. 创建特性分支 (git checkout -b feature/AmazingFeature)
  3. 提交更改 (git commit -m 'Add some AmazingFeature')
  4. 推送到分支 (git push origin feature/AmazingFeature)
  5. 开启 Pull Request

📄 许可证

本项目采用 MIT 许可证 - 查看 LICENSE 文件了解详情

🙏 致谢

Tools (15)

create_entitiesCreates new entities in the knowledge graph.
update_entitiesUpdates existing entities.
delete_entitiesDeletes entities from the knowledge graph.
search_nodesSearches for nodes within the knowledge graph.
open_nodesRetrieves detailed information for specific nodes.
create_relationsCreates relationships between entities.
delete_relationsDeletes relationships between entities.
list_zonesLists all available memory zones.
create_zoneCreates a new memory zone.
delete_zoneDeletes a memory zone.
copy_entitiesCopies entities between zones.
move_entitiesMoves entities between zones.
merge_zonesMerges two memory zones.
inspect_filesPerforms AI-driven file inspection.
inspect_knowledge_graphPerforms AI-driven knowledge graph inspection.

Environment Variables

ES_NODErequiredThe URL of the Elasticsearch instance.

Configuration

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"}}}}

Try it

Create a new entity for 'Project Alpha' in the default memory zone.
Search for all entities related to '人工智能' in my knowledge graph.
Move the entity 'Server-01' from the 'Development' zone to the 'Production' zone.
List all current memory zones and their contents.
Inspect the knowledge graph for any orphaned entities.

Frequently Asked Questions

What are the key features of Elastic Brain ZH?

Advanced Chinese language support using IK Analyzer with custom dictionary support.. Multi-zone memory isolation for project-specific knowledge graph management.. Complex entity relationship modeling and cross-zone entity association.. Intelligent semantic search with multi-field weighting and keyword highlighting.. Docker-ready deployment with pre-configured Elasticsearch mappings..

What can I use Elastic Brain ZH for?

Managing complex project documentation and entity relationships in Chinese.. Building a persistent AI memory system for cross-project knowledge retrieval.. Organizing technical notes and server configurations into isolated memory zones.. Performing semantic searches across mixed-language technical documentation..

How do I install Elastic Brain ZH?

Install Elastic Brain ZH by running: git clone https://github.com/TocharianOU/elastic-brain-zh.git && cd elastic-brain-zh && npm install && npm run build

What MCP clients work with Elastic Brain ZH?

Elastic Brain ZH works with any MCP-compatible client including Claude Desktop, Claude Code, Cursor, and other editors with MCP support.

Turn this server into reusable context

Keep Elastic Brain ZH docs, env vars, and workflow notes in Conare so your agent carries them across sessions.

Need the old visual installer? Open Conare IDE.
Open Conare