Metabrain

MCP文档知识

提供方 未标注

文档知识 stdio · 本地进程 未标注 社区 / 第三方 Claude DesktopClaudeCursorVS Code
查看接入方式

零依赖的SQLite记忆,供智能体使用,将重复模式提升为经过测试的假设和已验证的偏好。

一句话选型结论

按资料字段整理

Metabrain 属于文档知识类 MCP 服务器,stdio · 本地进程,鉴权方式未标注,可直接接入 Claude Desktop、Claude、Cursor 等,有可直接执行的安装命令。接入前先确认权限范围;涉及写入、删除或付款的操作,建议先在测试环境验证。

分类文档知识 传输方式stdio · 本地进程 鉴权未标注 部署方式本地部署
GitHub 星标 未标注 仓库热度,无公开仓库时显示未标注
工具数 未标注 暴露给模型的工具数量
资源 / 提示词 0 / 0 资源与提示词模板数量
维护方 社区 / 第三方 核验等级 仅资料核对

工具与能力

文档知识
数量来自来源目录的标注,具体工具清单以官方文档为准
工具数量未标注暴露给模型可调用的工具个数
资源数量0可读取的资源条目
提示词数量0内置提示词模板数量

能力标签

支持客户端

适用场景

记忆

安装与配置

stdio · 本地进程 未标注
客户端在本机拉起子进程,数据不出本机
docker run -i --rm -v metabrain:/data mcp/metabrain

这条命令只是入口,具体启动参数请按官方文档补齐,不要直接照搬到别的服务器。

  1. 1
    准备运行环境

    stdio 服务在本地起进程,需要先装好 Node.js 等运行时,再按安装命令拉取依赖。

  2. 2
    安装服务

    复制上面的安装命令执行;命令里带占位符的位置,换成自己的密钥或路径。

  3. 3
    写入客户端配置

    在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4
    验证是否可用

    连接成功后随便调一个只读工具,确认能返回结果,再接入正式流程。

典型使用场景

3 类
按分类与标签整理的常见用法,具体以官方文档为准
文档检索问答

在你的文档库里按问题找答案。

知识库读写

把新资料写进知识库,随用随取。

内容整理

把零散资料归纳成结构化笔记。

选择建议

选之前先看这几条
按条目字段给出的判断,不替你决定用不用

值得选的地方

  • 有现成的安装命令,不用自己找入口,照着跑就能起服务。
  • 已适配 Claude Desktop、Claude、Cursor,换客户端不用重新研究配置。

先想清楚的地方

  • stdio 方式要求本地装好运行时(如 Node.js),换机器要重新装一遍。
  • 资料没标注工具数量,实际能力要装好后确认。
  • 版本更新与行为细节以官方仓库为准。

更适合

  • 需要在文档知识场景里让模型直接调用外部能力的人。
  • 已经在用 Claude Desktop、Claude 的用户,接入路径最短。
  • 想先快速试一下、能接受在本地或自有环境跑服务的人。

不太适合

  • 完全不想在本地装环境的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

6 个同类
同分类里挑最接近的几条,字段以各自详情页为准
MCP 服务器工具数传输方式部署方式安装命令最后核验
Metabrain当前 未标注 stdio · 本地进程 本地部署 有 未标注
dify 未标注 stdio · 本地进程 本地部署 有 2026-04-11
open-webui 未标注 stdio · 本地进程 本地部署 有 2026-04-11
JeecgBoot 未标注 stdio · 本地进程 本地部署 有 2026-04-11
Cherry Studio 未标注 未标注 未标注 无 2026-05-17
mempalace 未标注 stdio · 本地进程 本地部署 有 2026-04-11

服务器档案

文档知识
字段来自项目仓库与公开索引,中文说明由本站标注
提供方未标注上游标注的维护方 未标注
分类文档知识本站按上游分类展示
连接方式stdio · 本地进程客户端在本机拉起子进程,数据不出本机
鉴权方式未标注远程服务建议用最小权限凭据
维护方社区 / 第三方核验等级 仅资料核对
包名 / 运行时未标注 · 未标注本地安装时用到的包标识与运行时
部署类型本地部署上游给出的部署形态
最近核验未标注上游最后核验时间

详细介绍

9.3 KB
来自项目仓库与上游目录的原文,未做删改

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:```bash
pip install 'metabrain[mcp]'
claude mcp add metabrain -- metabrain-mcp --db ./agent.db

first call, once the server is registered:

start_brief() -> proven preferences, open hypotheses, open units


Codex instead of Claude Code? Add to `~/.codex/config.toml`:```toml
[mcp_servers.metabrain]
command = "metabrain-mcp"
args = ["--db", "./agent.db"]

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.```
learn(pattern) → recurs → hypothesis (under test)
→ each verdict is an experiment (supports / refutes)
→ evidence clears the bar → preference (a proven rule)


That loop is the whole point. It runs on the Python standard library — no vector database, no server, no API keys.

## Install```bash
pip install metabrain

Python 3.10+. No dependencies beyond the standard library. (Import name is metabrain.)

Quick start```python

from metabrain import MetaBrain

db = MetaBrain("agent.db")

with db.session(task="content") as s:
# A hunch. Record it as you notice it — three times and it's worth testing.
s.learn("pattern", "question hooks lift saves", domain="instagram")
s.learn("pattern", "question hooks lift saves", domain="instagram")
s.learn("pattern", "question hooks lift saves", domain="instagram")

# It just graduated into a hypothesis. Now test it against reality.
h = db.hypotheses(status="testing")[0]
post = s.unit("carousel with a question hook", kind="contract", hypothesis=h.id)
s.verdict("pass", unit=post, evidence="1,240 saves")

Next session: the proven rules come first.

brief = db.read_start()
for rule in brief.preferences: # things metabrain has proven
print("PROVEN:", rule.insight)
for h in brief.open_hypotheses: # things it's still testing
print("testing:", h.statement, f"({h.confidence:.0%})")


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

|  | metabrain | typical vector-memory store |
| --- | --- | --- |
| Remembers what you tell it | ✅ | ✅ |
| **Proves which memories actually work** | ✅ the learn→experiment→graduate loop | ❌ |
| Working state + telemetry, not just recall | ✅ units, checkpoints, sessions, events | ❌ |
| Infrastructure | a single SQLite file | vector DB / server / API key |
| Dependencies | none (stdlib `sqlite3`) | several |

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.```python
s.learn("pattern", "carousels outperform single images", domain="ig")  # ...×3 → hypothesis
for saves, ok in [(1200,"pass"), (90,"fail"), (1500,"pass"), (1100,"pass")]:
    post = s.unit(f"carousel ({saves} saves)", kind="contract", hypothesis=h.id)
    s.verdict(ok, unit=post, evidence=f"{saves} saves")
# 3/4 supported → graduates into the playbook

Lead capture. Each lead is a unit with its own checkpoint trail; a tactic about what converts graduates once enough leads confirm it.```python
lead = s.unit({"name": "Acme", "source": "webinar"}, kind="contract")
s.checkpoint({"stage": "demo booked"}, unit=lead)
s.verdict("pass", unit=lead, evidence="closed")


**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.```python
app = s.unit({"company": "Acme"}, kind="contract", hypothesis=h.id)
s.verdict("pass", unit=app, evidence="recruiter replied")

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:

Table Filled by When
sessions db.session() open/close every run
events every write method always (telemetry is automatic)
learnings learn() — preference rows are graduated always
context unit(), checkpoint(), handoff(), verdict() always
hypotheses a pattern crossing promote_at (default 3 hits) automatic
experiments a verdict() on a unit/hypothesis under test automatic
errors capture_error(), and any exception inside a session automatic

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.```python
db = MetaBrain("agent.db", promote_at=3, graduate_at=0.8, min_experiments=3)


## API

| Method | What it does |
| --- | --- |
| `session(*, task, tier, agent, meta)` | Open a session (context manager); records the outcome on close |
| `learn(type, insight, *, evidence, domain, ...)` | Record/reinforce a lesson; recurring `pattern`s graduate to hypotheses |
| `recall(query, *, limit)` | Substring-search lessons; bumps hit count (can trigger graduation) |
| `learnings(*, type, domain, limit)` | Fetch lessons, newest first |
| `forget(id)` | Delete a lesson |
| `unit(statement, *, kind, acceptance, hypothesis)` | Open a unit of work; `kind="spec"` requires `acceptance=[...]` |
| `checkpoint(content, *, unit, agent)` | Record progress mid-work |
| `handoff(content, *, unit, agent)` | Record a brief for the next session |
| `verdict(result, *, unit, hypothesis, evidence)` | `"pass"`/`"fail"`; becomes an experiment when a hypothesis is in play |
| `hypotheses(*, status, limit)` / `experiments(*, hypothesis)` | Inspect the loop |
| `context(*, type, unit, limit)` | Fetch work-state entries |
| `read_start(*, learnings_limit)` | The "what to know" digest — proven preferences first |
| `capture_error(tool, error, ...)` / `errors(*, limit)` | Record / fetch failures |
| `prune(*, keep)` / `stats()` | Trim old checkpoints / row counts per table |

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.```bash
pip install 'metabrain[mcp]'
claude mcp add metabrain -- metabrain-mcp --db ./agent.db

Codex, in ~/.codex/config.toml:```toml
[mcp_servers.metabrain]
command = "metabrain-mcp"
args = ["--db", "./agent.db"]


`metabrain-mcp` speaks stdio, opens one shared `MetaBrain` on the `--db` path, and closes it on exit. Seven tools, thin wrappers over the library:

| Tool | Calls |
| --- | --- |
| `start_brief()` | `read_start()` — proven preferences first; run it before you work |
| `recall(query, limit=20)` | `recall()` |
| `learn(type, insight, domain?, context?)` | `learn()`; `type` is `failure` / `pattern` / `gotcha` / `preference` |
| `hypotheses(status?)` | `hypotheses()` |
| `verdict(result, unit?, evidence?, hypothesis?)` | `verdict()` — closes the loop |
| `stats()` | `stats()` |
| `capture_error(tool, error, context?)` | `capture_error()` |

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```bash
pip install -e ".[dev]"
pytest

License

MIT © Aria Han

常见问题

8 问
答案由本站依据条目字段整理,不引用上游原文
Metabrain 怎么安装?

在客户端按下面的安装命令接入:docker run -i --rm -v metabrain:/data mcp/metabrain。装完在客户端配置里引用同一个包或端点。

Metabrain 怎么在 Claude Desktop、Claude、Cursor 里配置?

它的传输方式是stdio · 本地进程,在客户端的 MCP 配置里填好启动命令和参数,保存后完全退出客户端再打开,配置才会生效。

Metabrain 收费吗?

本站不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Metabrain 需要 API Key 吗?

资料没有标注鉴权方式,是否需要密钥取决于服务本身,接入前按官方文档确认。

Metabrain 支持哪些客户端?

资料标注支持 Claude Desktop、Claude、Cursor、VS Code、Gemini CLI、Codex;其他客户端只要能配置 MCP Server,也能用同样的命令或地址接入。

Metabrain 能提供哪些能力?

资料显示能力标签包括 记忆。具体工具清单以官方文档为准。

Metabrain 需要什么运行环境?

属于本地进程,需要在本机装好运行环境。

Metabrain 是本地还是远程?

它是本地进程(stdio),由客户端在本机拉起。传输方式为stdio · 本地进程。

热门专题

按标签挑服务器
全部专题 →

服务器信息以作者仓库与官方文档为准;分类、传输方式与鉴权方式的中文说明为中文整理,最近核验 未标注。