reflex-brain
MCP server that gives AI agents a continual learning brain with lessons, skills, memories, evidence-based refinement, rollback, and hybrid GraphRAG retrieval.
README
Reflex Brain
Continual learning brain for AI agents — lessons, skills, and memories with evidence-based refinement, rollback, and GraphRAG retrieval.
Overview
Reflex Brain is an agent-agnostic, continual learning memory system that gives AI agents the ability to:
- Learn continuously from interactions — extract lessons, skills, and memories with evidence
- Refine knowledge through evidence-based updates (
/refineequivalent) with full audit trail - Rollback safely — snapshot-based versioning with one-click revert
- Retrieve intelligently — GraphRAG + continual memory hybrid queries with quality filtering
- Run anywhere — MCP server for Hermes/Claude Code/Codex, or as standalone library
Architecture
┌─────────────────────────────────────────────────────────────┐
│ AGENT LAYER │
│ Hermes │ Claude Code │ Codex │ OpenInterpreter │ Custom │
└────────────────────────────┬────────────────────────────────┘
│ MCP / Python API
▼
┌─────────────────────────────────────────────────────────────┐
│ REFLEX BRAIN CORE │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Lessons │ │ Skills │ │ Memories │ │
│ │ (versioned)│ │ (executable)│ │ (episodic) │ │
│ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │
│ │ │ │ │
│ └────────────────┼────────────────┘ │
│ ▼ │
│ ┌──────────────────────┐ │
│ │ Refinement Engine │ ← Evidence-based │
│ │ (propose/validate/ │ updates + rollback │
│ │ apply/rollback) │ │
│ └──────────┬───────────┘ │
│ │ │
│ ┌──────────▼───────────┐ │
│ │ Snapshot Store │ │
│ │ (full checkpoints) │ │
│ └──────────────────────┘ │
└─────────────────────────────────────────────────────────────┘
Key Features
| Feature | Description |
|---|---|
| Lessons | Versioned knowledge units with evidence, confidence scores, and semantic clusters |
| Skills | Executable capabilities (Python/JS) with interfaces, tests, and versioning |
| Memories | Episodic memories with importance decay and temporal context |
| Refinement Engine | Proposes, validates, and applies updates based on evidence weight |
| Snapshots | Full state checkpoints for safe rollback |
| Hybrid Querier | Combines GraphRAG (conversations) + Continual (lessons/skills/memories) |
| Quality Filtering | Penalizes tool outputs, boosts substantial content, prioritizes high-value types |
| MCP Server | Thin wrapper exposing reflex_* tools over stdio |
| Daemon | Background processor for passive capture + continuous embedding |
Installation
# From PyPI (when published)
pip install reflex-brain
# From source
git clone https://github.com/jesuscaicedo800/reflex-brain.git
cd reflex-brain
pip install -e ".[dev]"
Quickstart
As MCP Server (Hermes, Claude Code, Codex)
# config.yaml
mcp_servers:
reflex-brain:
command: "python"
args: ["-m", "continual_brain.mcp.server"]
env:
HF_HUB_OFFLINE: "1"
REFLEX_DB_PATH: "~/reflex-brain/continual.db"
REFLEX_FAISS_PATH: "~/reflex-brain/"
Restart your agent — tools available: reflex_query, reflex_propose_lesson, reflex_apply_refinement, reflex_rollback, reflex_snapshot.
As Python Library
from continual_brain import ReflexBrain
brain = ReflexBrain(db_path="continual.db")
# Query (GraphRAG + Continual hybrid)
results = brain.query("DIAN facturación electrónica", top_k=5)
# Propose a lesson from recent session
proposal = brain.propose_lesson("DIAN compliance", session_id="sess_123")
# Apply with evidence threshold
brain.apply_refinement(proposal, auto_apply=True)
# Rollback if needed
brain.rollback(refinement_id="ref_abc")
Run Daemon (Background Processing)
# Foreground
reflex-brain daemon --poll-interval 3 --batch-size 50
# Background service
reflex-brain daemon --daemonize
Configuration
| Env Var | Default | Description |
|---|---|---|
REFLEX_DB_PATH |
./continual.db |
SQLite database path |
REFLEX_FAISS_PATH |
./ |
FAISS index directory |
HF_HUB_OFFLINE |
0 |
Set 1 to disable HF Hub requests |
REFLEX_EMBED_MODEL |
all-MiniLM-L6-v2 |
Sentence transformer model |
Development
# Install dev dependencies
pip install -e ".[dev]"
# Run tests
pytest
# Lint
ruff check .
# Type check
mypy continual_brain
# Pre-commit
pre-commit install
Project Structure
reflex-brain/
├── continual_brain/
│ ├── core/ # Models, Store, RefinementEngine, Evidence
│ ├── query/ # BrainQuerier, ContinualQuerier, HybridQuerier
│ ├── daemon/ # Processor, Extractor, Embedder
│ ├── mcp/ # Thin MCP server wrapper
│ └── cli/ # CLI entry points
├── tests/
│ ├── unit/ # Unit tests
│ └── integration/ # Integration tests
└── pyproject.toml
License
MIT © Jesus Caicedo
Related
- Hermes Agent — AI agent with Brain MCP
- Prime Intellect Prime Agent — Inspiration for Continual Harness
- Open Interpreter — Agent harness for open models
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。