The full upstream README, mirrored here for reference. Install config, tool schemas, adoption signals, and an original overview live on the AnchorDB listing page.
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:
anchordb-mcp | MCP server for coding agents. Talks to SQLite directly; no daemon needed. |
anchorctl | Command-line client for shells, scripts, and CI. |
anchord | HTTP API and web viewer for reading code and notes in a browser. |
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.
AnchorDB stores anchors.
Each anchor contains:
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:
git diff says 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.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.
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.
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:
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.
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.
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:
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.
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.
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.
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.
Start the server:
Register a repo:
Create an anchor:
Open the viewer:
Start the MCP server:
anchorctl talks to the running HTTP server.
It reads the base URL from ANCHOR_DB_URL. Default:
Add a repo:
List repos:
Get one repo:
Sync one repo:
Remove one repo:
List anchors:
Get one anchor:
Create an anchor:
Update anchor metadata:
Archive an anchor:
Reopen an anchor:
Re-run anchor resolution:
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.
Default listen address:
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 /viewCreate 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:
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:
On Linux or WSL, Anthropic currently documents two install paths for Claude Code:
curl -fsSL https://claude.ai/install.sh | bashnpm install -g @anthropic-ai/claude-codeAfter 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 project stores the configuration in .mcp.json for the current project--scope local keeps it private to your local project setup--scope user makes it available across projects on your machine-- is the actual server command and its argumentsEquivalent .mcp.json entry:
Once connected, a coding agent can:
repo_addanchor_reposrepo_getrepo_syncrepo_removeanchor_contextanchor_createanchor_updateanchor_closeanchor_reopenanchor_resolveanchor_commentanchor_searchanchor_text_searchanchor_eventsanchor_staleanchor_candidatesanchor_relocateanchor_getanchor_commentsanchor_file_viewanchordb://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}The web viewer shows:
Highlighted lines mark anchor coverage. The diff panel shows the actual Git diff for the selected file.
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".
| Symptom | Cause | Fix |
|---|---|---|
command not found: anchordb-mcp | Go bin directory not on PATH | export PATH="$PATH:$(go env GOPATH)/bin", or use absolute paths |
| MCP host does not list the server | Config not reloaded | Restart the host fully; check claude mcp list |
not a git repository | Path is not a git checkout | git init, or point at the actual repository root |
path escapes repository root | Path outside the repo, or a symlink leaving it | Use a repository-relative path |
invalid git ref | Ref begins with - | Use a commit SHA, a branch name, or WORKTREE |
Anchors show as stale after a refactor | The code moved beyond automatic matching | Run the triage loop: anchorctl anchor stale |
connection refused from anchorctl | anchord is not running | Start it, or use the MCP tools, which need no daemon |
| Search returns nothing for an exact phrase | Terms are ANDed | Try fewer terms, or a prefix: retry idempot* |
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.
MIT. See LICENSE.