
Cortex Memory Engine
io.github.gambletan由 GitHub 帳號 gambletan 發布v1.8.0更新於 Nov 3, 2026
Local-first AI memory engine — 4-tier memory, people graph, Bayesian beliefs. Encrypted, 62µs.
發布方自己的服務:Memory.fit
概覽
本地優先的記憶引擎,讓 AI 助理擁有保存在本機 SQLite 檔案中的持久化結構化長期記憶。
- 可以做什麼
- 在四個記憶層級中儲存、檢索記憶,並產生受 token 預算限制的上下文,支援批次寫入、壓縮、衰減、整併、封存、還原與刪除。
- 記錄與查詢結構化事實、偏好與貝氏信念,並偵測事實矛盾。
- 跨頻道解析、列出與合併人物身分,並從文字中擷取關係。
- 啟用、檢視並拉取經使用者自有雲端儲存的端對端加密同步,並設定單筆記憶的隱私等級。
- 適用情境
- 適合希望助理跨工作階段、跨頻道記住偏好、事實與過往對話,又不願把個人資料交給託管記憶服務的情境。適用於個人代理、Claude Code 或 Desktop、LangGraph 以及需要本機記憶層的多代理系統。
- 執行需求
- 以本機程序執行;清單列出透過 stdio 執行的 Docker 映像(ghcr.io/gambletan/cortex),README 另提供 Homebrew、Rust/cargo 建置與本機 HTTP 服務方式。本機使用不需帳號或 API 金鑰。裝置端語意檢索會在首次寫入時從 Hugging Face CDN 下載約 30 MB 模型,除非以 CORTEX_NO_EMBEDDINGS=1 關閉。選用同步需要來自 macOS 鑰匙圈或環境變數的通行碼。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Cortex Memory Engine,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Cortex
🧠 Try Cortex in your browser — zero install, 124KB WASM, runs entirely client-side.
If Cortex helps your AI remember, give it a ⭐ — it takes 1 second and helps others discover the project.
Local memory for personal AI agents.
Private. Free. Local. — a memory engine for personal AI agents.
Your AI's memory archive lives on your device. Pure Rust. 3.8MB binary. The local engine needs no hosted service and collects zero telemetry. Optional encrypted sync uses your own cloud storage; optional Muse sharing sends only the excerpts you approve to Cortex Cloud and Meta. (On-device semantic search downloads a ~30MB model once on first use, then runs fully offline — or go 100% offline with CORTEX_NO_EMBEDDINGS=1. See Security & Privacy.)
[Cortex remembering across sessions — a real, local cortex-mcp-server recording]
What you get
- 🔒 Private by default — memories live in a local SQLite file; sync and Muse sharing require explicit opt-in. Zero telemetry (CI-enforced).
- 🧠 Real memory, not a text file — 4 tiers, multi-signal retrieval, self-correcting Bayesian beliefs, a cross-channel people graph.
- ⚡ Sub-millisecond — 156µs ingest, 568µs search. ~528× faster than cloud memory APIs, with no network round-trip.
- 🔌 Drop-in for any agent — one MCP server gives Claude Code / Claude Desktop (or any MCP client) persistent cross-session memory.
- 🤝 Connect Meta Muse to chosen excerpts — your archive stays local. The optional service at
https://cortex.alvinsclub.aiserves only your approved export, with daily disclosure limits and revocation. The server and Meta can read shared excerpts. Setup and privacy limits → - ☁️ Yours across devices — optional end-to-end-encrypted sync through your own iCloud / Drive / Dropbox; this sync needs no Cortex server.
See it remember across sessions — ~30 seconds:
Tell Claude "remember I deploy on Fly.io and always run tests before pushing." Open a brand-new session and ask "how do I deploy this project?" — it answers from memory, 100% on your machine.
⭐ If that's useful, give it a star — it helps others find a memory engine that respects their privacy.
LLMs start blank every session — they forget your name, your preferences, yesterday's conversation, last week's decision. The usual fixes are flat text files (no ranking, no decay), keyword grep, or cloud APIs that add 200–500ms, charge you, and ship your personal data to someone else's server. Cortex gives your AI structured, self-evolving long-term memory that persists across sessions and channels — all local, all yours. Your memories are not a cloud provider's training data, a startup's monetization asset, or a surveillance target.
Cortex vs Mem0 vs OpenAI Memory
Performance Benchmarks
528x faster than Mem0 cloud. With features neither Mem0 nor OpenAI Memory offer.
Note: Benchmarks include proactive inference (auto-extracting facts, preferences, relationships) on every ingest. Raw ingest without inference is ~15µs. Numbers from
cargo benchon M-series Mac.
LoCoMo Benchmark (ACL 2024)
Academic-grade long-term conversation memory evaluation — 10 conversations, 1540 QA pairs across 4 categories.
Key findings:
- Open-domain 88.8% — leads Mem0 (72.9%) by +15.9%
- Temporal 74.1% — leads Mem0 (55.5%) by +18.6%
- Single-hop 72.5% — leads Mem0 (67.1%) by +5.4%
- Multi-hop 59.5% — leads Mem0 (51.2%) by +8.3%
- Overall 73.7% — beats Mem0 (66.9%) by +6.8%, beats OpenAI Memory (52.9%) by +20.8%
Cortex outperforms Mem0 on all 4 categories — while running 100% locally, end-to-end encrypted, at $0 cost.
Setup: Claude Sonnet 4 (QA + judge), nomic-embed-text (embeddings via Ollama), top-30 retrieval. Reproducible with that setup:
python3 bench/locomo_bench.py(needsANTHROPIC_API_KEY+ a local Ollama withnomic-embed-text). Numbers measured on the v1.7 engine; the v2.2 retrieval beam fix (paraphrase recall 40%→90% at 5K, seedocs/scale-test-2026-06-13.md) has not yet been re-run on LoCoMo, so these are reported as the last verified figures, not a v2.2 claim.
Architecture
Cortex implements a 4-tier memory model inspired by human cognition:
Working holds the current session scratch pad. Episodic stores raw experiences with timestamps and source metadata. The Consolidation Engine periodically promotes recurring patterns into Semantic facts and decays stale episodes. Procedural captures learned workflows and routines.
Bot integration architecture
For a hosted Bot with existing PostgreSQL memory and account permissions, Cortex is an optional derived retrieval backend behind its MemoryManager. PostgreSQL remains the authority for confirmed values, scope, provenance, revisions and withdrawal; ContextProjector remains the single model-context composer, and Workflow keeps execution and approvals. Search hits must pass current authoritative validation before entering model context. A controlled projection store must not import personal archives or enable sync, automatic inference or consolidation by default.
The controlled API contract documents the implemented
ControlledStore Python interface, snapshot/replay lifecycle and error codes. The
implementation plan separates Cortex-side
acceptance from host-owned PostgreSQL and Bot integration. Package publication and Bot
deployment are separate steps; existing personal-agent interfaces remain available.
Key Components
People Graph
Cross-channel identity resolution. The same person messaging you on Telegram, emailing you, and showing up in calendar events gets unified into a single identity node. Interactions, relationship strength, and communication patterns are tracked per-person.
Bayesian Belief System
Self-correcting understanding of the world. Beliefs are formed from evidence, updated with each new observation, and can be contradicted. Confidence scores reflect actual certainty rather than recency bias.
Consolidation Engine
Episodic-to-semantic promotion, decay of stale memories, and pattern extraction. Runs as a background cycle that keeps the memory store lean and queryable. Returns a report of what was promoted, decayed, and merged.
Multi-signal Retrieval
Queries combine five signals for relevance ranking:
- Similarity -- vector cosine distance against query embedding
- Temporal -- recency weighting with configurable decay
- Salience -- importance scoring from access patterns and explicit hints
- Social -- boost for memories involving specific people
- Channel -- filter or boost by source channel
Context Injection Protocol
Generates LLM-ready context strings from memory state. Pass a token budget, optional channel/person filters, and get back a structured text block your LLM can consume directly.
Storage
SQLite for persistence, in-memory vector index for fast similarity search. Single-file database, no external services required. Designed for edge deployment -- runs on a laptop, a Raspberry Pi, or a server.
Cloud Sync
Sync memories across devices through your own cloud storage — no third-party server involved.
- Changelog-based: Each device writes append-only operation logs to its own subfolder
- No conflicts: Devices never write to the same file. Merge uses Last-Writer-Wins with Hybrid Logical Clocks
- Encrypted: AES-256-GCM encryption (opt-in). Even if your cloud account is compromised, memories stay private
- Tamper-evident: the sync manifest and every operation carry an HMAC; tampered or plaintext-injected oplog lines are rejected, and a manifest without integrity protection refuses to load (no key-rollback path)
- Key rotation & forward secrecy: rotate to a new key version (
ENC2envelopes) without re-encrypting history; old versions stay readable, new writes are unreadable to a leaked old key - Privacy-aware, per-memory opt-in: Private memories (the default) never leave your device. Mark a memory
sharedto sync it; demote it back toprivateand a retraction deletes it from your other devices (local copy kept) - Survives restarts: sync settings persist in the database (passphrase never touches disk — macOS login Keychain or
CORTEX_SYNC_PASSPHRASE); the server resumes sync and starts background pull (30s poll + fs watcher) automatically
Supported providers: iCloud Drive, Google Drive, OneDrive, Dropbox (auto-detected).
Security & Privacy
See SECURITY.md for the full threat model.
Prerequisites
Install the Rust toolchain (provides cargo):
After installation, either restart your terminal or run:
Verify:
Real-World Example: A Personal AI That Actually Remembers
Imagine your AI assistant across a week of real conversations:
All of this happens locally in <1ms per operation. No cloud. No API calls. No one else sees your data.
Install
Homebrew (macOS / Linux)
From source
Official packages (avoid look-alikes)
Cortex is published under the cortex-ai-memory name. Several similarly-named
packages on npm/PyPI are not affiliated with this project — use exactly these:
⚠️ Not us: npm
cortex-mcp, npmcortex-ai-memory(unscoped), PyPIcortex-memory. The source of truth is always this repo —github.com/gambletan/cortex. When in doubt, the binary from Releases is the canonical install.
Quick Start
Python Bindings
Native module built with PyO3, published on PyPI as cortex-ai-memory (pip install cortex-ai-memory):
Integration with unified-channel-hub
Cortex is designed as the memory layer for unified-channel-hub. Messages flow in from any channel adapter, Cortex ingests and indexes them, and the context injection protocol feeds relevant memory back to your LLM before each response.
Integration with LangGraph
Add persistent memory to any LangGraph agent via langchain-mcp-adapters — no custom code needed.
Your LangGraph agent gets instant access to memory_search, memory_ingest, fact_add, belief_observe, person_resolve, and 25 more tools — all running locally.
Integration with DeerFlow (ByteDance)
Cortex works as a persistent memory layer for DeerFlow — ByteDance's open-source multi-agent orchestration platform. Zero code changes needed.
All DeerFlow agents (Telegram, Slack, Feishu) get instant access to 30 memory tools — cross-session memory, fact storage, people graph, and belief tracking across all channels.
CLI
Cortex doubles as a standalone CLI tool — no MCP client required.
Examples:
No subcommand = MCP stdio mode (for Claude Code / Claude Desktop integration).
MCP Server (Claude Code / Claude Desktop)
Cortex ships as an MCP server — works with any MCP-compatible client.
Setup
1. Build & install the binary:
2. Register as MCP server:
Claude Code (CLI):
Claude Desktop — add to ~/Library/Application Support/Claude/claude_desktop_config.json:
3. Allow tools in "don't ask" mode:
Add to ~/.claude/settings.json → permissions.allow:
Note: MCP tool permissions do not support parentheses format (e.g.
mcp__cortex__memory_ingest(*)). Use the wildcardmcp__cortex__*instead.
4. Make it automatic — add to your CLAUDE.md (project or global ~/.claude/CLAUDE.md):
5. Auto-inject memory on session start (Claude Code hooks — fully automatic):
Create ~/.claude/hooks/cortex-memory-inject.sh:
Add to ~/.claude/settings.json:
Now every new Claude Code session automatically loads your memory context — zero manual effort. Claude learns as you work and remembers across sessions.
Cross-Device Memory Sync
Your Claude's memory follows you across all your devices — MacBook, iMac, work laptop — through your own cloud storage.
Enable sync (one command):
On your second device — one script does everything (build/install, wait for iCloud, join, restore):
Or conversationally:
What syncs and what doesn't:
- Private memories (default) never leave your device. Opt in per memory:
memory_ingestwithprivacy: "shared",cortex-mcp-server ingest --privacy shared, ormemory_set_privacyon an existing memory - Demote a shared memory back to
privateand it is retracted (deleted) from your other devices — the local copy stays - All sync data is AES-256-GCM encrypted with HMAC integrity — even if your cloud account is compromised, memories stay private and tampering is detected
- Sync survives restarts: settings persist, the passphrase lives in the OS keychain, the server resumes automatically
- No server, no API, no account — just your own cloud folder
CLI alternative:
Multi-Project Isolation
Working across multiple projects? Use separate databases for physical memory isolation — no cross-project leakage, zero code changes needed.
Global config (~/.claude/settings.json) — user-level knowledge:
Per-project config (~/.claude/projects/<path>/settings.json) — project-specific:
Then add these memory isolation rules to your project's CLAUDE.md:
This gives you two independent Cortex instances per project — complete isolation with shared user knowledge.
30 Tools
Tool access is governed by an optional deny-by-default capability policy: drop a
capabilities.jsonnext to your database ({"version":1,"grants":["read","write"]}) and only granted tool groups (read/write/sync/plugins/all) or exact tool names are listed and callable. No policy file = everything enabled (legacy).
OpenClaw Plugin
Give your OpenClaw agent persistent memory with auto-recall and auto-capture.
Install:
Configure (optional — works with defaults):
What it does:
autoCapture: Automatically stores conversation context after each turnautoRecall: Injects relevant memories before each turn (your agent "remembers")- 7 tools: memory_search, memory_store, fact_add, belief_observe, person_resolve, and more
See openclaw-plugin/README.md for full configuration options.
Project Structure
HTTP API
Cortex ships a lightweight HTTP server for integration with any language or framework. Binds to 127.0.0.1 by default — your data never leaves your machine.
Endpoints
Examples
Roadmap
- v0.2 ✅ — Local embedding integration (all-MiniLM-L6-v2/ONNX), batch queries, importance-aware decay + auto-consolidation
- v0.3 ✅ — Proactive inference (auto-extract facts), temporal awareness, contradiction detection, Chinese NLP
- v0.4 ✅ — HTTP REST API (axum), import/export (JSON backup), Docker packaging
- v0.5 ✅ — Conversation compression, relationship inference (EN + CN), temporal retrieval enhancement, 112 tests
- v1.0 ✅ — Feature comparison table, benchmark update, 18-feature Cortex vs Mem0 vs OpenAI
- v1.1 ✅ — HNSW vector index (50K search: 12ms → 91µs), Python SDK (
pip install cortex-ai-memory) - v1.2 ✅ — Negation detection (EN + CN), multi-hop retrieval, 117 tests
- v1.3 ✅ — Context quality optimization, query expansion, bidirectional relationships, 126 tests
- v1.4 ✅ — Incremental HNSW, SQL-indexed entity queries, LLM summarizer hook, 18 MCP tools, configurable decay, LLM-assisted inference, 131 tests
- v1.5 ✅ — Docker image (GHCR auto-publish), batch ingest, dedup, namespace isolation, plugin system, event bus, archival, 351 tests
- v1.6 ✅ — Int8 quantization (75% storage reduction), materialized column indexes, FTS5 triggers, LRU caches (MemObject + entity-facts), rayon parallel decay, Arc embedding, generation-based cache invalidation, 25 MCP tools, batch inference, enhanced Chinese NLP
- v1.7 ✅ — Cloud sync (changelog-based, HLC ordering, LWW merge), AES-256-GCM encryption (Argon2id KDF), privacy enforcement (Private/Shared/Public), zeroize (memory wiping), SECURITY.md, 27 MCP tools, 400+ tests
- v2.0 ✅ — Background sync (filesystem watcher + polling), Web Dashboard, Homebrew tap, integration docs (CrewAI/AutoGen/LangGraph/DeerFlow),
/v1/memories/recentAPI, 12 rounds Codex review fixes, 489 tests - v2.1 ✅ — WASM build (124KB, runs entirely in the browser, GitHub Pages demo)
- v2.2 ✅ — Security hardening series (self-evolution iterations 11–17): manifest + per-operation HMAC, plaintext-injection rejection, timing-attack hardening, key rotation with forward secrecy (
ENC2), bounded query budget, deny-by-default MCP capability policy, per-memory privacy opt-in with cross-device retraction, persistent sync (Keychain) + auto background sync, frecency ranking, one-shot device setup script, 30 MCP tools, 500+ tests - v2.3 — Mobile targets (iOS/Android), multi-modal memory
If you find Cortex useful, please consider giving it a star ⭐ — it helps others discover the project and motivates continued development!
License
MIT
來源:README.md,提交 de02006
工具
0版本歷史
1- v1.8.0最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
其他 Memory 整合

Memory.fit
fit.memory官方發布者
託管式 Memory.fit 伺服器,讓 AI 讀取你的訓練、睡眠、恢復與飲食資料,並寫回每週計畫、每日目標和飲食計畫。
pg.ddx.io: the PostgreSQL community's memory
io.ddx.pg官方發布者
pg.ddx.io: the PostgreSQL community's memory 的託管 MCP 服務,由 pg.ddx.io 發布;無需登入;Streamable HTTP;29 個工具。
var.gg Naming Memory
gg.var官方發布者
遠端 MCP 伺服器,可依領域概念推薦並檢索韓、日、中、越、英多語言的程式識別字名稱,並提供 ERD 結構查詢。

Counterparts
ai.counterparts
為 Claude Code 與 Claude Desktop 提供的本地優先長期記憶:助理自行寫下關於你與專案的筆記,並在之後的對話中回想起來。

LAHZE - Persian AI Memory Platform
由 GitHub 帳號 pedramgholizadeh 發布
以波斯語為先的地理記憶平臺:發現地點,起草併發布僅限波斯語的記憶。AI 翻譯