OmniMem

官方

一個自託管的 MCP 伺服器,為 AI 代理提供跨工作階段、專案與機器的持久記憶。

你可以用 OmniMem MCP 做什麼?

為您的 AI 代理提供跨工作階段、專案與機器的持久、自架記憶體——要求它「在建議一個已經失敗的函式庫之前,先檢查一下墳場」。

  • 工作階段簡報 — 要求提供 briefing,即可在一次呼叫中取得專案背景、經驗統計、過時記憶、新文章與技能建議。
  • 避免重蹈覆轍 — 讓代理在建議先前失敗的函式庫或模式之前,先檢查墳場。
  • 回顧過往決策 — 使用 recall 來呈現先前工作階段中跨專案的決策、修正與模式。
  • 記錄得來不易的經驗 — 使用 record_experience 記錄修正,讓那些耗費心力才獲得的教訓,下次更容易浮現。
  • 去重記憶 — 執行 find_duplicates 來標記並批次清理近乎重複的已儲存記憶。
  • 備份您的記憶 — 使用 dump_to_file 將所有內容匯出為您擁有的 JSON 檔案。

文件

Self-hosted semantic memory for AI Agents. Persistent sessions, experience scoring, and a graveyard for dead ends, backed by knowledge acquired from the RSS you read and stored in a Valkey vector search then exposed as an MCP server. https://omnimem.org

Ric Harvey 50fde316a1

Security Scans / Bandit SAST (push) Successful in 7s

Details

Security Scans / Dependency Audit (mcp_server) (push) Successful in 40s

Details

Security Scans / Dependency Audit (rss_worker) (push) Successful in 30s

Details

Security Scans / Dependency Audit (web_ui) (push) Successful in 27s

Details

Security Scans / Test Coverage (push) Successful in 1m23s

Details

Security Scans / Secret Scan (push) Successful in 4s

Details

Docker Build & Push / Build mcp_server (push) Successful in 17m57s

Details

Docker Build & Push / Build web_ui (push) Successful in 15m23s

Details

Docker Build & Push / Build rss_worker (push) Successful in 2m5s

Details

Merge pull request 'v6.4.x' (#25) from v6.4.x into main
2026-07-20 01:19:39 +02:00
.forgejo/workflowsci: pin buildx builds to the multiarch builder2026-07-17 15:08:57 +00:00
claude_configfeat: auto skill scan proposes drafts from cross-project lesson patterns2026-07-19 17:50:40 +00:00
docsfeat: auto skill scan proposes drafts from cross-project lesson patterns2026-07-19 17:50:40 +00:00
guideschore: drop the executable bit from the deployment guides2026-07-17 12:09:52 +00:00
mcp_serverci: silence bandit B104 on deliberate 0.0.0.0 test fixtures2026-07-19 23:15:31 +00:00
rss_workerci: silence bandit B104 on deliberate 0.0.0.0 test fixtures2026-07-19 23:15:31 +00:00
scriptsdocs: skill demo playbook — load, compile, demo, and clean up the moo-reports skill2026-07-17 12:28:05 +00:00
web_uici: silence bandit B104 on deliberate 0.0.0.0 test fixtures2026-07-19 23:15:31 +00:00
.env.exampledocs: 6.3.1 — web UI login across changelog, README, env example, dev guide2026-07-13 20:44:03 +00:00
.gitignoretest: push coverage to 99.9% across the whole codebase2026-07-19 19:20:36 +00:00
.gitleaks.tomlci: allowlist gitleaks false positive on valkey test string2026-07-19 23:17:59 +00:00
CHANGELOG.mdchore: bump version to 6.4.2, changelog for the 6.4.2 line2026-07-19 22:38:45 +00:00
CLAUDE.mdchore: bump version to 6.4.2, changelog for the 6.4.2 line2026-07-19 22:38:45 +00:00
docker-compose.hub.ymlfeat: one-line installer script using Docker Hub images2026-07-16 21:29:09 +00:00
docker-compose.test.ymlfeat: add comprehensive test suite with Docker-based test runner2026-03-12 16:44:58 +00:00
docker-compose.ymlfix(oauth+security): refresh-token grace window + harden server surface2026-07-08 10:40:53 +01:00
install.shfix: stop install.sh hanging under curl|bash and add step-by-step progress [skip ci]2026-07-17 16:13:10 +00:00
LICENSEchore: add MIT license2026-03-10 19:42:51 +00:00
OMNIMEM_BUILD_PROMPT.mdfeat: initial project scaffold2026-03-09 22:13:35 +00:00
README.mddocs: repeat the Codeberg development notice in the contributing section2026-07-17 12:10:22 +00:00
TODO.mddocs: add TODO.md with future feature ideas2026-03-17 17:46:16 +00:00

<OmniMem>omnimem.org

Security Scans Docker Build Coverage

開發在 Codeberg 上進行 — 問題與 PR 請到那裡提出。

別再重複經歷同一個 session。

每一次 Claude Code session 都從零開始。沒有你專案的記憶。沒有上週失敗的記憶。沒有你上週二花了三個小時才發現為什麼 onnxruntime 在 Alpine 上會爆炸、最後終於找到可行方案的記憶。

所以你又要重新解釋專案。Claude 又建議同一個壞掉的 library。同樣的警報。同樣的戲碼。你是 Bill Murray,而 Claude 是 Punxsutawney。

OmniMem 解決這個問題。它是一個 self-hosted 的 MCP server,讓你的 AI agent 在 session、專案和機器之間擁有持久記憶。它跑在你自己的硬體上,而且永遠免費。

claude> use onnxruntime for the embeddings

⚠ WARNING: previously abandoned approach

  onnxruntime — SIGILL crash on Alpine musl libc (effort: 4/5)
  → switched to sentence-transformers instead

那個警告來自記憶,不是運氣。你已經付出代價的錯誤,不該再向你收費第二次。


快速上手

提示

一條指令就能從預先建好的 Docker Hub images 啟動完整 stack:

curl -fsSL https://codeberg.org/ric_harvey/omnimem/raw/branch/main/install.sh | bash

然後把你的 agent 指向它 — 快速開始 帶你走完其餘步驟,或直接跳到下方更完整的 快速開始章節。


它記住什麼

五種記憶,在 recall 時全部一起搜尋:

  • Episodic(事件記憶) — 你做的決定、你修的 bug、你發現的模式。那些真正花費心力才學到的東西,不該每天早上重新學一遍。
  • Project context(專案脈絡) — 你的 stack、目標和當前狀態。Agent 每次 session 到達時已經被 briefing 過,而不是從冷啟動開始。
  • Knowledge(知識) — 你設定的 RSS feeds,按排程抓取,由 Claude Haiku 摘要、embedding 後儲存。當上週有相關文章出現時,它會浮現為值得一讀的起點。
  • Preferences(偏好) — 關於你希望如何工作的規範性規則(例如「功能上線後永遠更新 README」),從你的對話中自動萃取,並在適用時浮現。
  • Skills(技能) — 從你在某個領域累積的經驗編譯而成的 SKILL.md 文件,讓 agent 從第一個 prompt 就用你的方式工作。從其他 namespaces 衍生而來,絕不手動編輯,每次變更都經過你的 review。請見 skill compiler。 最頂端的召回結果可能是六個月前另一個專案的決策、昨天的解決方案,或週二晚上出現的文章。只要有用,來源並不重要。

與眾不同之處

不只是帶有 MCP 包裝的鍵值儲存。OmniMem 模擬記憶實際運作的方式:事物會隨時間淡去、有時彼此矛盾,而艱苦得來的經驗會贏得自己的位置。

  • The Graveyard — 每個死胡同都會記錄你嘗試過什麼、為何失敗,以及浪費了多少時間。代理程式在建議函式庫或模式之前會先檢查它。
  • Experience scoring — 花了四次嘗試和一個奇怪的平台變通方案才破解的東西是黃金。越難取得的經驗,下次越容易浮現。
  • Memory lifecycle — ACTIVE → DEPRIORITISED → ARCHIVED → DELETED。「忘記 X」通常意味著不再提起它,而不是將它從存在中抹去。被降級優先順序的記憶可以重新贏回自己的位置。
  • Contradiction detection — 如果新記憶與已儲存的內容相矛盾,OmniMem 會捕捉到。每次寫入時進行快速啟發式檢查,可選透過 Claude Haiku 進行更深入的分析。
  • Semantic deduplication — 幾乎相同的記憶會在寫入時被標記,並透過 find_duplicates() 進行批次清理。
  • One-call briefing — 單次 briefing() 呼叫即可回傳專案上下文、經驗統計、過時記憶、新文章、矛盾警告和技能建議。無需三步驟暖身。
  • The skill compiler — 將強化後的教訓和死胡同濃縮為可載入的技能,並設有提案與接受閘門,讓不良教訓無法默默成為政策。
  • Auto-maintenance — 重複項目歸檔、矛盾標記、過期知識清理,全部在背景執行。
  • Web UI — 從 htmx 儀表板瀏覽、搜尋和管理一切,並提供遙測和 Prometheus /metrics 端點。

每次召回背後的排名公式:

score = similarity x surface_score x recency x experience_weight

四個因素決定回傳什麼。僅靠語意相似度不夠——生命週期狀態、年齡,以及教訓的學習難度都扮演重要角色。


適用於任何 MCP 代理程式

適用於所有代理程式的單一記憶層:claude.ai、Claude Code、Claude Desktop、Cursor、GitHub Copilot、GitLab Duo、AWS Kiro、OpenCode、OpenAI Codex CLI 和 Open Design。


架構

四個容器。沒有任何資料離開你的機器。透過 sentence-transformers 進行本機嵌入,儲存在支援向量搜尋的 Valkey 中,兩個前端入口共享同一個記憶引擎。

flowchart TB
    agent["AI agent<br/>Claude Code · claude.ai · Cursor · Copilot · ..."]
    browser["Browser"]

    agent -- "MCP · Streamable HTTP / SSE · :8765" --> mcp
    browser -- "HTTP · :8080" --> webui

    subgraph stack["Docker Compose stack"]
        mcp["MCP server<br/>Python · FastMCP<br/><i>remember · recall · briefing<br/>compile_skill · record_experience</i>"]
        webui["Web UI<br/>Starlette · htmx · Jinja2<br/><i>dashboard · search · skills<br/>projects · backups · /metrics</i>"]
        rss["RSS worker<br/>feedparser · APScheduler<br/>Claude Haiku summaries"]
        valkey[("Valkey + valkey-search<br/>HNSW vector indexes<br/><i>idx:episodic · idx:project · idx:knowledge<br/>idx:preference · idx:skill</i>")]

        mcp <--> valkey
        webui <--> valkey
        rss --> valkey
    end

完整藍圖——召回管線、儲存模型和設計決策——位於 docs/architecture.md。


自架、開源、屬於你

沒有 SaaS。沒有供應商鎖定。沒有將上下文傳送到他人的伺服器。

  • Valkey 是開源的 Redis 分支。你所有的資料都保留在自己機器上的具名 Docker 磁碟區中。
  • 支援 amd64 和 arm64 的多架構 Docker 映像。它在 Raspberry Pi、AWS Graviton 或 Apple Silicon 上與 x86 一樣運作良好。
  • sentence-transformers 在本機執行嵌入,無需任何 API 呼叫。
  • MIT 授權意味著你可以自由分支、擴充,並在任何地方執行。
  • 單一備份指令呼叫 dump_to_file() 並將所有內容匯出到你擁有的 JSON 檔案。

透過你的反向代理暴露 MCP 連接埠,你使用的每台機器都共享相同的記憶。一次部署,隨處可用——請參閱 docs/remote-access.md。


快速入門

安裝程式會檢查 Docker 是否已安裝、產生安全密碼、寫入合理的 .env,並從預先建置的 Docker Hub 映像啟動一切:

curl -fsSL https://codeberg.org/ric_harvey/omnimem/raw/branch/main/install.sh | bash

或從原始碼建置:

git clone https://codeberg.org/ric_harvey/omnimem.git && cd omnimem
cp .env.example .env
# Set VALKEY_PASSWORD and ANTHROPIC_API_KEY in .env
docker compose up -d

然後將你的代理程式指向它——Claude Code(~/.claude.json):

{
  "mcpServers": {
    "omnimem": {
      "type": "sse",
      "url": "http://localhost:8765/sse"
    }
  }
}

伺服器會透過 MCP 的 instructions 欄位自動將使用指南傳遞給任何連線的代理程式——無需設定檔。網頁儀表板位於 http://localhost:8080。

完整的逐步教學,包括驗證權杖、權限設定和其他代理程式,位於 docs/quick-start.md。


文件

快速入門安裝程式、從原始碼建置、連線你的代理程式
功能深入探討生命週期、墳場、經驗評分、去重、矛盾、簡報
技能編譯器將經驗編譯為可載入的技能
MCP 工具參考全部 30+ 個工具
設定參考每個環境變數
RSS 與知識被動知識攝取與提升
多台機器反向代理、claude.ai 的 OAuth 2.1、疑難排解
網頁介面管理儀表板和 Prometheus 指標
架構容器、召回管線、設計決策
記憶類型規格儲存模型,逐欄位說明
連線指南各代理程式的設定
部署指南macOS · Raspberry Pi · AWS · GCP · Linux + Tailscale Funnel

各命名空間的儲存規格,如果你想確切知道什麼內容由誰寫入 Valkey:概覽 · 情節 · 專案 · 知識 · 偏好 · 技能


貢獻

歡迎提交 Issue 和 PR。開發在 Codeberg 上進行——請在那裡提交 Issue 和 PR。OmniMem 設計為可擴充的,評分管線的結構允許在不觸及核心的情況下新增新的乘數。新的 MCP 工具、額外的命名空間類型,以及替代的嵌入後端都是合理的發展方向。


授權

MIT。可自由使用、分支和修改。沒有企業版、沒有託管版本、沒有任何附加條件。


由 Ric Harvey @ SquareCows Ltd 打造,一家為寧願擁有自己工具的人提供服務的 AI 與自動化顧問公司。