
Memdex
io.github.ChoYugyeong由 GitHub 帳號 ChoYugyeong 發布v0.3.1更新於 Nov 1, 2026
Shared memory for AI coding agents: summaries, symbol map, notes and agent-to-agent messages.
概覽
為 AI 程式代理提供共享記憶的本機 MCP 伺服器:依內容雜湊快取檔案摘要、符號定位、可失效筆記、交接與代理間訊息,全部存於單一 SQLite 檔案。
- 可以做什麼
- 取得工作階段簡報:上次交接、坑點、決策、待辦、未讀訊息與目前的佔用宣告
- 讀取依內容雜湊快取的檔案摘要、儲存新摘要,並定位符號或讀取限定片段
- 以關鍵字(可選本機向量)搜尋筆記、交接與摘要
- 儲存、讀取、確認、置頂或封存與檔案關聯的筆記、決策、坑點與待辦
- 與其他代理協作:宣告檔案佔用、發送訊息、讀取收件匣、留下交接
- 適用情境
- 適合在同一台機器上多個程式代理或多個工作階段共同處理同一儲存庫、反覆重讀相同檔案並重複踩坑的情況。中大型程式碼庫效益最明顯;README 指出約 20 個檔案以下的小型儲存庫用手寫 AGENTS.md 更划算。
- 執行需求
- 以本機 stdio 程序執行,從 PyPI 安裝 memdex-mcp(指令為 memdex,可用 pipx 或 uvx)。需要 MEMDEX_HOME(預設 ~/.memdex)下的本機 SQLite 資料庫,並為每個代理設定 MEMDEX_AGENT 名稱。選用:MEMDEX_PROJECT、搭配本機 Ollama 的 MEMDEX_EMBED 以啟用語意搜尋,以及 Kensaku CLI 路徑。不需帳號或 API 金鑰。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Memdex,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
[memdex — a bookmark in the night ledger]
memdex
Shared, token-saving memory for AI coding agents.
One SQLite file. Zero dependencies. Any MCP client. Claude Code, Codex, Cursor and DeepSeek can all remember the same things — and talk to each other.
[Two agents, one checkout: claim, inbox and handoff in memdex]
[CI] [PyPI] [Python 3.9+] [MIT] [Glama MCP score]
Quick start · How it works · Tools · CLI · Configuration · Comparison · FAQ · 한국어
Every new agent session starts from nothing. It re-reads the same 3,000-token files, re-runs the same searches and re-discovers the same pitfalls — and you pay for every token of it. When several agents work on one machine, they can't see what the others learned, or that another one is editing the same file right now.
memdex is a small MCP server that fixes both:
- A file summary written once stays valid until the file's content changes. Summaries are keyed to the sha256 of the content, not the path. The next session — or the next agent — gets a 100-token summary instead of the 3,000-token file, and is told the moment it goes stale.
- Notes know when they rot. Decisions, pitfalls and handoffs cite the files they're based on; when those files change, the note is flagged.
- Agents coordinate.
claimwhat you're editing,postto other agents, read yourinbox, leave ahandofffor whoever comes next. All worktrees of a repository share one memory.
That response is 1.5 KB. The file is 22 KB. Nothing was sent to any model to produce it.
Listed in the official MCP Registry as
io.github.ChoYugyeong/memdex and on PyPI as memdex-mcp.
On a real 66-file site repo, memdex bench measures 154,105 tokens to read every file versus 3,471 tokens
of outlines — 98% smaller, before an agent saves a single summary. Run memdex bench in your own checkout;
the token count is chars / 4, an estimate, and the ratio is the point.
Quick start
Claude Code (user scope, every project) — when the claude CLI is on PATH, memdex connect runs this
line for you, and prints it when it is not:
Everything else that keeps a config file — Claude Desktop, Cursor, VS Code (GitHub Copilot), Windsurf,
Zed, Cline, Gemini CLI and Codex CLI: memdex connect finds each one that is already installed, merges
mcpServers.memdex into its config (servers.memdex with type: stdio for VS Code,
context_servers.memdex for Zed, [mcp_servers.memdex] for Codex), keeps the rest of the file byte for
byte, and saves a .bak before it writes. A client whose config folder does not exist is reported as not
installed and left alone; a config file it cannot parse is left exactly as it was, and a Zed settings file
with comments gets the block printed to paste instead of being rewritten (a rewrite would drop the
comments). --list shows what is installed and configured without writing, --dry-run shows the writes,
--remove takes the entry out.
--serve-check is the honest end of setup: after writing, memdex starts the server from the entry it
just wrote and speaks MCP to it (initialize, then tools/list), so a wrong path, a missing interpreter or a
database it cannot open is caught now instead of in the agent:
Team scope — put the config in the repo so everyone who clones it gets memdex:
A committed config cannot carry this machine's absolute path, so project scope writes command: "memdex"
and the teammate's PATH has to find it (pipx install memdex-mcp). With the claude CLI on PATH and
--project, the CLI writes .mcp.json itself (claude mcp add memdex --scope project …) and memdex writes
only the VS Code file, so one file never has two owners. --no-claude skips the CLI entirely, and
--client claude-code runs only that step.
By hand, or for a client memdex does not know about:
Give each agent its own MEMDEX_AGENT name; its id becomes name@checkout (e.g. claude@myrepo-wt).
memdex config --agent <name> prints the snippets above, plus an optional Claude Code SessionStart hook
that injects the project brief automatically.
That's it. The server sends its own usage instructions in the MCP initialize response, so agents know
the workflow (brief → file_summary before reading → remember → handoff) without extra prompting.
How it works
Supported outline languages: Python, JavaScript/TypeScript, Vue, Svelte, Go, Rust, Java, Kotlin, Scala, C#, Swift, Dart, C, C++, Ruby, PHP, Lua, GDScript, Elixir, Clojure, Zig, Julia, R, Haskell, Groovy, Protobuf, GraphQL, SQL, shell, PowerShell, Markdown.
How memdex ranks and forgets
Memory that only grows is as useless as no memory: the brief has to pick a few lines out of hundreds. Every
note gets an activation, after ACT-R's base-level learning — the sum of t^-0.5 over its uses, so a note
read five times last week outranks one written yesterday and never touched. Pitfalls and decisions carry a
prior (ignoring them costs more), and --importance raises a note further.
Three things follow from that score:
- Pinned core (
--pin): a small fixed slot at the top of every brief for the handful of facts every session must see — a system prompt written by the agents themselves. - Cold tier: below an activation of −3 a note stays stored and searchable but stops spending brief and
default-search budget. Nothing is deleted;
searchstill finds it. - Reconsolidation: when a note's files or symbols have changed,
noteprints⚠ changed since, andnote(id, "confirm")re-stamps its refs to the current code. Confirming is also a use, so a note that keeps being re-verified keeps its place.
Staleness is tracked per symbol, not per file: a note about Store.claim goes stale when that function
changes, and stays fresh when other functions in the same file change.
When you save a note, memdex compares it against the project's active notes with a 64-bit SimHash over word n-grams. At ≤12 bits of distance it points at the likely duplicate ("similar to #17 — supersede it instead"). The agent decides; memdex never merges memory on its own.
Tools
The 12 tool schemas cost about 1,000 tokens per request. Responses are short plain text — every byte is a token.
CLI
Everything the tools do is also a command, for shell-only agents, hooks and humans:
Locks and shared checkouts
Advisory claims are enough between friendly agents, but they do not stop a git commit. Two commands close that gap:
--exclusive makes the claim a lock: another agent's claim on that path is refused, and their commits are
refused while it is live. --force records the claim anyway and tells them why. Every claim expires, so a
session that dies cannot lock you out forever.
memdex hook install writes .git/hooks/pre-commit (a small sh script that calls memdex hook pre-commit);
it only checks the staged files and only reads the local database:
An advisory claim still commits — it just prints a note. MEMDEX_ALLOW_LOCK=1 git commit … skips the check
for a lock you know is stale, and --force on hook install replaces a hook that memdex did not write.
A commit is late, though: by then the edit already happened. Harnesses that expose a pre-tool hook can refuse
the edit itself. Claude Code has PreToolUse:
The hook reads Claude Code's JSON on stdin, turns tool_input.file_path into a project-relative path, and
exits 2 (blocked, with stderr shown to the model) when another agent holds an exclusive claim there:
Advisory claims print a note and let the edit through, edits outside the checkout are ignored, and
MEMDEX_ALLOW_LOCK=1 bypasses the check. The installer merges into an existing settings.json (backing it
up as .bak) and never rewrites a file it cannot parse. memdex config prints the same snippet.
A lock is a lease with a number. Every grant carries a fencing token and the sha of the file it was taken against, so a lock can be told apart from the one before it — and an edit computed from a stale read is refused instead of overwriting what moved underneath:
--refresh re-stamps your own claim (new token, current sha); it never takes a new lock and never overrides
someone else's.
Measure it on your repo
The first thing anyone asks is "how much does this actually save?". Run it yourself:
--json prints the same numbers for scripts. Tokens are estimated as chars / 4; the ratio is the point,
not the absolute number — and file_summary gets smaller still once agents save real 2–6 line summaries.
Maintenance
One SQLite file is shared by every project on the machine, so it grows. memdex prune drops index rows for
project directories that no longer exist, then VACUUMs:
Configuration
What is never read: files that look like secrets (.env*, *.pem, *.key, *secret*, *credential*,
.npmrc, …), binaries, lockfiles, files over 512 KB and anything git ignores.
Project identity: the git common directory. All worktrees of a repository share notes, messages and claims; each worktree keeps its own file index.
Limits (read this before adopting it)
memdex is honest about what it is not. docs/LIMITS.md takes each item below and records what removing it would take, and which published technique is the cheapest honest answer:
- The bench baseline is generous.
memdex benchcompares "read every file whole" with "take the outline"; a real agent greps and reads slices, so the saving is smaller than 98%.memdex statsreports the usage signal instead (summaries served fresh, notes read by another agent, re-confirmed after a change, cold notes), which is the honest number. The win that does hold is that nobody re-discovers the same file, symbol or pitfall twice. - Nothing is shared between machines. One SQLite file, local only. There is no team sync, no cloud, no SSO — by design, but it does mean it cannot replace a team knowledge base.
- Locks are enforced where memdex is asked, not at the file system.
claim(exclusive=true)refuses other agents' claims, thepre-edithook (Claude Code) refuses the edit, and the pre-commit hook refuses the commit — but memdex cannot stop an editor writing bytes through a path it never sees: a session without the hook, or a tool that edits outside the checkout, can still write. Git is still the source of truth. - A tiny repo may not need it. Under ~20 files, a hand-written
AGENTS.mdis cheaper than any tool. - The first brief on a huge checkout is partial. Indexing runs at about 0.4 ms per file (20,000 files ≈
8 s), but a first read of a fresh clone costs far more on Windows, where the antivirus scans each new file.
So the brief indexes at most
INDEX_BUDGET(2,000) files per call and says how many are left; the next brief continues.memdex indexis uncapped,MEMDEX_INDEX_BUDGET=0lifts the cap,memdex briefnever blocks for more than that one batch. - It is young. One maintainer. Schema v5 with in-place migrations from every earlier version; a database written by a newer memdex is refused rather than silently corrupted. Expect rough edges.
- Outlines are regex-level, not semantic. Python uses
ast; everything else is per-language regexes. Expect good results on normal code and occasional misses in exotic syntax.where_isstill falls back to substring search.
How it compares
memdex is deliberately small. These tools are good at things memdex doesn't try to do, and several of them inspired it.
FAQ
Does anything leave my machine? No. SQLite file, local subprocesses, optional local Ollama. No telemetry.
Who writes the summaries? The agents, when they read a file that has no fresh summary. The server's
instructions ask for 2–6 lines. You can also write them: memdex file path --summary "…".
What if two agents edit the same file? claim warns, it doesn't lock. memdex coordinates; it doesn't
replace git.
How much context does it cost? About 1,000 tokens of tool schemas per request, a few hundred for
project_brief (hard-capped at 4,000 chars; memdex brief --max-chars 0 shows everything).
It pays for itself the first time a file isn't re-read.
Something is broken — what do I run? memdex doctor. It reports the database path, size, schema version,
whether it is writable, whether the current project is indexed, which installed agents carry the MCP entry,
and which optional integrations are on. Add --serve-check and it starts the server the way an agent would
and speaks MCP to it, so "installed but cannot start" shows up as a ✗ instead of a mystery:
Can I see or edit the memory? memdex export writes every note as a Markdown file. The database is plain
SQLite. Delete ~/.memdex to start over.
Why not just a vector database? Exact names beat embeddings for code; embeddings help for fuzzy recollection of notes. memdex does keyword + symbols by default and adds vectors only when you turn them on.
Brand
The identity is Ledger Ribbon: a bookmark left in the file, set in Hahmlet, on the night ledger's ink with one amber rule.
- Logo:
logo.svg· dark ground:logo-on-dark.svg· symbol:symbol.svg - Colour: Ledger Ink
#0e1a1c· Lamp Amber#f0b03f· Bone#ece5d6 - Type: Hahmlet (display) · Gothic A1 (text) · Nanum Gothic Coding (mono) — all OFL 1.1
- Tokens:
tokens.css· guidelines:memdex-guidelines.pdf(13 pages) · notes indocs/brand/
Contributing
Ground rules are short: no runtime dependencies, keep tool descriptions terse (they are tokens on every request), and every outline regex captures the symbol name in group 1. See CONTRIBUTING.md.
memdex was built by Claude Code and DeepSeek working on the same checkout — coordinated through memdex itself.
License
來源:README.md,提交 83228cb
工具
0版本歷史
2- v0.3.1最新Nov 1, 2026
- v0.2.1Nov 1, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分
