
AnchorDB
io.github.jolovicdev由 GitHub 帳號 jolovicdev 發布v1.0.6更新於 Oct 24, 2026
Persistent code memory for AI agents: notes pinned to files and symbols that survive refactors.
概覽
AnchorDB 為編碼代理提供持久化程式碼記憶,把筆記固定到檔案、行範圍與符號上,並在程式碼移動後繼續跟隨。
- 可以做什麼
- AnchorDB 儲存錨點:包含儲存庫、檔案路徑、行列範圍、選取文字以及可選符號路徑的筆記。檔案變動時,它依精確範圍、git 行對應、符號比對與文字上下文重新解析錨點,無法定位的標記為 stale。代理可在編輯前讀取上下文、建立與更新錨點、搜尋筆記、留言,並透過 anchor_context、anchor_create、anchor_search、anchor_stale、anchor_candidates、anchor_relocate 等工具重新固定失效錨點。所有資料保存在一個本機 SQLite 檔案中。
- 適用情境
- 適合需要在編輯檔案或符號前讀取既有上下文的編碼代理、代理之間的工作交接、需要把重現步驟與發現附著在程式碼上的長時間除錯,以及對計費、驗證、遷移、重試邏輯等高風險路徑的審查筆記。
- 執行需求
- 以 stdio 本機程序執行;唯一執行期依賴是 git,提供 Linux、macOS、Windows 預編譯二進位檔、Go 安裝方式(Go 1.25+)與容器映像。MCP 伺服器直接讀取 SQLite 資料庫,不需要常駐程序、帳號、API 金鑰或網路存取。建議為二進位檔與資料庫使用絕對路徑。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 AnchorDB,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
AnchorDB
Code memory for AI coding agents. AnchorDB is an MCP server that stores notes attached to specific code — a file, a line range, a symbol — and keeps them attached as that code moves. The context an agent builds up in one session is still there in the next one.
Point Claude Code, Cursor, or any Model Context Protocol host at it, and an agent can read why a workaround exists before editing it, and leave notes for whoever comes next. Everything stays local: one SQLite file, your git repositories, no network calls, no account.
No account, no API key, and nothing to run in the background. git is the only
requirement; prebuilt binaries cover Linux, macOS, and Windows, and there is a
container image and a Go install path too.
Three ways in, over the same data:
Why
Chat history is a bad place to keep what you learn about a codebase. It scrolls away, it is not attached to anything, and the next session starts blank.
A comment in the source is better, but you cannot leave one everywhere, and much of what matters does not belong in the file: a reproduction for a bug you did not fix, why the obvious refactor is wrong, what broke the last time someone touched this retry loop, where you stopped.
AnchorDB keeps those notes beside the code instead of inside it, and follows the code when it moves. A note pinned to a function is still on that function after you rename it, reorder the file, or move it to another package.
Use cases
- Coding agents that should read context before editing a file or symbol
- Agent handoffs, where one run leaves precise notes for the next
- Long debugging sessions, keeping repros and findings attached to the code
- Review notes on risky paths — billing, auth, migrations, retry logic
- Any codebase where the reason for a decision outlives the person who made it
How It Works
AnchorDB stores anchors.
Each anchor contains:
- repo metadata
- a note body and kind
- a file path
- a line and column range
- selected text plus surrounding context
- an optional symbol path
When files change, AnchorDB re-resolves anchors using the saved span, text context, and symbol information. Tree-sitter improves symbol extraction and relocation, but the system still works without it.
Resolution tries strategies from most to least certain and stops at the first that holds up:
- Exact span — the recorded lines still hold the recorded text.
- Git line mapping — each anchor records the commit its line numbers were
taken against, so
git diffsays exactly where those lines went. This is deterministic where text matching can only guess, and it is the difference between finding the right copy of a duplicated block and finding the first one. The mapping is always verified against the stored text before it is applied, so it degrades safely rather than mis-anchoring. - Symbol match — the same symbol path, scored on how much of its body survived.
- Text and context match — the recorded text found elsewhere in the file, ranked by surrounding context.
An anchor that none of these can place is marked stale and keeps its last
known position. Because the diff is available, a stale anchor can say whether
its code was rewritten in place or deleted outright. Resolution is per-path
and failures are isolated, so one unresolvable file never stops the rest of a
repo from syncing.
Anchors written before this existed have no recorded base commit; they simply skip the git step and fall back to text matching.
Triage
Stale anchors are a queue, not a dead end. AnchorDB ranks the places each one might now belong -- with a confidence score and a code preview -- and lets you accept one:
Relocating re-reads the span from the file, re-derives the symbol at the new position, and re-bases the anchor onto the current commit, so the next automatic pass can follow it through git again. To re-pin somewhere the suggestions missed, give an explicit range instead:
The same loop is available to agents over MCP (anchor_stale,
anchor_candidates, anchor_relocate), so a run that refactors code can re-pin
the notes it left behind. In the web viewer it appears as a review panel on each
stale anchor.
History
Every move, stale, and update is recorded with its reason and confidence, and that history is readable everywhere:
It answers "why is this note here?" — for example created, then
moved · git line mapping, then stale · the anchored lines were deleted or restructured. Resolution passes that change nothing record nothing, so the
history stays signal.
Paths are always interpreted as repo-relative and confined to the repository:
requests that try to escape the root, follow a symlink out of it, or read .git
are rejected. Git refs that would be parsed as command-line options are refused
for the same reason.
Built-in symbol extractors:
- Go
- Python
- JavaScript
- TypeScript
Install
git is the only runtime requirement. Every release ships prebuilt binaries for
Linux, macOS, and Windows, so a Go toolchain is only needed if you build from
source.
Only anchordb-mcp is needed to use AnchorDB from a coding agent. anchorctl
and anchord add the command-line client and the web viewer.
Download a binary
Linux and macOS:
That fetches the archive for your platform, verifies it against the release
checksums, and installs into ~/.local/bin. Set ANCHORDB_INSTALL_DIR to put it
somewhere else, or ANCHORDB_VERSION to pin a version.
To do it by hand instead, take the archive for your platform from the
releases page, unpack it, and
move the binaries onto your PATH. checksums.txt in each release covers every
archive.
With Go
Requires Go 1.25 or newer.
From a local checkout:
If the installed command is not found afterwards, the Go bin directory is not on
your PATH:
With Docker
Anchors record absolute repository paths, so mount each repository at the same path it has on the host — otherwise the paths stored in the database will not match anything the container can see. The container is only worth the trouble in CI or a sandbox; a binary on the host is simpler everywhere else.
Verify
Where to keep the database
One database holds many repositories. A stable per-user location works well:
Use ~/.anchordb/anchor.db in the commands below. Keep it out of your
repositories — it is local state, not source, and does not belong in git.
Install with a coding agent
If you would rather have an agent do this, point it at this repository and say "install this". The steps below are written to be followed directly.
1. Check prerequisites. go version (needs 1.25+) and git --version. If Go
is missing, stop and ask before installing a toolchain.
2. Install the MCP server.
3. Find the binary. go env GOBIN, or $(go env GOPATH)/bin if that is
empty. Use the absolute path in step 5 rather than editing shell profiles.
4. Choose a database path. mkdir -p ~/.anchordb and use
~/.anchordb/anchor.db. Do not put it inside the user's repository.
5. Register the server. For Claude Code:
For any host using mcpServers JSON, merge — do not overwrite — the entry shown
under Claude Code Setup. Absolute paths only; most hosts do
not expand ~.
6. Verify. anchordb-mcp --version should print a version. Restart the host
and confirm anchor_context appears in the tool list. If it does not, the config
was not picked up: check you edited the config for the host that is running, and
that it fully restarted.
7. Register the repository with the repo_add tool, or:
Report the returned repo ID to the user; most commands take it.
Using it well
Read before editing. Call anchor_context with the repo ID and file path before
modifying a file. Anchors record what the code does not say — why a workaround
exists, which invariant a function holds, what broke last time. Skipping that is
how the same bug gets reintroduced.
Write what is durable and non-obvious. Good anchors: a constraint the types do
not enforce, why an appealing simplification is wrong, a reproduction for a bug
you did not fix, handoff state when stopping mid-task. Set author to identify
yourself, for example agent://claude.
Skip what the code already says. A note restating a function signature is noise, and noise buries the anchors that matter.
Re-pin what you break. After a refactor, call anchor_stale for the repo. Use
anchor_candidates to see suggested new locations and anchor_relocate to
accept one, or give an explicit line range if you know better. Leaving stale
anchors behind makes the next run worse than the last.
Do not commit the database, and do not delete anchors you did not create without asking.
Quick Start
Start the server:
Register a repo:
Create an anchor:
Open the viewer:
Start the MCP server:
CLI
anchorctl talks to the running HTTP server.
It reads the base URL from ANCHOR_DB_URL. Default:
Repo Commands
Add a repo:
List repos:
Get one repo:
Sync one repo:
Remove one repo:
Anchor Commands
List anchors:
Get one anchor:
Create an anchor:
Update anchor metadata:
Archive an anchor:
Reopen an anchor:
Re-run anchor resolution:
Context, Comments, Search
Get file or symbol context:
List comments:
Add a comment:
Full-text search:
Queries are treated as literal text, so punctuation-heavy terms such as C++,
don't, or retry (v2) are safe to search for. Multiple terms are ANDed, and a
trailing * performs a prefix search:
All CLI commands return JSON.
HTTP API
Default listen address:
Endpoints
GET /healthGET /v1/reposPOST /v1/reposGET /v1/repos/{repo_id}POST /v1/repos/{repo_id}/syncDELETE /v1/repos/{repo_id}GET /v1/anchorsPOST /v1/anchorsGET /v1/anchors/{anchor_id}PATCH /v1/anchors/{anchor_id}POST /v1/anchors/{anchor_id}/closePOST /v1/anchors/{anchor_id}/reopenPOST /v1/anchors/{anchor_id}/resolveGET /v1/anchors/{anchor_id}/commentsPOST /v1/anchors/{anchor_id}/commentsGET /v1/anchors/{anchor_id}/eventsGET /v1/anchors/{anchor_id}/candidatesPOST /v1/anchors/{anchor_id}/relocateGET /v1/staleGET /v1/contextGET /v1/searchGET /view
Common Requests
Create a repo:
Response:
Create an anchor:
Update an anchor:
Close, reopen, or resolve an anchor:
Read file context:
Full-text search:
Add a comment:
All API responses are JSON. Validation failures return:
MCP
anchordb-mcp serves the same data over MCP stdio and reads the SQLite database directly. It does not require anchord to be running.
Run it:
Claude Code Setup
On Linux or WSL, Anthropic currently documents two install paths for Claude Code:
- native installer:
curl -fsSL https://claude.ai/install.sh | bash - npm installer:
npm install -g @anthropic-ai/claude-code
After Claude Code is installed, add AnchorDB as a stdio MCP server:
Useful follow-up commands:
Inside Claude Code, use /mcp to inspect configured MCP servers and their status.
Notes:
--scope projectstores the configuration in.mcp.jsonfor the current project--scope localkeeps it private to your local project setup--scope usermakes it available across projects on your machine- everything after
--is the actual server command and its arguments
Equivalent .mcp.json entry:
Once connected, a coding agent can:
- read anchor context before editing a file
- search previous notes and comments
- create or update anchors during debugging
- leave handoff notes for the next run
MCP Tools
repo_addanchor_reposrepo_getrepo_syncrepo_removeanchor_contextanchor_createanchor_updateanchor_closeanchor_reopenanchor_resolveanchor_commentanchor_searchanchor_text_searchanchor_eventsanchor_staleanchor_candidatesanchor_relocateanchor_getanchor_commentsanchor_file_view
MCP Resources
anchordb://reposanchordb://repo/{repo_id}anchordb://context/{repo_id}{?ref,path,symbol}anchordb://search{?query,repo_id,path,symbol,kind,limit,offset}anchordb://anchors/{repo_id}{?path,symbol,status,limit,offset}anchordb://file/{repo_id}{?ref,path}anchordb://events/{anchor_id}anchordb://anchor/{anchor_id}anchordb://comments/{anchor_id}
Viewer
The web viewer shows:
- a repo file list
- the selected file with highlighted anchor ranges
- anchor cards and threaded comments
- the Git working-tree diff for that file
Highlighted lines mark anchor coverage. The diff panel shows the actual Git diff for the selected file.
Storage
Everything lives in one SQLite database — anchors, comments, history, and the full-text search index. No server, no external dependency, nothing leaves the machine.
All three binaries read the same file:
Keep it outside your repositories. It is local state, not source.
Back it up by copying the file while nothing is writing, or with
sqlite3 anchor.db ".backup anchor-backup.db".
Troubleshooting
Versioning
AnchorDB follows semantic versioning. All three binaries report the same version:
The database schema migrates forward automatically on open. Anchors created by earlier versions keep working; those written before git-aware resolution simply fall back to text matching until they next resolve cleanly.
Each tagged release builds its binaries on the platform they target, publishes a
checksums.txt covering every archive, and pushes a matching multi-architecture
image to ghcr.io/jolovicdev/anchor-db.
License
MIT. See LICENSE.
來源:README.md,提交 45b16f6
工具
0版本歷史
1- v1.0.6最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分