Skip to content

aharol/memex

Repository files navigation

memex

"Consider a future device for individual use, which is a sort of mechanized private file and library. It needs a name, and to coin one at random, 'memex' will do." — Vannevar Bush, As We May Think, The Atlantic, July 1945.

memex is persistent memory for AI agents. Tell any MCP-speaking agent — Claude Code, Codex, Claude Desktop, Cursor, anything that talks the protocol — to remember something in one session, and any other agent can recall it in a different session next week. No file format, no schema, no per-session reload, no manuscript pasted into chat.

The product is a single MCP server you run locally. Agents call its remember / cognify tools to write and its recall / search tools to read. memex extracts entities, builds a knowledge graph, embeds chunks for semantic search, and stores everything on your machine.

It is the 2026 implementation of Bush's 1945 idea: a personal device that remembers what you and your agents have learned, so you do not have to re-explain it every time you open a new chat.

What problem this solves

If you have ever felt one of these, memex is for you:

  • Every new agent session starts blind. You spend the first ten minutes pasting context the agent already knew yesterday, just not in this chat.
  • Decisions evaporate between sessions. You worked out a tricky design choice on Monday; on Friday a different agent makes the opposite call because it never saw the reasoning.
  • Reloading context burns tokens. Every editorial pass over a manuscript, every refactor across a codebase, every conversation about a long-running project requires re-feeding the same material into the model.
  • Knowledge is siloed by tool. Claude Code knows what you discussed in Claude Code. Codex doesn't. Both should be reading from the same notebook.
  • Drift. Decisions made in week N silently contradict definitions fixed in week 1. The agent has no way to notice unless you remind it.

memex is the shared notebook. Anything you tell it to remember, any agent can recall — by association, with citations, without you carrying the context yourself.

What it is, mechanically

~/Workspace/memex/
├── docker-compose.yml           (FalkorDB + Cognee MCP — declarative stack)
├── bin/
│   └── memex                    (shell CLI: add / search / status / seed)
├── scripts/
│   ├── seed.py                  (bulk-load a pile of files in one shot)
│   ├── init_db.py               (reset memory)
│   ├── _falkor_patch.py         (in-process compatibility shim)
│   └── ...
├── examples/
│   └── bulk-seeding/
│       └── ambit-labs-book/     (worked example of a seed source)
├── .env                         (LLM + embedding + DB config)
├── .mcp.json                    (drop into a repo to wire any MCP client)
├── pyproject.toml
└── LICENSE                      (Apache 2.0)

The architecture:

                       writes (prompt or bulk)
                                │
       ┌────────────────────────┴──────────────────────────┐
       │                                                   │
  Claude Code, Codex,                              scripts/seed.py
  Claude Desktop, Cursor,                          (one-off bulk load
  any MCP-HTTP client                               of an existing pile
       │                                            of files)
       │                                                   │
       ▼                                                   ▼
  ┌─────────────────────────────────────────────────────────┐
  │   memex MCP server   (http://localhost:1945/mcp)        │
  │   tools: remember · recall · cognify · search ·         │
  │          save_interaction · list_data · forget · ...    │
  │   built on Cognee 1.0, runs in Docker                   │
  └─────────────────────────┬───────────────────────────────┘
                            │
              ┌─────────────┴─────────────┐
              ▼                           ▼
       ┌─────────────┐             ┌─────────────┐
       │  FalkorDB   │             │ Ollama      │
       │  (graph +   │             │ (host)      │
       │  vector)    │             │ qwen2.5:14b │
       │  in Docker  │             │ entity      │
       └─────────────┘             │ extraction  │
                                   │ (ingestion  │
                                   │ only)       │
                                   └─────────────┘
                            ▲
                            │ reads (recall / search)
                            │
       ┌────────────────────┴──────────────────────────────┐
       │                                                   │
  Claude Code, Codex,                              bin/memex search
  Claude Desktop, Cursor,                          (shell CLI for
  any MCP-HTTP client                               pipelines)

Writes and reads use the same MCP surface. Bulk seeding from disk and the shell CLI are conveniences that go through the same MCP tools. There is no agent-specific code path.

Quick start

Prerequisites

  • Docker (Compose v2 — docker compose version should print).
  • Ollama running natively on the host (so it has GPU access). memex defaults to Ollama for the one job it needs an LLM for: ingestion-time entity extraction. No external API key required.
    brew install ollama          # or follow https://ollama.com/download
    ollama serve &
    ollama pull qwen2.5:14b      # the default model in .env; any chat
                                  # model will do — see "Provider model".
  • Python 3.11 only if you want to run the host-side scripts directly. The everyday CLI (bin/memex) and all agent traffic go through the MCP container; no host venv is needed.

Bring the stack up

cd ~/Workspace/memex
docker compose up -d
docker compose ps          # both containers should show healthy

http://localhost:1945/mcp is now serving the MCP transport. Stop with docker compose down (data preserved) or docker compose down -v (data wiped).

Talk to it from the shell

bin/memex status                                            # service health
bin/memex add "Onboarding decision: tabs in Python files."  # write a note
bin/memex search "tabs python"                              # recall it

Talk to it from an agent

Drop .mcp.json into the root of the repo you want the agent to read from:

cp ~/Workspace/memex/.mcp.json /path/to/your/repo/

Or register memex globally with the agent's CLI:

claude mcp add memex --transport http http://localhost:1945/mcp   # Claude Code
codex mcp add memex http://localhost:1945/mcp                     # Codex

Then in the chat, just talk to it:

"memex, remember that we decided to use UUIDv7 for primary keys because the time-ordered prefix makes recent-row B-tree inserts cheap." "memex, what did we decide about primary keys last month?"

The agent picks the right MCP tool (cognify or remember to write, search or recall to read) and uses its own LLM to synthesise the final answer. memex itself never makes an LLM call at query time.

How agents talk to memex

The MCP server exposes 12 tools. The two you will use most:

Tool Purpose
cognify Write: take a chunk of text, extract entities, write to the graph.
search Read: return ranked chunks + graph nodes for a query.

The new "memory" API (Cognee 1.0+) wraps these with session bookkeeping:

Tool Purpose
remember Higher-level write with session linkage.
recall Higher-level read with session linkage.
forget_memory Drop a specific memory or wipe a dataset.
improve Mark interactions for reinforcement.

Plus the operational tools agents rarely need by hand:

Tool Purpose
cognify_status Poll the background ingest pipeline.
list_data Enumerate datasets and document IDs.
save_interaction File the current conversation back into memory as one artefact.
delete Remove a specific document by id.
delete_dataset Drop a whole logical dataset.
prune Wipe everything (use with care).

A typical agent interaction looks like this (you don't write the JSON; the agent does):

User: "memex, remember that the prod migration window is Saturday 2am UTC."

Agent → MCP tools/call:
  name: "cognify"
  arguments: { "data": "Prod migration window: Saturday 2am UTC.",
               "dataset_name": "operations" }
← Background process launched.

User (next week, in a different agent): "When is the migration window?"

Agent → MCP tools/call:
  name: "search"
  arguments: { "search_query": "production migration window time",
               "search_type": "CHUNKS", "top_k": 3 }
← Returns the chunk from last week, with metadata.

Agent (using its own LLM):
  "Saturday 2am UTC, per your note on the operations dataset."

Bulk seeding (optional)

If you already have a pile of files — a docs site, a wiki, a book in progress, an internal knowledge base — you can bulk-load them in one shot instead of pasting into chat. Describe the source with a memex.toml:

[seed]
name = "company-handbook"
root = "~/Workspace/handbook"
include = ["**/*.md"]
exclude = ["drafts/**", "**/.*"]

[chunking]
strategy = "h2_section"
max_tokens = 1024

[ontology]
canonical_terms = ["Authority", "Delegation", "Evidence"]
banned_terms = ["agentic", "AI agent"]

Then:

bin/memex seed examples/bulk-seeding/ambit-labs-book/memex.toml
# or with --reindex to wipe the prior copy first

The CLI stops the MCP container during the seed (Cognee's SQLite metadata is single-writer), runs the bulk load in an ephemeral container, and restarts MCP. After it finishes, every agent connected to memex sees the new content.

The examples/bulk-seeding/ambit-labs-book/ directory is a worked example you can fork. The corpus itself is not bundled with memex; the memex.toml points at the author's private filesystem path.

Connecting agents

memex is a regular MCP server on HTTP. Anything that speaks MCP can use it.

Claude Code

Project-scoped (only this repo sees memex):

cp ~/Workspace/memex/.mcp.json /path/to/your/repo/

User-scoped (every Claude Code session, any directory):

claude mcp add memex --transport http http://localhost:1945/mcp

Open Claude Code; on first launch in a project-scoped directory it will ask to trust the memex server — approve, and the tools become available.

Codex

codex mcp add memex http://localhost:1945/mcp

(Codex's flags evolve; see the Codex MCP docs for the current syntax.)

Claude Desktop / claude.ai

Add memex to Claude Desktop's MCP config under Settings → Developer → Edit Config:

{
  "mcpServers": {
    "memex": {
      "type": "http",
      "url": "http://localhost:1945/mcp"
    }
  }
}

Cursor / Continue / other MCP clients

memex speaks the standard MCP Streamable HTTP transport (2025-03-26). Any client that supports HTTP MCP transports can point at http://localhost:1945/mcp. Consult the client's MCP setup instructions; the URL and protocol are all you need.

Generic HTTP

The wire protocol is documented at modelcontextprotocol.io. If your tool isn't on the list above but speaks MCP-HTTP, it works.

Provider model

memex returns raw retrieval results (chunks, graph nodes, citations) — not LLM-synthesised natural-language answers. The calling agent does the synthesis with its own LLM and its own credentials. That makes memex provider-agnostic at query time and lets the same graph serve agents on different LLMs.

Claude Code  →  memex MCP  →  raw chunks + graph nodes
                ↓
                Claude (your existing Anthropic subscription) writes the answer

Codex        →  memex MCP  →  the SAME raw chunks + graph nodes
                ↓
                GPT (your existing OpenAI key) writes the answer

memex uses an LLM for one job only: ingestion-time entity extraction, which runs in the background when you call cognify / remember (whether from an agent prompt or bin/memex seed). Default: local Ollama (qwen2.5:14b) — zero per-token cost, zero API key, manuscript text never leaves the host. Configure LLM_PROVIDER / LLM_MODEL / LLM_ENDPOINT in .env to switch (Anthropic, OpenAI, any LiteLLM-supported endpoint).

Embeddings run locally via fastembed with BAAI/bge-small-en-v1.5 (30 MB ONNX model, CPU, 384-dim vectors). No embeddings API is called. This:

  • keeps stored text out of any embeddings vendor's logs;
  • avoids the embedding-symmetry constraint (every agent's query is embedded with the same model that ingested the chunk);
  • removes one whole class of API-key management.

Privacy and what gets stored

memex writes only to local Docker containers and the local .cognee/ directory:

  • Stored locally: the parsed graph, embeddings, and the original content of everything you (or any agent) asked memex to remember. All under .cognee/ (gitignored). Graph data also lives in the named Docker volume memex-falkor-data.
  • Sent off the host at ingestion time: nothing, by default. The default LLM provider is local Ollama and the default embedding model is local fastembed. If you switch LLM_PROVIDER to anthropic or openai in .env, then text chunks are sent to that vendor at ingestion time only — never at query time.
  • Sent to embeddings vendor: nothing. Embeddings run locally.
  • Never stored: your .env, your API keys, anything outside what you explicitly asked memex to remember.

Concepts

  • Memex — Vannevar Bush's 1945 thought experiment for a personal device that retrieves information by association. The conceptual ancestor of hypertext, the web, and modern personal knowledge systems.
  • Cognee — open-source memory framework that ingests text, builds an entity graph, embeds chunks, and exposes search. memex is a thin wrapper that adds a public install story, the MCP boundary, the shell CLI, and the bulk-seeding convenience. See topoteretes/cognee.
  • FalkorDB — Redis-based graph + vector store. memex uses it because Cognee has a community adapter for it; the database is interchangeable.
  • MCP (Model Context Protocol) — Anthropic's open spec for AI-tool / agent-server protocols. Claude Code, Codex, Claude Desktop, Cursor, and many other agents are MCP clients. memex is an MCP server.

Development

docker compose logs -f memex-mcp        # tail the MCP server's logs
docker compose down                      # stop everything (data preserved)
docker compose down -v                   # stop AND wipe the FalkorDB volume
.venv/bin/python scripts/init_db.py      # reset Cognee system DB (asks first)

Files of interest:

  • docker-compose.yml — service stack: FalkorDB + Cognee MCP. Owns the full lifecycle.
  • bin/memex — shell CLI (add / search / status / seed). Talks to the MCP server over HTTP. Pure stdlib, no extra deps.
  • scripts/seed.py — bulk-load driver. Reads a memex.toml, walks the declared files, calls Cognee through its in-process Python API.
  • scripts/init_db.py — one-shot database reset.
  • scripts/_falkor_patch.py — in-process compatibility shim that rewrites dict-typed query parameters as inline Cypher map literals (works around a wire-format gap between the FalkorDB community adapter and FalkorDB v4.18.4).
  • examples/bulk-seeding/ambit-labs-book/ — worked example seed source.

Status

memex is early personal infrastructure. Public packaging (pip install memex, a homebrew tap, a one-liner installer) is planned once the rough edges from real use have been sanded down. If you fork it for your own agents and your own knowledge, expect to read the source and to file an issue if something obvious is missing.

Naming

The name is from Bush's 1945 essay; the spelling is his. The project is not related to Google Memex (an internal image-search experiment, discontinued 2014) or DARPA's Memex programme (dark-web search, concluded 2017). Both are defunct; the name is fair use of an 80-year-old common noun for a concept that finally has the substrate to exist.

License

Apache License 2.0. See LICENSE.

Copyright 2026 Art Harol.

About

Persistent memory for AI agents over MCP — any agent writes, any agent recalls. Local, model-agnostic, cross-session.

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages