motherflame
by opelpleple
README.md
<div align="center">
# π₯ Motherflame
### The Org Brain for teams that use AI
**Harvest your company's context once. Let every AI agent β yours, Claude, Cursor β draw on it forever.**
[](https://github.com/opelpleple/motherflame/actions/workflows/ci.yml)
[](https://www.python.org/downloads/)
[-brightgreen.svg)](#-almost-zero-dependencies)
[](https://modelcontextprotocol.io)
[](#-zero-knowledge-sync)
[](LICENSE)
*Bring your own AI key. Self-hosted. Your data never leaves your control.*
</div>
---
## The problem
> *"The models are not the bottleneck anymore. A frontier model that knows nothing about your company still writes a confident, generic, **wrong** answer."*
Every AI agent your team uses starts from **zero**. It doesn't know your pricing, your customers, your decisions, your voice. So everyone re-explains the same context, in every chat, forever β and the knowledge stays trapped in scattered files, individual configs, and dead Slack threads.
**Motherflame fixes this.** It harvests the context that already exists β your markdown, your docs, your notes β into one **Org Brain** that any agent can query. No migrating into a new workspace. No re-typing context. Just point it at your files and go.
---
## What's in v0.2 (Current)
**v0.2 closes all 8 architectural gaps** β here's what's new:
### ποΈ Complete Knowledge Architecture
| Layer | Capability | Status |
|-------|-----------|--------|
| **Storage** | Brain state, claims, documents, indexing | β
|
| **Sync** | Encrypted push/pull, merge strategy, team coordination | β
|
| **Trust** | Authority tiers (5-level), confidence scoring, conflict tiebreak | β
|
| **Quality** | Contradiction detection, entity linking, canonical forms | β
|
| **Knowledge** | Entity graph, semantic search, pluggable embeddings | β
|
| **Ingestion** | File absorption, LLM extraction, fact validation | β
|
| **Interface** | CLI, dashboard, MCP server, GraphML export | β
|
### π Security & Team Features (NEW in v0.2)
- **Zero-knowledge encryption:** ChaCha20-Poly1305 β server never sees plaintext
- **Multi-machine sync:** 3+ team members, encrypted push/pull, conflict-free convergence
- **Sensitivity tiers:** public/internal/confidential with auto-classification by path
- **Entity graph:** Org structure, leadership, team relationships β GraphML export for Gephi
- **Semantic validation:** Detect contradictions (temporal, cardinality, mutual exclusion)
- **Coreference resolution:** "Alice" = "alice" = "CEO" linked to canonical form
- **Authority model:** Local > confidential > interview > chat > web (web capped at 0.5)
### π By the Numbers (v0.2)
- **6,500+ LOC** Python (authoritatively typed, 26 modules)
- **167 tests** (100% pass) across 3.9/3.11/3.12
- **8/8 gaps closed** β all architectural constraints satisfied
- **3-machine verified:** Generic org sync test with multiple team members β
- **Zero external deps** (crypto only via stdlib)
---
## See it in 20 seconds
```console
$ motherflame
π₯ Motherflame v0.2.0
The Org Brain for teams that use AI
π₯ MyOrg Org Brain Β· 12 items (4 from teammates)
Connected: openai/gpt-4o-mini Β· session 20260628-145220
Type a message, '/' for commands, or /exit to quit.
you βΊ what are our key business constraints?
β graph_query(role=strategy) β [Leadership] CEO: Alice | [Finance] ARR: $15M
β validate_contradictions() β 1 contested (stage) β auto-resolved
ai βΊ You're at Series A stage, ARR is $15M. CEO is Alice. Funding closed Q2 2026.
you βΊ /pull
β Syncing with team...
5 new facts from teammates Β· Bob (product), Carol (engineering)
β All 3 machines now have identical brain (hash: a7f3b9c2d1e6f4a8)
you βΊ /analyze
π Brain Quality Report
- Entities: 5 (MyOrg, Alice, Bob, Carol, etc.)
- Coreference chains: 4 (Alice linked across mentions)
- Contradictions resolved: 1 (stage via authority tiers)
- Sensitivity: 2 confidential, 10 public
```
---
## Quickstart (under a minute)
```bash
# 1. Install (zero dependencies β just Python 3.9+)
git clone https://github.com/opelpleple/motherflame
cd motherflame
python3 -m venv .venv && source .venv/bin/activate # recommended
pip install -e .
```
> **No virtualenv?** On modern macOS/Linux a bare `pip install` may be blocked
> (PEP 668). Either use the venv above, or `pipx install -e .`, or
> `pip install -e . --break-system-packages`. There are no third-party deps to
> install β only Motherflame itself.
```bash
# 2. Try it immediately β no API key, no signup
motherflame connect # generates a local Flame Key for you
motherflame start # harvest your files (keyword mode works key-free)
motherflame # drop into the agent
# 3. (Optional) Connect your own AI for high-quality extraction + chat
motherflame setup # pick Anthropic / OpenAI / Ollama, paste your key
```
That's it. Type `/` any time to see every command. See [`CONCEPTS.md`](CONCEPTS.md)
for a glossary of terms (Flame Key, claims, contested, etc.).
### π Bootstrap from your website (recommended)
Typing facts by hand is shallow and tedious. The fastest way to fill an Org Brain
is to point Motherflame at your company website β it reads the key pages, the LLM
extracts **concrete** facts, and you confirm each one before it's saved:
```bash
motherflame research https://yourcompany.com
```
```
π Researching https://yourcompany.com
β Read 5 page(s): / Β· /about Β· /pricing Β· /product Β· /team
Found 14 candidate facts. Confirm each before it enters your Org Brain:
Product Β· pricing_tiers
Listing plans at $18k / $48k / $100k+ per year (confidence 80%)
βΊ β
Keep βοΈ Edit value β Skip
```
`motherflame start` runs this first (Phase 0) before scanning local files and a
few interview questions. Nothing is saved until you confirm it.
### Create a new org, or join an existing one
The **Flame Key** (`mf_<org>_<hex>`) both names *and* encrypts your Org Brain.
Whoever holds it can decrypt and sync the same brain β so it's how teams share.
```bash
# Start a NEW Org Brain (you're the first member):
motherflame create "Acme" # solo
motherflame create "Acme" --remote git@github.com:acme/brain.git # team-synced
# β prints your Flame Key. Share it with teammates.
# JOIN an existing Org Brain (a teammate gave you their key):
motherflame join mf_acme_1a2b3c4d --remote git@github.com:acme/brain.git
# β sets the key, binds the remote, AND pulls + merges the team's brain
# so you see their knowledge right away (not an empty brain).
```
The git remote is any repo you control β the host only ever stores **ciphertext**
(zero-knowledge). Solo users can skip `--remote` and add it later with
`motherflame config set sync_remote <git-url>`.
### Two ways to run
| | No API key | With your AI key (`setup`) |
|---|---|---|
| Harvest | keyword extraction (works, lower precision) | LLM extraction (high quality) |
| Chat / query | β | full agentic chat |
| Everything else | β
| β
|
---
## What it does
| | Feature | What it means |
|---|---|---|
| π§ | **Org Brain** | One structured knowledge base β company, product, team, voice, strategy |
| π€ | **Agent chat** | A real tool-using agent (not Q&A) that reads *and writes* the brain |
| π | **Planning** | `/plan` breaks a goal into steps, then executes them autonomously |
| πΎ | **Smart harvest** | LLM extraction from your files (keyword fallback when offline) |
| β»οΈ | **Freshness** | `/refresh` re-scans only files that changed since last time |
| βοΈ | **Conflict resolution** | Two-layer brain (claims β canonical); a resolution ladder settles contradictions instead of last-write-wins |
| π
| **Trust scoring** | Every fact is scored by source authority Γ human-verification Γ staleness Γ confidence β the most *trustworthy* claim wins, not the newest |
| β
| **Human verification** | `verify` marks a fact human-confirmed; ranked above unverified LLM guesses |
| π°οΈ | **Temporality** | Facts carry `valid_from`/`valid_until`; ask "what was true on date X" |
| π₯ | **Review queue** | Optionally gate machine-extracted facts for human approval before they enter the canonical truth |
| π | **Zero-knowledge team sync** | `push`/`pull` your brain across the team β AES-256-GCM encrypted client-side |
| π | **MCP server** | Connect Claude Code, Cursor, or any MCP agent to your Org Brain |
| π§© | **Connectors** | A pluggable interface so any source (Slack, Notion, Driveβ¦) can feed the brain |
| π | **Eval harness** | Golden Q&A β precision@k / recall, so retrieval changes are measured not guessed |
| π | **Provenance** | `/sources` + `/history` β know exactly what was scanned and where every fact came from |
| π©Ί | **Doctor & Team** | `doctor` (flame-themed readiness checklist) and `team` (sync dashboard + invite) |
| πΎ | **Sessions** | Conversations persist; resume context with `--resume` |
---
## Commands
```
Setup
motherflame setup Connect your AI key (Anthropic / OpenAI / Ollama)
motherflame create [name] Start a NEW Org Brain (generates a Flame Key)
motherflame join <key> Join an EXISTING Org Brain (pulls the team's brain)
motherflame connect [key] Low-level: set a Flame Key (prefer create / join)
Core
motherflame Smart entry β splash, or drops into chat when ready
motherflame doctor Flame-themed readiness checklist + hints
motherflame team Team dashboard: key, remote health, members, invite
motherflame research <url> Research a company website β confirm facts β brain
motherflame start Harvest org context (web research + files + interview)
motherflame chat [--resume] Talk to your Org Brain agent (tool-use, planning)
motherflame query "<q>" One-off question (LLM answer, or keyword fallback)
motherflame brain View everything in the Org Brain
motherflame status Connection & brain status
Sync (zero-knowledge)
motherflame push Pull-first, then encrypt & sync your brain to the remote
motherflame pull Pull & merge teammates' context
motherflame config set sync_remote <git-url> Bind a git remote for team sync
Integrate
motherflame mcp Run MCP server (for Claude Code / Cursor / any MCP agent)
```
### In-chat slash commands
Type `/` and pick from a menu, or type the command directly:
```
/plan Plan a multi-step task, then execute it
/harvest Scan folders β add facts
/refresh Re-scan only changed files (freshness)
/optimize Find gaps, duplicates, coverage + AI suggestions
/conflicts Show contested facts (teammates disagree)
/resolve Settle a contested fact β you pick the truth
/verify Mark a fact as human-verified (trusted above LLM guesses)
/forget Retract a fact β tombstoned so it won't return on sync
/review Approve/reject machine-extracted facts in the review queue
/owner Assign who owns a fact/category (their claim wins)
/sources Where each fact came from (provenance)
/history What's been scanned & sent to the brain
/gaps What's still missing
/brain Show the full brain
```
---
## Architecture
```
ββββββββββββββββββββββββββββ
your files ββββββββΊ β harvest (LLM / keyword)β
(md/html/txt/pdf) ββββββββββββββ¬ββββββββββββββ
β fingerprints (freshness)
βΌ
βββββββββββββββββββββββββββββββββββββββββββββββββββ
β ORG BRAIN β
β facts Β· gaps Β· provenance ledger Β· sessions β
βββββββββ¬ββββββββββββββββ¬βββββββββββββββββββ¬ββββββββ
β β β
agent chat MCP server push / pull
(tool-use) (Claude/Cursor) (zero-knowledge sync)
```
**Modules** (stdlib Python; `sync` uses the audited `cryptography` lib):
| Module | Responsibility |
|---|---|
| `core.py` | Commands, harvest, display, the interactive REPL, splash/doctor/team |
| `cli.py` | Argument dispatch + flag parsing |
| `runtime.py` | Agentic tool-use loop + planning (OpenAI + Anthropic), retry/backoff |
| `agent.py` | LLM calls, arrow/checkbox TTY pickers, providers, HTTP retry |
| `conflicts.py` | Claims layer, resolution ladder, canonicalization, review queue, verify |
| `trust.py` | Per-fact trust scoring (authority Γ verification Γ staleness Γ confidence) |
| `tokens.py` | Token-budget ranking β fits the most relevant facts into context |
| `connectors.py` | `BaseConnector` contract + registry (pluggable sources) |
| `eval.py` | Golden Q&A retrieval eval (precision@k / recall / hit-rate) |
| `redact.py` | Best-effort PII/secret redaction before text leaves the machine |
| `ledger.py` | Provenance events + file fingerprints (freshness) |
| `sessions.py` | Persistent chat history |
| `sync.py` | Client-side AES-256-GCM encryption, git/local backends, remote health |
| `mcp_server.py` | JSON-RPC MCP server over stdio (query/list/add/forget/verify) |
| `splash.py` | The launch splash screen (figlet + flame box) |
---
## βοΈ Single source of truth β how contradictions are settled
Most "knowledge bases" do last-write-wins: whoever saved most recently is "right".
That quietly corrupts a shared brain. Motherflame keeps a **two-layer** model:
- **Claims** β every assertion ever made about a key (raw evidence, never overwritten).
- **Canonical** β the single resolved truth, recomputed from claims.
When claims disagree, a **resolution ladder** decides β in order:
1. **Manual** β a human ran `/resolve` and picked the answer. Wins outright.
2. **Owner** β the owner of that fact/category (`/owner`) β their claim wins.
3. **Consensus** β the value the most distinct sources independently assert.
4. **Trust score** β the most *trustworthy* claim (see below), ties broken by recency.
Keys are **canonicalized**, so `pricing` / `price` / `pricing_model` collapse to one
fact instead of drifting into three. Values are normalized too β `$48k`, `48,000`,
and `USD 48000` are treated as the same number.
### π
Trust scoring
Every claim gets a score, so a fresh human-verified fact outranks a confident-but-old
LLM guess:
```
trust = source_authority Γ verification_bonus Γ staleness_decay Γ confidence
```
- **Source authority** β `manual`/`verified` (human) > `chat` > `interview` > file/keyword.
- **Verification** β `verify` a fact and it's ranked above anything unverified.
- **Staleness** β trust decays as a claim ages (configurable half-life).
- **Confidence** β the extractor's own 0β1 score.
### π°οΈ Temporality
Claims can carry `valid_from` / `valid_until`. Ask the brain what was true at a point
in time β essential when pricing, headcount, or policy changes over a year:
```python
resolve_key(brain, "pricing", as_of="2024-06-01") # β last year's price
```
### π₯ Review queue
Turn on `review_required` and **machine-extracted** facts land in a pending queue for
a human to approve or reject before they enter the canonical truth. Human-sourced
claims (chat / interview / manual) skip the gate. Manage it with `/review`.
### β»οΈ Tombstones (CRDT-style delete)
`/forget` doesn't just delete β it tombstones, so a teammate's stale copy can't
resurrect the fact on the next sync.
---
## π§© Connectors β feed the brain from anywhere
Local files are one source; real org knowledge also lives in Slack, Notion, Drive,
Jira, email. Rather than hard-code each, Motherflame defines a tiny contract:
```python
from motherflame.connectors import BaseConnector, Document, register
@register
class MyConnector(BaseConnector):
name = "my_source"
def fetch(self):
yield Document(title="Q3 Plan", text="...", source_id="notion:abc")
```
Core ships a reference `local_files` connector; remote connectors live outside core
so the CLI stays lean. Every `Document` flows through the same extraction, redaction,
claims, and review-queue path β so trust/temporality/PII guarantees apply uniformly.
---
## π Eval harness β measure, don't guess
A brain is only worth feeding to agents if it retrieves the *right* facts. Point a
golden Q&A set at it and get precision@k / recall / hit-rate over the brain's own
retrieval β so you can tell whether a change (new aliases, trust weighting) actually
helped:
```python
from motherflame import eval as mf_eval
report = mf_eval.run(brain, golden, k=3)
print(mf_eval.format_report(report))
```
---
## π©Ί Doctor & π₯ Team
```bash
motherflame doctor # flame-themed readiness checklist: AI Β· Brain Β· Encryption Β·
# Knowledge Β· Team sync β each lit or a dim ember, with a hint
motherflame team # dashboard: Flame Key, remote health (live), members, last
# sync, and a copy-paste invite block for teammates
```
### Set up team sync from chat (no config commands)
You don't have to run `config set sync_remote` by hand β just ask the agent:
```
you βΊ I want my team to share this brain
ai βΊ Sure β do you have a git repo for it, or should I create one?
you βΊ create one
ai βΊ β Created private repo acme/acme-brain and set it as your sync remote (reachable).
Run `motherflame push` to publish; teammates run
`motherflame join mf_acme_β¦ --remote https://github.com/acme/acme-brain.git`.
```
Behind the scenes the agent calls `create_team_repo` (via the `gh` CLI) or
`setup_team_sync` (if you give it a URL), then health-checks the remote β the same
tools are available to external agents over MCP.
---
## π Zero-knowledge sync
Your Org Brain is encrypted **on your machine** before it ever touches the network. The backend only ever sees ciphertext.
- **Key derivation:** `scrypt(flame_key, salt)` β 32-byte key
- **Cipher:** **AES-256-GCM** (authenticated encryption) via the audited
[`cryptography`](https://cryptography.io) library β we deliberately do **not**
hand-roll crypto.
- **Backward compat:** brains written by older versions (a hand-rolled cipher)
are still decryptable, but everything new is AES-GCM.
Wrong key? Tampered bytes? Decryption **fails loudly** (GCM tag check) β never silently returns garbage.
> **On dependencies:** Motherflame's only runtime dependency is `cryptography`.
> For security-sensitive code, a single audited, widely-used crypto library is
> the *right* call β "no crypto dependency" would mean hand-rolling primitives,
> which is exactly what you don't want from a tool that stores company secrets.
```bash
# Solo / single machine (default β zero setup):
motherflame push # encrypt locally β store ciphertext in ~/.motherflame/cloud/
motherflame pull # decrypt locally β merge
# Real team sync β point at a git repo you control:
motherflame config set sync_remote git@github.com:yourco/org-brain.git
motherflame push # commits the encrypted blob to that repo
motherflame pull # teammates pull + merge (their claims survive, never clobbered)
```
The git backend stores **only ciphertext** in your repo β the host (GitHub/GitLab/
self-hosted) never sees your data. Merges union everyone's claims, so conflicting
values surface as *contested* rather than overwriting each other.
---
## π Connect any agent (MCP)
Motherflame speaks the [Model Context Protocol](https://modelcontextprotocol.io). Add it to your MCP client's config:
```jsonc
{
"mcpServers": {
"motherflame": {
"command": "motherflame",
"args": ["mcp"]
}
}
}
```
**Where that config lives:**
- **Claude Code** β run `claude mcp add motherflame -- motherflame mcp`, or edit `~/.claude.json`
- **Claude Desktop** β `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
- **Cursor** β `~/.cursor/mcp.json` (or Settings β MCP)
> If `motherflame` isn't on your PATH (e.g. it's in a venv), use the absolute
> path to the executable as `command` β find it with `which motherflame`.
Exposes seven tools to the external agent: `query_brain`, `list_facts`, `add_fact`,
`forget_fact`, `verify_fact`, `setup_team_sync`, and `create_team_repo`. The agent
decides *when* to call them from their descriptions β e.g. it calls `query_brain`
whenever it needs company-specific facts instead of guessing, `add_fact` to write
something it learned back into the brain, or `create_team_repo` to spin up a private
synced repo for the team. Returns are token-budgeted and carry **provenance**
(`[source: β¦]`), and contested facts are flagged so the agent never states a disputed
value as settled.
> **Read-only mode.** The MCP server has no transport-level auth (it's stdio,
> local by design). If you connect an agent you don't fully trust, run it
> read-only so it can query but not write:
> `MOTHERFLAME_MCP_READONLY=1 motherflame mcp` (or set `readonly_mcp: true` in
> config). All write tools (`add_fact`, `forget_fact`, `verify_fact`) are then refused.
---
## Why Motherflame (vs. the alternatives)
| | Motherflame | Tana | Augment Code | Notion AI |
|---|:---:|:---:|:---:|:---:|
| Harvest from **existing files** | β
| β | β | β |
| **No migration** into a new workspace | β
| β | β | β |
| **Bring-your-own-AI** key | β
| β | β | β |
| **Zero-knowledge** encryption | β
| β | β | β |
| **Conflict resolution** (claims β canonical) | β
| β | β | β |
| **Trust scoring** on each fact | β
| β | β | β |
| **MCP** server for any agent | β
| β
| β οΈ | β |
| Runs as a **CLI** (scriptable) | β
| β | β οΈ | β |
| Cost model | **Self-hosted + your own AI key** | $$$ | $$$$ | $$$ |
---
## πͺΆ Almost zero dependencies
The entire CLI β agent loop, MCP server, TTY pickers, conflict engine β is built on the **Python standard library**. The **one** runtime dependency is [`cryptography`](https://cryptography.io) for AES-256-GCM, because security code should use audited primitives, not hand-rolled ones. Clone it, read it, audit it, fork it.
```python
requires-python = ">=3.9"
dependencies = ["cryptography>=42"] # audited AES-256-GCM β the only one
```
---
## π Privacy: what leaves your machine
Be deliberate about this β it's the difference between safe and sorry:
- **Encrypted sync** (`push`/`pull`) only ever transmits **ciphertext**. Safe.
- **AI harvest** sends the **contents** of the files you scan to your AI provider
(OpenAI/Anthropic/etc). **Bringing your own key does NOT make this private** β
the text leaves your machine. Motherflame masks emails/keys/cards/SSNs with
regex first, but **regex redaction is best-effort, not a guarantee**.
- Motherflame asks for explicit consent before the first AI harvest, and you can
always choose **local keyword extraction** (nothing leaves your machine).
**Do not point AI harvest at folders containing real customer PII or
credentials.** Use keyword mode, or a local model (Ollama), for sensitive data.
---
## Roadmap
**Shipped**
- [x] Agent chat with tool-use + planning
- [x] LLM-powered harvest + freshness
- [x] Zero-knowledge client-side encryption (AES-256-GCM)
- [x] MCP server (query / list / add / forget / verify)
- [x] Git-based team sync (host the encrypted repo yourself)
- [x] Conflict resolution: claims β canonical, resolution ladder, tombstones
- [x] Trust scoring, human verification, temporality, review queue
- [x] Connector interface + reference local-files connector
- [x] Eval harness (golden Q&A β precision@k)
- [x] `create` / `join` onboarding, `doctor`, `team` dashboard, launch splash
- [x] pytest suite + CI (Python 3.9 / 3.11 / 3.12)
**Planned**
- [ ] Live connectors (Slack / Notion / Drive / Jira) on the connector interface
- [ ] Semantic / vector retrieval (today: keyword + token-budget ranking)
- [ ] Watch mode / git hooks β capture context as work happens
- [ ] Per-member identity & access control (today: one Flame Key = shared access)
- [ ] Web dashboard
See [`STRATEGY.md`](STRATEGY.md) for the full product thesis and gap analysis.
---
## Contributing
PRs welcome. The codebase is small, readable, and dependency-free by design.
```bash
git clone https://github.com/opelpleple/motherflame
cd motherflame && pip install -e .
```
---
## License
MIT β see [`LICENSE`](LICENSE). Use it, fork it, ship it.
<div align="center">
**π₯ Light your org's flame.**
</div>
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessSyncing