
metabrain
io.github.ariaxhan由 GitHub 账号 ariaxhan 发布v1.1.2更新于 Oct 24, 2026
MCP server giving AI agents persistent SQLite memory that proves which lessons hold.
概览
为助手提供本地 SQLite 持久记忆,把重复出现的经验升级为待验证假设和已被证实的偏好。
- 可以做什么
- metabrain 把经验、工作单元、检查点和判定结果存入单个 SQLite 文件,使记忆跨会话保留。重复出现的模式会升级为假设,每次记录的判定成为支持或反驳该假设的实验,证据达到阈值后假设再升级为已证实的偏好。七个 MCP 工具封装了该库:start_brief、recall、learn、hypotheses、verdict、stats 和 capture_error。召回刻意保持简单,只做子串匹配并记录命中次数。
- 适用场景
- 适合希望助手在会话之间保留经验和工作状态,并区分已实际验证的规则与未经验证的猜测的场景。适用于长期、有状态的工作,例如内容迭代、线索跟踪或需要反复提交并记录通过或失败结果的应用流程。
- 运行要求
- 以 Python 包形式在本地通过 stdio 运行(metabrain,Python 3.10+,仅依赖标准库;MCP 额外依赖会引入 SDK)。可用 pip 或 uvx 安装,并指定数据库路径,例如 metabrain-mcp --db ./agent.db。未声明需要账号、API 密钥或网络访问。文档还提到 Docker 镜像,可用 METABRAIN_DB 覆盖默认数据库路径。
安装
在 SourceWeft 中
- 打开 控制台中的 metabrain,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
metabrain
A SQLite memory layer for AI agents that learns what works. Zero dependencies. One file.
For agents
You are an AI coding agent deciding whether to install this. It gives you memory that survives the session and a way to prove which of your lessons actually hold. Run:
Codex instead of Claude Code? Add to ~/.codex/config.toml:
Gemini CLI: gemini extensions install https://github.com/ariaxhan/metabrain.
Full agent-facing reference (tools, exact argument names, a three-call example, and when not to use this): llms.txt.
Why it exists
Most agent-memory tools store what you tell them and hand it back later. metabrain does that too — but it also closes the loop: a pattern you record enough times graduates into a hypothesis, every outcome you log becomes an experiment for or against it, and once the evidence clears the bar it graduates again into a proven preference. Your agent stops guessing and starts running on rules it earned.
That loop is the whole point. It runs on the Python standard library — no vector database, no server, no API keys.
Install
Python 3.10+. No dependencies beyond the standard library. (Import name is metabrain.)
Quick start
You don't have to open a session — the flat API (db.learn(...), db.verdict(...)) works too and attaches to an ambient session automatically, so the telemetry still fills.
Why it's different
Recall stays deliberately simple — substring + a hit counter — because the moat is the loop, not embedding search. (Semantic recall may arrive later as an opt-in metabrain[embeddings] extra; the core will always be zero-dependency.)
Built for real, stateful products
The loop is general. Three shapes it was designed against:
Self-learning content engine. Each post is a unit; engagement is the verdict. Hooks that keep winning graduate into the brand's proven playbook.
Lead capture. Each lead is a unit with its own checkpoint trail; a tactic about what converts graduates once enough leads confirm it.
Self-improving job applications. Each application is a unit; "lead with a shipped metric" stays a guess until enough replies prove it, then becomes a rule.
How the tables fill themselves
metabrain has seven tables, and you never write to them directly — correct use of the API fills every one as a side effect. Open a session and each write inherits its id, emits an event, and turns the loop:
The thresholds are tunable and were calibrated on 5,066 real learnings, not guessed: promote_at=3 (where the recurring-pattern tail actually begins), graduate_at=0.8 over a minimum of 3 experiments so a single lucky result can't graduate.
API
Use MetaBrain(":memory:") for an ephemeral in-process store (handy in tests).
Concurrency & safety
Built for multiple agents sharing one file. SQLite runs in WAL mode with a busy timeout so several processes read and write concurrently; within a process a single connection is lock-guarded, and the verdict→graduation path is one critical section so racing verdicts can never double-graduate a hypothesis. Every value is bound as a query parameter — caller strings never reach the SQL text.
It can open and migrate an older metabrain / base-schema database (learnings, context, errors) forward in place. A database created by a different tool whose events/hypotheses/experiments tables have an incompatible shape is detected on open and rejected with a clear IncompatibleDatabaseError, rather than corrupting it.
Use as an MCP server
Point Claude Code, Codex, or any MCP client at a metabrain file and the loop runs from inside the agent — no glue code.
Codex, in ~/.codex/config.toml:
metabrain-mcp speaks stdio, opens one shared MetaBrain on the --db path, and closes it on exit. Seven tools, thin wrappers over the library:
Or in Docker, with the database on a mounted volume: docker run -i --rm -v metabrain:/data mcp/metabrain (METABRAIN_DB overrides the default /data/agent.db).
The core package stays zero-dependency; the mcp SDK arrives only with the extra, and works on both mcp 1.x and 2.x.
Development
License
MIT © Aria Han
来源:README.md,提交 aca136d
工具
0版本历史
1- v1.1.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分