Cross-Agent Memory

io.github.indamices由 GitHub 账号 indamices 发布v1.0.0更新于 Oct 25, 2026

Local-first shared memory for AI coding agents: one searchable store, served over MCP. MIT.

发布方自己的服务:Memory.fit

已验证STDIO仅桌面知识与记忆开发者工具

概览

AI 生成的概览

本地优先的共享记忆服务,索引 AI 编程会话历史与项目文件,让任何支持 MCP 的智能体都能搜索并写入同一份记忆。

可以做什么
跨所有已接入工具与项目进行语义搜索,检索已索引的会话和项目文件(memory_search)。把决策、见解和发现写入共享存储,供后续会话使用(memory_write)。列出集合及其规模(memory_stats)。工具背后是一个本地服务,负责导入 Claude Code、OpenCode、ZCode 的会话存储和已注册的项目文件夹,在本地生成向量并保存在单个 SQLite 库中。
适用场景
当你同时使用多个 AI 编程智能体,希望它们共享此前已确定的决策、解释和发现,而不必反复粘贴上下文时使用。适合单台机器上会话与项目文档不断增长、且需要保持私密与离线的场景。
运行要求
macOS 或 Linux(暂不支持 Windows)、Python 3.10+,以及本地运行的 Ollama 和 bge-m3 等嵌入模型。记忆服务需单独启动;MCP 服务器是本地 stdio 进程,通过 MEMORY_SERVICE_URL 指向该服务,启用鉴权时还需 MEMORY_SERVICE_TOKEN。无需账号或云端访问。
安装前请注意
该服务会索引你的 AI 会话历史以及你注册的任何项目文件夹,请只指向你愿意被检索的目录。若通过 MEMSVC_AUTH 或 MEMSVC_API_TOKEN 启用令牌鉴权,需为 MCP 服务器设置 MEMORY_SERVICE_TOKEN。MCP 工具可向存储写入新的记忆。可选的健康告警可推送到飞书 webhook。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Cross-Agent Memory,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Cross-Agent Memory

One local memory for all your AI coding agents.
Your Claude Code history, Codex sessions, Cursor work, project docs and decisions — indexed once, searchable from every agent, forever yours.

[License: MIT] [Python 3.10+] [CI] [Local-first]

English | 中文

🎬 ▶ Play the full demo (2 min, Mandarin narration)

https://github.com/user-attachments/assets/a8d5d77c-98bc-42f7-9c58-7b48295875fe

[Terminal demo: install, verify, store and search memory — click to play the full video]

Real run: install → verify → store → search. No mock-ups. Click the poster to play the 2-minute narrated walkthrough.


The problem

Every AI coding tool starts from zero.

You spend a week with Claude Code designing an architecture, switch to Codex next week, and it knows nothing about what you decided or why. You paste context again. You re-explain the project. Three tools later, the same conversation has happened five times, and none of it is searchable.

cross-agent-memory fixes this. It runs a small local memory service that:

  1. Ingests your session history from any AI tool (Claude Code / Codex-style CLIs / OpenCode / ZCode / …) and any project folder you point it at.
  2. Indexes everything with local embeddings into a single searchable store.
  3. Serves it back to every agent through an HTTP API or directly as MCP tools — so any MCP-capable agent can recall what every other agent (and you) already figured out.

No cloud. No accounts. Nothing ever leaves your machine.

Features

  • 🔒 Local-first, private by design — embeddings and search run on your machine (Ollama + SQLite + sqlite-vec). Airplane mode is a supported mode.
  • 🧠 Cross-tool by design — connectors for Claude Code, OpenCode and ZCode session stores, plus a generic file watcher for any project/docs folder. Agents share one memory regardless of which tool produced it.
  • 🔌 One-line MCP integration — memory_search, memory_write and memory_stats are exposed over the Model Context Protocol. Claude Code, Codex CLI, Cursor and anything else MCP-capable can use them today.
  • ⚡ Fast at real scale — built for large corpora: sqlite-vec vec0 KNN with a 1-bit coarse recall prefilter and hot/warm/cold tiering. The reference deployment searches 2,000,000+ chunks in 0.36–1.20 s (see measured numbers).
  • 🛠 Ops included — health/monitor endpoints, rolling-window degradation detection, backups & restore, snapshot archiving, tier maintenance scripts.
  • 📈 Battle-tested — extracted from a continuously running multi-agent system where four different AI tools share one memory daily, with millions of chunks and daily incremental indexing.

Architecture

        Claude Code      Codex-style CLI     OpenCode / ZCode      any project             │                  │                  │                  │             ▼                  ▼                  ▼                  ▼      ┌────────────────────────────────────────────────────────────────────┐      │                         Connectors / Indexers                      │      │   incremental watermarks · content-hash dedup · active-session     │      │   skip · unified chunker · local embeddings (Ollama, e.g. bge-m3)  │      └────────────────────────────────────────────────────────────────────┘                                      │                                      ▼      ┌────────────────────────────────────────────────────────────────────┐      │                      SQLite memory store (single file)             │      │   chunks (source of truth)  ├─ vec0 KNN index (sqlite-vec)         │      │   FTS-ready metadata        ├─ 1-bit recall codes (Hamming)        │      │                             └─ hot / warm / cold tier tables       │      └────────────────────────────────────────────────────────────────────┘                                      │                    ┌─────────────────┴───────────────────┐                    ▼                                     ▼        HTTP API (port 5370)                    MCP server (stdio)        /api/search /api/memories               memory_search        /api/stats  /api/health ...             memory_write / memory_stats                    ▲                                     ▲                    └─────────────────┬───────────────────┘                                      │                    every agent you use, in any language/tool

Design notes and the full retrieval pipeline are documented in docs/ARCHITECTURE.md.

🤖 Let your AI agent install it (one paste)

The fastest path: open this repository in your AI coding assistant and paste the block below. It installs everything locally — venv, dependencies, a fresh isolated database — verifies a real write/search round trip, and reports back with exact commands and results. Nothing is sent anywhere; the agent works on your machine only.

text
Install this repository locally. Read AGENTS.md and INSTALL-FOR-AI.md first.Use ./install.sh --dry-run, then ./install.sh. Keep all runtime data isolatedfrom existing databases and bind only 127.0.0.1. Verify initialization twice,Ollama bge-m3, health, and a real write/search round trip using examples/run.py.Add the client instructions from examples/client-instructions.md. Report exactcommands, results and blockers; do not claim success from health alone.Do not import personal projects, restore backups or change system services.

Prefer doing it yourself? The manual path is right below. The same protocol is documented for agents in INSTALL-FOR-AI.md and AGENTS.md.

Quickstart

0. Prerequisites

  • macOS or Linux (Windows is not supported yet — connectors use POSIX file locks)
  • Python 3.10+
  • Ollama running locally (for embeddings)
bash
ollama pull bge-m3            # ~1.2 GB, good multilingual embedding model

1. Install

bash
git clone https://github.com/indamices/cross-agent-memory.gitcd cross-agent-memorypython3 -m venv venv && source venv/bin/activatepip install -r requirements.txt

2. Start the service

bash
python3 server.py# Server listening on 127.0.0.1:5370

3. Give it something to remember

Register any project folder (docs, decisions, notes):

bash
curl -s -X POST http://127.0.0.1:5370/api/register \  -H 'Content-Type: application/json' \  -d '{"root": "/path/to/your/project"}'

The folder needs a .memory-service.yaml or sensible defaults are used — see examples/. Files are indexed immediately; later changes are batched by a debounce window (default 1 hour, MEMSVC_WATCH_DEBOUNCE). For instant pickup: POST /api/reindex {"project": "..."} or start with MEMSVC_WATCH_DEBOUNCE=0.

Or ingest AI-tool session history with a connector:

bash
python3 connectors/index_claude_code.py     # ~/.claude/projects/**/*.jsonlpython3 connectors/index_opencode.py        # ~/.local/share/opencode/opencode.dbpython3 connectors/index_zcode.py           # ~/.zcode/v2/tasks-index.sqlite

4. Search from anywhere

bash
curl -s -X POST http://127.0.0.1:5370/api/search \  -H 'Content-Type: application/json' \  -d '{"query": "why did we choose the tiered storage design", "n_results": 5}'

Or write a memory directly (decisions, insights — great for agent hooks):

bash
curl -s -X POST http://127.0.0.1:5370/api/memories \  -H 'Content-Type: application/json' \  -d '{"items": [{"type": "decision", "content": "We picked sqlite-vec over a server-based vector DB for local-first operation."}]}'

Connect your agents (MCP)

mcp_server.py is a zero-dependency MCP (stdio) server that exposes the memory API as tools. Point your agent at it:

Claude Code

bash
claude mcp add memory -- python3 /ABS/PATH/cross-agent-memory/mcp_server.py

or in .mcp.json:

json
{  "mcpServers": {    "memory": {      "command": "python3",      "args": ["/ABS/PATH/cross-agent-memory/mcp_server.py"],      "env": { "MEMORY_SERVICE_URL": "http://127.0.0.1:5370" }    }  }}

Codex CLI (~/.codex/config.toml)

toml
[mcp_servers.memory]command = "python3"args = ["/ABS/PATH/cross-agent-memory/mcp_server.py"]env = { MEMORY_SERVICE_URL = "http://127.0.0.1:5370" }

Cursor / other MCP agents — same server command and args in that tool's MCP settings. If you started the service with MEMSVC_TOKEN set, also set MEMORY_SERVICE_TOKEN for the MCP server.

Once connected, your agent gets:

ToolWhat it does
memory_searchSemantic search across all indexed sessions/projects of every tool
memory_writeStore a decision / insight / discovery for future sessions
memory_statsList collections and sizes

How retrieval works

Each /api/search request runs a staged pipeline:

  1. Query embedding — computed locally (Ollama), cached by text hash.
  2. Coarse recall — a 1-bit-per-dimension code per chunk is prefiltered by Hamming distance (skipped automatically for small collections).
  3. Exact KNN — sqlite-vec vec0 cosine KNN over the shortlist (falls back to a numpy brute-force path when sqlite-vec is unavailable).
  4. Re-ranking — time decay (30-day half-life) + MMR diversity + a small helpful feedback factor.
  5. Result — text + source + distance + score per hit.

Under the hood it also handles the boring-but-critical parts: content-hash deduplication, per-connector increment watermarks, skipping sessions that are still being written, batch-write pacing, WAL tuning, and stale-index self-healing.

Measured numbers

From the reference deployment (a Mac mini M4 Pro running this service 24/7 for a multi-agent setup):

MetricValue
Indexed chunks2,013,030 across 16 collections
Tools sharing one memory4 (Claude Code, OpenCode, ZCode, OpenClaw)
Sampled /api/search latency0.36 s – 1.20 s (5 production queries, warm cache)
Embedding modelbge-m3 (1024-dim), local Ollama
Storagesingle SQLite file + derived vec0 index (rebuildable at any time)

These are real numbers from a heavy, messy, constantly-growing corpus — not a toy benchmark. Your numbers will vary with corpus size and hardware; on a fresh database everything is sub-100 ms.

API overview

EndpointMethodDescription
/api/pingGETLiveness (no DB access)
/api/healthGETHealth incl. embedding status, disk, degraded reasons
/api/statsGETCollections and chunk counts
/api/projectsGETConfigured projects
/api/monitorGETLatency/cache/disk metrics
/api/searchPOSTSemantic search (query, n_results?, project?)
/api/memoriesPOSTDirectly capture memory items
/api/feedbackPOSTMark a chunk helpful/unhelpful (influences ranking)
/api/registerPOSTRegister a project directory for indexing
/api/reindexPOSTForce re-index (single project or all)
/api/backup / /api/restorePOSTBackup / restore the database
/api/archive-snapshotsPOSTCompress old snapshot files

Full reference with request/response examples: docs/API.md.

Configuration

Everything works with defaults; tune via environment variables when needed:

VariableDefaultPurpose
MEMSVC_PORT5370HTTP port
MEMSVC_DB./memory.dbSQLite database path
MEMSVC_SEARCH_MODEvecvec (sqlite-vec) or legacy (numpy)
MEMSVC_BIT_RECALLon1-bit coarse recall prefilter (off to disable)
MEMSVC_MAX_CONCURRENCY8HTTP worker cap (503 fast-fail beyond)
MEMSVC_STALL_WATCHDOGonDump stacks when a search stalls
MEMSVC_AUTH(unset)1 enables bearer-token auth (writes require Authorization: Bearer <token>)
MEMSVC_API_TOKEN(unset)Bearer secret; setting it also enables auth
MEMSVC_READ_REQUIRES_TOKEN(unset)1 also requires the token for reads
MEMSVC_BACKUP_DIRbackupsDatabase backup directory
MEMSVC_SLOW_THRESHOLD_MS8000Slow-query threshold for health
MEMORY_MISS_LEDGER(disabled)JSONL of zero/low-quality results (write-back candidates)
MEMORY_HITS_LEDGER(disabled)JSONL sampling of top hits per query
CLAUDE_PROJECTS_DIR~/.claude/projectsClaude Code connector source
OPENCODE_DB / OPENCODE_DBS~/.local/share/opencode/…OpenCode connector source
ZCODE_DB~/.zcode/v2/tasks-index.sqliteZCode connector source
MEMORY_SERVICE_URLhttp://127.0.0.1:5370Used by the MCP server
MEMORY_SERVICE_TOKEN(unset)Bearer token if auth is enabled

Operations

  • Health: GET /api/health reports status, disk usage, embedding availability and degraded reasons (e.g. slow queries, disk pressure) — designed to be scraped by a cron/monitor without false alarms.
  • Backups: scripts/backup_silent.py (cron-friendly) or POST /api/backup. Restore with POST /api/restore.
  • Tiering (optional): scripts/migrate_to_vec0.py builds the vec0 index; scripts/tier_rebuild.py builds hot/warm/cold tier tables to keep the hot set small on very large corpora.
  • Snapshot archiving: scripts/archive_silent.py.
  • Health cron with alerts: scripts/health_check.py (optional Feishu webhook support is built in — configure .alert.env).

Design choices (and non-goals)

  • SQLite, not a vector server. One file, zero services, trivially backed up, works offline. The vec index is derived and rebuildable.
  • Local embeddings, not an API. Privacy and zero marginal cost; swap the model in config.py if you prefer something else.
  • Files are the source of truth. Everything indexed can be re-ingested from its source; deleting the database loses nothing that lives on disk.
  • Not a cloud sync product. This is a local service for one machine (multiple agents, one memory). Multi-user/server mode is on the roadmap.
  • Not a vector database benchmark entry. It prioritizes a small dependency surface and operability over raw ANN throughput.

Roadmap

  • Web console (browse / search / curate memories)
  • More connectors: Codex CLI session store, Cursor, Aider, generic JSONL
  • First-class memory types (facts / lessons / code-change context) with extraction pipelines
  • Multi-machine sync for people who work across hardware
  • Python package / Docker image for one-command installs

Issues and PRs are welcome — especially new connectors. See CONTRIBUTING.md.

Acknowledgements

Built on the shoulders of excellent tools: SQLite, sqlite-vec, Ollama, numpy, watchdog.

License

MIT © 2026 indamices

来源:README.md,提交 6e95aed

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.0最新Oct 25, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分

其他 Memory 集成