A self-hosted long-term memory for language models. Same idea as OB1, and built the same way: PostgreSQL with pgvector, where every memory is stored with an embedding and found by semantic search. The difference is that it runs on your own hardware, with a tier that never leaves the local network.
Any client that speaks MCP (or OpenAPI) can search and write the memory. What you know about your systems is written down once instead of re-explained in every conversation.
- A memory is a row. The
thoughtstable comes from OB1, plus atiercolumn. Each row holds the text, structured metadata and an embedding: a vector that describes what the text means. - Writing. On every write the server refuses text that looks like a secret, asks a metadata model for title, summary, kind, project, topics, people and systems, and asks an embedding model for the vector. A fingerprint of the text makes an exact copy update the existing row instead of adding one.
- Searching is semantic. The question gets a vector too, and pgvector finds the closest memories by cosine similarity through an HNSW index. Ranking is hybrid: mostly meaning (0.80), plus full-text matches on title, summary and text, and the memory's review state. A question can find a memory that shares no words with it.
- Receipts. Every search returns a
trace_id, and the client reports which results it used. Memories that keep being used rise in the ranking; ones that are never used are listed for review.
Concepts and diagrams: docs/concepts.md. Details: docs/how-it-works.md.
- Two tiers. Open knowledge is reachable from anywhere through a reverse
proxy. The vault — sensitive context and
SECRET_REFpointers — is served on the LAN only. The tier is decided by the port, never by a header. - A secret gate. Raw passwords, tokens, API keys and private keys are refused on every write path, before the text reaches a model, the embedder or the database.
- Governed memory. Memories written by an agent start as pending evidence, not instructions, until you confirm them. Corrections supersede the old memory and keep it as history instead of deleting it.
- Long text in pieces. A long source is split into proposed atomic memories, and only the ones you approve are saved.
- A session digest.
memory_digestgives every client the usage policy and your confirmed rules once per session, whatever client it is. - Memories at the prompt. A Claude Code hook searches each prompt and adds up to three clear hits to the model's context.
- Contradictions and duplicates. A nightly check asks a model whether pairs of similar memories disagree. Near-duplicates are listed too. You decide each pair on the Review page, or with a model through the MCP tools.
- A change log. A database trigger records every create, update and delete, also from psql. Any version can be restored, and a deleted memory can be restored for 30 days.
- Choose your models. Embedding, metadata and the contradiction check each
use their own provider and model: OpenRouter, OpenAI, Ollama or any
OpenAI-compatible server. A local embedding model such as
bge-m3in Ollama works, and a change of embedding model re-embeds in the background before the switch. - Measured, not guessed. Your own questions measure recall and propose similarity thresholds for each embedding model. Cases with known answers test a contradiction model before it is put to work.
- Home Assistant. Optional MQTT sensors publish counts and health, never content. See docs/home-assistant.md.
- Web UI in English and Swedish, dark or light, for browsing, editing, reviewing, statistics and connecting clients.
Node.js (no web framework), the MCP TypeScript SDK and zod, PostgreSQL 17
with pgvector in the pgvector/pgvector:pg17 image, and Docker Compose. The
web UI is plain HTML and ES modules with no build step.
| Path | What it holds |
|---|---|
db/init.sql |
Schema: tables, pgvector and HNSW index, fingerprint upsert, change-log trigger |
server/index.mjs |
HTTP listeners on three ports, authentication, web API, nightly maintenance |
server/mcp.mjs, server/openapi.mjs |
The MCP tools and the same tools as REST |
server/lib.mjs |
Database access, search and ranking, relations, contradictions, duplicates |
server/memory-model.mjs |
Metadata rules and tool guidance |
server/memory-policy.mjs |
The usage policy: general defaults, and each instance's own text from Settings |
server/ai.mjs, server/model-settings.mjs |
Providers, models, embeddings and re-embedding |
server/secret-gate.mjs |
The check that refuses secrets |
server/public/ |
The web UI |
server/test/ |
Tests (npm test) |
| install.md | Installation on Proxmox LXC, Docker Desktop or Ubuntu Server: configuration, reverse proxy, backups, updates, local embedding model, contradiction test |
| HowToUse.md | Connecting Claude Code, Codex, Claude Desktop, ChatGPT, Open WebUI; what belongs in the memory |
| docs/concepts.md | Concepts and fields, with diagrams: what a memory is, what project, topics, systems and people mean, and what affects what |
| docs/how-it-works.md | Tier boundary, authentication, memory model, search, models, maintenance |
| docs/home-assistant.md | MQTT sensors for Home Assistant |
| tools/hooks/ | Claude Code hook that brings memories to each prompt |
| docs/nginx-brain.conf | Reverse proxy template |
| docs/translations.md | Adding a UI language |
| migrate/ | One-time import of existing notes |
| history.md | What was built, why, and what went wrong |
Addresses in the docs are placeholders.
192.0.2.x(RFC 5737) andexample.net(RFC 2606) resolve to nothing. Substitute your own, and keep real values indocs/deployment.local.md(gitignored).
Requires Docker with Compose. Full instructions: install.md.
git clone https://github.com/Snille/Mimers-Brain.git && cd Mimers-Brain
cp .env.example .env # set POSTGRES_PASSWORD, MCP_ACCESS_KEY, OPENROUTER_API_KEY, CITATION_BASE_URL
docker compose up -d --buildOpen http://localhost:8790, sign in with MCP_ACCESS_KEY, and go to
Connect: it shows ready-to-copy setup for every client, filled in with this
instance's addresses and keys. For Claude Code on the LAN:
claude mcp add --transport http mimers-brain http://192.0.2.41:8790/mcp --header "Authorization: Bearer <MCP_ACCESS_KEY>"The default models run on OpenRouter. Instead of OPENROUTER_API_KEY you can
set any provider on the Settings page. Without an embedding provider nothing
gets a vector, and only listing and text search work.
| Port | Serves | Who may reach it |
|---|---|---|
| 8790 | open + vault, web UI, all tools | LAN/VPN only. Never proxy it. |
| 8791 | open tier, web UI | the only port a public reverse proxy forwards to |
| 8792 | open tier, read-only tools, no UI | a model that may look things up but must not write |
The open and read listeners are built without the ability to reach vault rows, so no parameter, header or path changes what they return. See docs/how-it-works.md.
| Tool | 8790 | 8791 | 8792 |
|---|---|---|---|
memory_digest — usage policy and standing rules; call once per session, again with context for one kind of work |
✓ | ✓ | ✓ |
search_thoughts — semantic search |
✓ | ✓ | ✓ |
list_thoughts, thought_stats |
✓ | ✓ | ✓ |
search + fetch — the pair ChatGPT expects |
✓ | ✓ | ✓ |
report_memory_usage — receipt for a search |
✓ | ✓ | ✓ |
get_media — pictures and links for the media a memory points at |
✓ | ✓ | ✓ |
capture_thought, preview_ingest + apply_ingest |
✓ | ✓ | |
supersede_thought, review_memory, delete_thought |
✓ | ||
propose_context — suggest a context; you confirm it under Settings |
✓ | ||
list_contradictions + dismiss_contradiction — go through the Review page's possible contradictions |
✓ | ||
list_duplicates + resolve_duplicate — go through the Review page's possible duplicates |
✓ |
That is 19 tools on 8790, 11 on 8791 and 8 on 8792. The same tools are
available as REST for OpenAPI clients: GET /openapi.json and
POST /tools/<name> (with fetch_thought instead of search/fetch).
| Page | What it is for |
|---|---|
| Memories | List, hybrid search, facets, reviewing new agent memories with their whole text, editing (on 8790 also moving a memory between the open tier and the vault), contexts and media on a memory, change history with restore, Copy reference and Copy GUID for a chat, pinning memories into the start pack |
| Review | How many memories await review (with a link to them on Memories), duplicates, possible contradictions, rarely useful memories, recently deleted |
| Statistics | A 3D map of the memory (can be switched off), health, recall usefulness, client activity, MQTT status, receipt retention |
| Connect | Setup for every client |
| Settings | Port 8790 only: theme and accent colour, the memory policy, contexts, providers and keys, models, re-embedding, the four similarity thresholds, media sources, and the recall and contradiction measurements |
The UI is served on 8790 (sign in with MCP_ACCESS_KEY) and 8791 (open tier,
behind your authenticator). It loads its text from JSON catalogs, picks the
browser language, and remembers a manual choice.
cd server
npm ci
npm test # database tests are skipped without TEST_DATABASE_URL
npm run audit # read-only quality report on the database in DATABASE_URLDatabase tests need a disposable pgvector Postgres; see the header of
server/testing/db.mjs. A new environment variable must be added to .env.example
and passed under app.environment in docker-compose.yml. A new MCP tool goes
into both server/mcp.mjs and server/openapi.mjs, and in mcp.mjs it gets
annotations that say whether it reads, writes or deletes.
The Compose project, containers and volume keep their old valv names on
purpose; renaming them would start an empty database. See
docs/how-it-works.md.
MIT. See LICENSE.

