Token导航 LogoToken导航TokenDH.com
Claude Brain logo
文档知识未说明官方级别未说明来源级核验

Claude Brain

MCP Server

为AI编码代理提供跨会话的持久化记忆存储和检索功能,解决上下文丢失问题。

工具数

35

提示词数

0

GitHub Stars

0

资源数

0
JavaScriptClaude文档处理Claude

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

Xattaus

提供方

Xattaus

最后核验

2026/5/17 20:22

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

     ██████╗██╗      █████╗ ██╗   ██╗██████╗ ███████╗
    ██╔════╝██║     ██╔══██╗██║   ██║██╔══██╗██╔════╝
    ██║     ██║     ███████║██║   ██║██║  ██║█████╗
    ██║     ██║     ██╔══██║██║   ██║██║  ██║██╔══╝
    ╚██████╗███████╗██║  ██║╚██████╔╝██████╔╝███████╗
     ╚═════╝╚══════╝╚═╝  ╚═╝ ╚═════╝ ╚═════╝ ╚══════╝
    ██████╗ ██████╗  █████╗ ██╗███╗   ██╗
    ██╔══██╗██╔══██╗██╔══██╗██║████╗  ██║
    ██████╔╝██████╔╝███████║██║██╔██╗ ██║
    ██╔══██╗██╔══██╗██╔══██║██║██║╚██╗██║
    ██████╔╝██║  ██║██║  ██║██║██║ ╚████║
    ╚═════╝ ╚═╝  ╚═╝╚═╝  ╚═╝╚═╝╚═╝  ╚═══╝

AI编码代理的持久内存

您的代理在会话之间会忘记所有内容,并在会话中失去上下文。这修复了两者。

![License: MIT](https://opensource.org/licenses/MIT) ](https://nodejs.org) ![MCP](https://modelcontextprotocol.io) Tools

______________________________________________________________________

问题

AI编码代理有两个基本限制:

1.会话之间没有内存。 每个会话都从零开始。

Session 1:  "Let's use JWT for auth"     ─── decision made
Session 2:  "Let's use session cookies"  ─── decision contradicted
Session 3:  "Why is auth broken?"        ─── bug reintroduced

架构决策相互矛盾。修复的bug回来了。代理一次又一次地犯同样的错误,因为它没有记忆。

2.上下文窗口在会话中填满。 随着对话时间的延长,代理会失去对早期决策的跟踪,上下文会被压缩或驱逐。项目越大,关键信息淹没在噪音中的速度就越快。

Turn 1:   Agent reads 5 files, understands architecture      ─── context: 30%
Turn 10:  Agent has made 8 edits, context is cluttered        ─── context: 75%
Turn 20:  Early decisions forgotten, auto-compact kicks in    ─── context: 100% → compressed
Turn 25:  "Wait, why did we choose that approach?"            ─── knowledge lost

解决方案

Claude Brain是一个MCP服务器,为您的代理提供 结构化知识库 它在启动时读取,并在工作时写入——同时解决这两个问题。

交叉会议决策、错误、教训和模式将永远存在。特工从刚才停下来的地方继续。

会期内:代理不会将所有内容都填充到上下文窗口中,而是根据需要查询大脑——只检索与当前任务相关的内容。

Session 1:  "Let's use JWT for auth"     ─── brain_record_decision ✓
Session 2:  "Let's use session cookies"  ─── brain_check_conflicts ⚠ CONFLICT with DEC-001
Session 3:  "Fix the auth bug"           ─── brain_get_context_for_files → knows full history
Turn 30:    Context compacted? No problem ─── brain_search retrieves what's needed

快速开始

git clone https://github.com/Xattaus/claude-brain.git
cd claude-brain && npm install

# Install into your project
node install.js /path/to/your/project

就是这样。安装程序配置MCP服务器,添加钩子,并将指令注入到您的 CLAUDE.md代理开始自动使用大脑。

运作原理

大脑将知识存储为带有YAML frontmatter的Markdown文件,在键入的知识图中链接在一起:

.brain/
├── overview.md              Project description
├── index.json               Fast lookup index
├── decisions/               Architecture Decision Records
│   ├── DEC-001-use-jwt.md
│   └── DEC-002-postgres.md
├── implementations/         What was built and how
├── bugs/                    Root causes and fixes
├── patterns/                Reusable conventions
├── lessons/                 Mistakes and rules to prevent them
├── plans/                   Session plans and deferred tasks
└── history/
    └── changelog.md         Full change log

条目通过键入的关系相互链接-- implements, fixes, supersedes, caused_by --形成项目知识的可导航图。

认知防火墙

大脑不仅储存知识 积极保护 你的代码库。

                    ┌─────────────────────┐
                    │   Agent wants to    │
                    │   edit a file       │
                    └─────────┬───────────┘
                              │
                              ▼
                    ┌─────────────────────┐
                    │  brain_preflight()  │
                    │  ┌───────────────┐  │
                    │  │ Check context │  │
                    │  │ Check conflicts│  │
                    │  │ Check lessons │  │
                    │  │ Check rules   │  │
                    │  └───────┬───────┘  │
                    └─────────┼───────────┘
                              │
                 ┌────────────┼────────────┐
                 │            │            │
                 ▼            ▼            ▼
           ┌──────────┐ ┌──────────┐ ┌──────────┐
           │ LOW  
Core — Query & Discovery 5 tools

|工具|它做什么|
|:-----|:-------------|
| `brain_get_overview` |项目概述+积极决策+开放错误。会话开始时呼叫。 |
| `brain_search` |对所有条目进行全文搜索,并进行相关性排名|
| `brain_get_entry` |按ID检索包含内容和关系的单个条目|
| `brain_list` |按类型、状态和标签筛选的列表条目|
| `brain_get_lessons` |获取按严重程度分组的活动课程|

Recording — Capture Knowledge 5 tools

|工具|它做什么|
|:-----|:-------------|
| `brain_record_decision` |ADR格式的架构决策|
| `brain_record_bug` |Bug修复,包括症状、根本原因和修复|
| `brain_record_implementation` |实施细节和代码更改|
| `brain_record_pattern` |可重用的模式和惯例|
| `brain_record_lesson` |从错误中吸取教训,制定规则防止再次发生|

Context & Relationships — Navigate Knowledge 4 tools

|工具|它做什么|
|:-----|:-------------|
| `brain_link_entries` |在条目之间创建双向类型链接|
| `brain_get_context_for_files` |获取特定文件的所有决策、错误和实现|
| `brain_traverse_graph` |浏览知识图——路径、影响分析、周期|
| `brain_check_conflicts` |检查拟议的变更是否与现有决策冲突|

Safety — Cognitive Firewall 4 tools

|工具|它做什么|
|:-----|:-------------|
| `brain_preflight` |预先编辑带有风险评分(低/中/高)的风险评估|
| `brain_validate_change` |根据大脑规则进行编辑后验证|
| `brain_rebuild_rules` |重建认知防火墙规则索引|
| `brain_restore_snapshot` |将大脑恢复到以前的快照|

Planning & Tracking 4 tools

|工具|它做什么|
|:-----|:-------------|
| `brain_record_plan` |记录会议计划,包括范围和延期项目|
| `brain_update_plan` |更新计划状态并标记已完成的项目|
| `brain_get_backlog` |按优先级对所有未完成/推迟的计划进行排序|
| `brain_get_session_summary` |当前会话中所有大脑变化的总结|

Maintenance 5 tools

|工具|它做什么|
|:-----|:-------------|
| `brain_update_entry` |更新现有条目(状态、标题、内容)|
| `brain_review_entry` |将条目标记为已审阅,但不更改内容|
| `brain_health` |健康报告——过时的条目、孤儿、断开的链接|
| `brain_get_history` |完整更改历史记录日志|
| `brain_auto_document` |分析git提交并建议未记录的更改|

Advanced 8 tools

|工具|它做什么|
|:-----|:-------------|
| `brain_visualize` |在浏览器中启动交互式知识图|
| `brain_mine_sessions` |从过去的Claude Code会话中提取上下文|
| `brain_coordinate_team` |运行大脑代理(策展人、文档管理员、审阅者、待办事项列表)|
| `brain_rebuild_index` |从文件重建index.json(修复损坏状态)|
| `brain_get_metrics` |使用指标——工具调用、创建的条目、活动|
| `brain_create_snapshot` |创建当前大脑状态的备份|
| `brain_list_snapshots` |列出可用于还原的快照|
| `brain_update` |将Brain升级至最新版本|

## 自我改进循环

当代理出错或用户纠正错误时,大脑会记录 **课程** 有一条防止再次发生的具体规则:

┌──────────────┐ ┌──────────────────┐ ┌────────────────────┐ │ User corrects│────▶│ brain_record_ │────▶│ Next session: │ │ the agent │ │ lesson() │ │ brain_get_lessons()│ └──────────────┘ │ │ │ reads the rule │ │ severity: high │ │ before working │ │ rule: "Never..." │ └────────────────────┘ └──────────────────┘


课程检查期间 `brain_preflight()` --如果建议的编辑违反了学习到的规则,防火墙会阻止它。

## 命令行界面

在没有AI代理的情况下从命令行使用大脑:

node cli.js overview # project overview node cli.js search "authentication" # full-text search node cli.js search --type=decision "database" # filtered search node cli.js read DEC-001 # read single entry node cli.js check "Switch JWT to session cookies" # conflict check node cli.js decide "Use Postgres" "Need RDBMS" "v14" # record decision node cli.js log-bug "Login crash" "500 error" "Fixed" # record bug fix node cli.js implement "Auth API" "Added /api/auth" # record implementation node cli.js link IMPL-005 DEC-002 implements # link entries


## 知识图谱可视化工具

项目大脑的交互式力定向图:

node cli.js visualize # from any project with brain installed node visualize.js /path/to/your/project # or directly with a path


打开一个带有黑曜石风格知识图的浏览器——力定向物理、沿连接流动的动画粒子、实时高亮显示搜索、细节面板、小地图、时间线、类型过滤器,并导出为PNG。节点按类型着色,按连接大小调整,按状态变暗。

## 建筑

┌─────────────────────────────────────────────────────────────┐ │ MCP Server │ │ mcp-server.js │ │ (35 tools exposed) │ ├─────────────┬──────────────┬──────────────┬─────────────────┤ │ Brain │ Search │ Graph │ Conflict │ │ Manager │ │ │ Checker │ │ │ BM25 + │ Typed │ Three-phase │ │ CRUD + │ fuzzy + │ relationships│ detection │ │ file locks │ boost phase │ + traversal │ │ ├─────────────┼──────────────┼──────────────┼─────────────────┤ │ Change │ Rule Index │ Analyzer │ Auto │ │ Validator │ │ │ Documenter │ │ │ Cognitive │ Project │ │ │ Post-edit │ firewall │ structure │ Git commit │ │ validation │ rules │ analysis │ analysis │ ├─────────────┴──────────────┴──────────────┴─────────────────┤ │ .brain/ directory │ │ Markdown + YAML frontmatter + index.json │ └─────────────────────────────────────────────────────────────┘


## 测试

npm test # run all tests npm run test:brain # core brain operations npm run test:graph # knowledge graph traversal npm run test:validation # input validation (Zod) npm run test:perf # performance benchmarks


使用Node.js内置测试运行器(`node:test`)--不需要额外的测试依赖关系。

## 项目结构

claude-brain/ ├── mcp-server.js MCP server — all 34 tools ├── install.js One-command installer for any project ├── cli.js Command-line interface ├── visualize.js 3D knowledge graph visualizer ├── lib/ │ ├── brain-manager.js Core CRUD with file locking │ ├── search.js BM25 + fuzzy search with boost scoring │ ├── graph.js Knowledge graph traversal │ ├── conflict-checker.js Decision conflict detection │ ├── change-validator.js Post-edit rule validation │ ├── rule-index.js Cognitive firewall rule engine │ ├── analyzer.js Project structure analysis │ ├── schemas.js Zod input validation │ └── ... ├── templates/ │ ├── CLAUDE.md.template Instructions injected into target projects │ ├── hooks/ Session hooks (start, stop, firewall, etc.) │ ├── agents/ Bundled agent definitions │ └── skills/ Brain workflow skills └── tests/ ├── brain.test.js Core operations ├── graph.test.js Graph traversal ├── validation.test.js Schema validation └── performance.test.js Benchmarks


______________________________________________________________________

**MIT许可证** ·专为 [克劳德代码](https://docs.anthropic.com/en/docs/claude-code) ·与任何MCP客户端兼容

目录标签

目录标签

JavaScriptClaude文档处理AI编码辅助本地部署知识管理上下文存储认知防火墙代码决策跟踪

支持客户端

Claude

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

session

工具数量(toolCount,工具数)

35

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明session部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP