Brain-MCP
Provides AI with persistent memory management including short-term memory (FIFO queue), long-term memory (graph-based storage with associations), and thought process management with multiple cognitive modes for continuous learning and reasoning.
README
Brain-MCP
Memory Control Protocol - AI记忆思维管理系统,模拟类人思维记忆过程
❌ 没有Brain-MCP
AI缺乏持久的记忆能力,每次对话都是全新的开始。您会遇到:
❌ 无法记住之前的对话内容
❌ 无法建立知识之间的关联
❌ 无法进行连续的思维过程
❌ 无法学习和积累经验
✅ 使用Brain-MCP
Brain-MCP为AI提供完整的记忆管理系统,支持短期记忆、长期记忆和思维过程管理:
✅ 短期记忆: FIFO队列式临时缓存,容量可配置
✅ 长期记忆: 基于图结构的持久化存储,支持关联和搜索
✅ 思维过程管理: 完整的思维链管理系统,支持多类型思考节点
✅ 自动持久化: 每次修改记忆都会自动保存
✅ 认知模式: 支持分析、直觉、创造、批判、元认知等多种模式
🚀 快速开始
要求
- Node.js >= v18.0.0
- Claude Desktop、Cursor、VSCode或其他MCP客户端
配置
{
"mcpServers": {
"brain": {
"command": "npx",
"args": ["-y", "digital-brain-mcp"],
"env": {
"BRAIN_MCP_STORAGE_PATH":"./memory_data"
}
}
}
}
🔨 可用工具
Brain-MCP提供以下工具供AI使用:
短期记忆工具
- addShortTermMemory: 添加临时记忆到短期缓存
- getShortTermMemory: 获取所有短期记忆(最新优先)
- clearShortTermMemory: 清空短期记忆
长期记忆工具
- addLongTermMemory: 创建新的持久化记忆节点
- getLongTermMemory: 根据ID获取记忆及其关联
- searchLongTermMemory: 关键词搜索记忆
- updateLongTermMemory: 更新记忆内容和关联
- deleteLongTermMemory: 删除记忆节点
- getAssociations: 获取节点的直接关联
思维过程工具
- startThoughtProcess: 启动新的思维链
- addThought: 向思维链添加思考节点
- branchThought: 从现有思考创建分支
- evaluateThought: 评估并更新思考的置信度
- completeThoughtProcess: 完成思维过程并存储结论
- getCurrentThoughtChain: 获取思维链的当前状态
- pauseThinking: 暂停活跃的思维过程
- resumeThinking: 恢复暂停的思维过程
- switchCognitiveMode: 切换认知模式
- getOptimalModeForTask: 获取任务推荐的最佳认知模式
- getThinkingProgress: 获取思维链的进度统计
- getActiveChains: 获取所有活跃的思维链
- getThinkingStats: 获取思维过程的总体统计信息
系统管理工具
- saveMemory: 手动保存记忆到磁盘
- getMemoryStats: 获取记忆系统统计信息
💡 使用示例
基本记忆操作
// 添加短期记忆
await mcp.addShortTermMemory("用户询问天气情况");
// 添加长期记忆并建立关联
const memoryId = await mcp.addLongTermMemory("北京夏天炎热", ["weather-memory-id"]);
// 搜索记忆
const results = await mcp.searchLongTermMemory("炎热");
思维过程管理
// 启动思维过程
const chainId = await mcp.startThoughtProcess("设计用户友好的产品界面");
// 添加思考节点
await mcp.addThought(chainId, "从用户角度思考主要使用场景", "analysis");
await mcp.addThought(chainId, "采用简约设计风格", "decision");
// 创建分支探索替代方案
const branchId = await mcp.branchThought(thoughtId, "尝试创新交互模式");
// 完成思维过程
await mcp.completeThoughtProcess(chainId, "选择平衡方案:简约为主,适度创新");
🛟 提示
自动保存
所有修改记忆的操作都会自动保存到本地存储,确保数据不会丢失。
记忆关联
使用关联功能建立知识之间的联系,支持深度检索和智能推荐。
思维模式
根据任务类型选择合适的认知模式:
- 分析模式: 深度推理,多角度分析
- 直觉模式: 快速联想,模式识别
- 创造模式: 发散思维,概念组合
- 批判模式: 质疑验证,逻辑检查
- 元认知模式: 思考自己的思考过程
💻 开发
克隆项目并安装依赖:
git clone https://github.com/DDguan2010/brain-mcp.git
cd brain-mcp
npm install
构建:
npm run build
运行服务器:
npm start
CLI参数
brain-mcp接受以下CLI参数:
- --port <number> – 服务器端口(默认3000)
- --storage-path <path> – 存储路径(默认./memory_data)
- --auto-save-interval <ms> – 自动保存间隔(默认5分钟)
示例:
npm start -- --port 8080 --storage-path ./my_memory
环境变量
可以使用以下环境变量:
- NODE_ENV: 运行环境(development/production)
- BRAIN_MCP_STORAGE_PATH: 存储路径
- BRAIN_MCP_AUTO_SAVE_INTERVAL: 自动保存间隔
示例:
NODE_ENV=production BRAIN_MCP_STORAGE_PATH=./data npm start
🏗️ 架构设计
brain-mcp/
├── src/
│ ├── types.ts # 类型定义
│ ├── config.ts # 配置管理
│ ├── short-term-memory.ts # 短期记忆管理
│ ├── long-term-memory.ts # 长期记忆管理
│ ├── thinking-process.ts # 思维过程管理
│ ├── storage.ts # 文件持久化
│ └── brain-mcp.ts # 主模块
└── server.ts # MCP服务器
📄 许可证
MIT License
🤝 贡献
欢迎提交Issue和Pull Request!
Made by 0.2Studio
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.
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.
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.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.
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.
E2B
Using MCP to run code via e2b.