# Self-Hosted AI Agent Memory: Zekra, an Open-Source MCP Server

> Zekra gives Claude Code, Codex, Cursor and your own agents one shared, self-hosted memory over MCP. How it works, how to install it, and its limits.

*2026-10-21T07:03:35Z*

# Self-Hosted AI Agent Memory: Zekra, an Open-Source MCP Server

If you want **self-hosted AI agent memory** that Claude Code, Codex, Cursor and your own agents can share, [Zekra](https://zekra.dev) is built for that. It is an open-source memory service that agents reach over MCP. What one session learns, the next one already knows.

![Zekra console](/uploads/sites/1f62359e-3d1f-4722-a08b-85474da4ffa1/media/zekra-gallery-01-hero.png)

## The problem

Every agent session starts empty. You explain the same project decisions again, and a second agent has no idea what the first one found. Notes pile up in files nobody reads, and old facts contradict new ones.

Three things go wrong with naive memory:

- **Duplicates.** The same fact is stored ten times and recall returns all ten.
- **Stale facts.** "We use MySQL" and "we moved to Postgres" both survive. I covered this in [stale memories in AI agents](https://zekra.dev/en/blog/stale-memories-ai-agents-invalidate-supersede-decay).
- **No sharing.** Each tool keeps its own private notes.

## How it works

**Retain.** An agent calls `memory_retain`. Zekra embeds the text, looks up its nearest neighbours, and runs a write decision: ADD, UPDATE, INVALIDATE or NOOP. A contradicted fact is updated instead of duplicated. Nothing is hard-deleted: `forget` soft-invalidates, and history stays queryable.

**Recall.** `memory_recall` mixes dense vectors with multilingual BM25, fused with RRF, then applies a salience nudge, reranking and 1-hop entity expansion. Results come back with citations.

**Brains.** One namespace per project or team, with per-agent grants and access tokens (`cbt_...`) enforced on the server.

**Knowledge graph.** Entities and typed relations are extracted from memories, with traverse, neighbors, path and ontology queries.

**Also in the box:** data-source connectors (`text`, `markdown`, `crawler`, `github`, `sql`, `webhook`), chat with a brain that answers with citations, knowledge gaps, a secrets vault, an activity log and a web console.

**Storage:** PostgreSQL with VectorChord, BM25 and pgvector, a Redis L1 cache and an object-store cold tier.

## Screenshots and video

![Zekra feature screenshot](/uploads/sites/1f62359e-3d1f-4722-a08b-85474da4ffa1/media/zekra-gallery-02-feature.png)

![Zekra feature screenshot](/uploads/sites/1f62359e-3d1f-4722-a08b-85474da4ffa1/media/zekra-gallery-03-feature.png)

![Zekra feature screenshot](/uploads/sites/1f62359e-3d1f-4722-a08b-85474da4ffa1/media/zekra-gallery-04-feature.png)

![Zekra get started screenshot](/uploads/sites/1f62359e-3d1f-4722-a08b-85474da4ffa1/media/zekra-gallery-05-get-started.png)

Watch the demo: [Zekra on YouTube](https://youtu.be/juky4ieH018). Voice-over: AI-generated.

## Getting started

From the README:

```bash
curl -fsSL https://app.zekra.dev/install.sh | sh     # installs the `zekra` CLI
zekra auth login --token <cbt_...>
zekra mcp:install claude-code                        # or claude-desktop | codex | gemini | cursor
```

Then ask your agent to retain a decision and recall it from a fresh session. The MCP tools include `memory_retain`, `memory_recall`, `memory_get`, `memory_forget`, `memory_share`, `memory_edit`, `graph_*`, `memory_gaps`, `brain_*`, `secret_*` and `datasource_*`. The docs list 24 tools through the `zekra` CLI and 31 through `zekra-mcp`; see [the docs](https://zekra.dev/en/docs) for the exact set.

To run it yourself, follow the [self-hosting guide](https://github.com/fadymondy/zekra/blob/main/docs/self-hosting.md) in the repository.

## Honest limits

- Self-hosting means you run PostgreSQL with the VectorChord extensions, Redis and an embedding server. It is not a one-line install.
- Zekra is licensed AGPL-3.0-only. If you run a modified version as a network service, you must offer its users the source.
- I have not published retrieval benchmarks, so I make no accuracy claims.
- The agent decides what to retain. Zekra does not read your mind.

## FAQ

**Which agents can use Zekra?** Any MCP client. The CLI installs the server config for Claude Code, Claude Desktop, Codex, Gemini and Cursor.

**Can I self-host it?** Yes. It is open source under AGPL-3.0-only and runs on PostgreSQL with VectorChord, Redis and a TEI embedding server.

**What happens when a fact changes?** The write decision chooses ADD, UPDATE, INVALIDATE or NOOP, so contradicted facts are updated instead of duplicated. Nothing is hard-deleted.

**Does it work in Arabic?** Recall uses a multilingual BM25 index and a multilingual embedding model, and the product is built for Arabic and English. I have not published a benchmark.

**Does it replace my agent's own context?** No. It is a shared store the agent reads and writes through tools.

## Next steps

- Set it up for Claude Code: [Claude Code memory that survives sessions](/en/blog/claude-code-memory-across-sessions-mcp)
- How it is built: [Zekra on ToGO, a case study](https://to-go.dev/en/blog/zekra-togo-case-study)
- The story: [Why I built Zekra](https://fadymondy.com/en/blog/why-i-built-zekra)
- Code: [github.com/fadymondy/zekra](https://github.com/fadymondy/zekra)
- Product Hunt: [Zekra](https://www.producthunt.com/products/zekra)
- Community: [Discord](https://discord.gg/99JBJd6FsR)

---

Source: https://zekra.dev/en/blog/self-hosted-ai-agent-memory-server
