
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 分