
metabrain
io.github.ariaxhanPublished by GitHub account ariaxhanv1.1.2Updated Oct 24, 2026
MCP server giving AI agents persistent SQLite memory that proves which lessons hold.
Overview
Gives an assistant a persistent local SQLite memory that turns repeated lessons into tested hypotheses and proven preferences.
- What you can do
- metabrain stores lessons, work units, checkpoints and verdicts in a single SQLite file so memory survives across sessions. Recurring patterns graduate into hypotheses, each logged verdict becomes an experiment for or against them, and evidence above a threshold graduates a hypothesis into a proven preference. Seven MCP tools wrap the library: start_brief, recall, learn, hypotheses, verdict, stats and capture_error. Recall is deliberately simple substring matching with a hit counter.
- When to use it
- Worth adding when an assistant should carry lessons and working state between sessions and distinguish rules it has actually validated from untested hunches. Suited to long-running, stateful work such as content iteration, lead tracking or repeated application workflows where outcomes can be logged as pass or fail.
- Requirements
- Runs locally over stdio as a Python package (metabrain, Python 3.10+, standard library only; the MCP extra adds the SDK). Install with pip or uvx and point it at a database path, for example metabrain-mcp --db ./agent.db. No accounts, API keys or network access are declared. A Docker image is also mentioned, with METABRAIN_DB overriding the default database path.
Installation
In SourceWeft
- Open metabrain in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
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
Source: README.md at commit aca136d
Tools
0Version history
1- v1.1.2LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts