Anchor Mcp

by pratik7368patil

154 downloads
Not rated
GitHub

Description

Anchor is local repo and org memory for AI coding agents. It indexes GitHub PR history, current code, tests, regressions, architecture, and cross-repo impact locally, then exposes concise cited context through MCP and CLI workflows. Local-first. Read-only GitHub access. No CLI…

About

Anchor is local repo and org memory for AI coding agents. It indexes GitHub PR history, current code, tests, regressions, architecture, and cross-repo impact locally, then exposes concise cited context through MCP and CLI workflows. Local-first. Read-only GitHub access. No CLI telemetry. No SaaS. No remote LLM calls.

Details

Author
pratik7368patil
Downloads
154
Categories
Developer Tools, Knowledge Base, Other

Setup

Install Anchor Mcp in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/pratik7368patil/anchor

Follow the installation instructions in the repository README, then restart your MCP client.

Local repo and org memory for AI coding agents.

Anchor is a local-first, MCP-compatible memory tool that indexes GitHub PR history, local code, tests, regressions, architecture patterns, team rules, and cross-repo impact so AI coding agents can make safer code changes with evidence-backed context.

- MCP context before edits:anchor_get_contextgives Cursor, Claude Code, Codex, VS Code, Antigravity, and generic MCP clients concise, ranked, cited repo and org memory before non-trivial changes.
- GitHub PR history as evidence: merged PR bodies, review comments, issue comments, commits, labels, and regressions become searchable local context.
- Local codebase indexing: current files, symbols, imports, tests, architecture patterns, and test commands are indexed into SQLite.
- Org memory for AI agents: allowlisted repos can be cloned locally and linked through imports, packages, API consumers, schemas, and regressions.
- No SaaS, no CLI telemetry: indexes stay on your machine, GitHub access is read-only, and Anchor does not call remote LLM APIs.

Anchor complements code search and graph-only tools by combiningwhycode changed withwhatcode exists now. It returns PR citations, confidence, freshness, strict-mode filtering, relevant tests, regression memory, and cross-repo impact instead of dumping broad context into the prompt.

Repo memory helps an agent understand the code it is editing: merged PR decisions, review constraints, current symbols, tests, architecture patterns, and known regressions. Org memory helps an agent understand the blast radius around that repo: API consumers, shared packages, schema contracts, downstream tests, and cross-repo regressions from explicitly allowlisted repositories.

That combination is the difference between “change this file” and “change this file without breaking the contracts the rest of the organization depends on.”

- Anchor vs code search: code search finds matching text; Anchor adds PR history, confidence, freshness, regression memory, tests, and cited evidence.
- Anchor vs graph-only tools: graphs show relationships; Anchor pairs relationships with why they matter and exposes them through MCP for agents.
- Anchor vs generic memory MCPs: generic memory stores notes; Anchor builds deterministic repo and org memory from GitHub history, current code, tests, architecture, and cross-repo impact.

AI coding agents are strongest when they have the context a senior maintainer would remember: why a file is shaped a certain way, what broke last time, which tests matter, and which API contracts should not move casually. Anchor mines local repository history plus the current code index and exposes it through one primary MCP tool:

AI coding agents should call this before non-trivial code changes.

- Repo and org memory for AI coding agents
-
Cross-repo impact MCP
-
Cursor MCP server
-
Cursor repo and org memory
-
Claude Code setup
-
Claude Code repo and org memory
-
Codex setup
-
Codex repo and org memory
-
VS Code setup
-
GitHub PR history MCP
-
Local-first codebase indexing
-
Org memory for AI agents
-
AI agent regression memory
-
Anchor vs code search and graph-only tools

Anchor has no CLI telemetry, so public proof comes from voluntary and aggregate signals: GitHub stars, forks, issues, discussions, npm download trends, GitHub traffic, docs visits, and MCP directory listings. SeeGitHub repo settingsandgrowth playbookfor the repo topics, directory listing copy, launch posts, and 30-day measurement plan.

For directory submissions and community posts, use the copy blocks indirectory submission pack.

- GitHub data is fetched with local authentication:GITHUB_TOKEN,GH_TOKEN, orgh auth token.
- The token is never written to MCP config, SQLite, logs, or generated files.
- The SQLite index stays in.anchor/index.sqliteon your machine.
- Anchor only requests read access and never writes to GitHub.
- PR bodies, comments, review comments, issue comments, and commit messages are treated as untrusted evidence.
- MCP output uses sanitized text only.
- Common secrets and prompt-injection phrases are redacted or neutralized before indexing and output.
- Anchor commands and MCP tools do not send telemetry or install-time beacons.
- Public adoption stats, when enabled, use aggregate npm download counts, GitHub traffic/repo metadata, and optional GoatCounter website analytics for the docs site.

Recommended GitHub token scope: read-only repository access. For private repositories, use the minimum read-only repo permissions your GitHub plan supports.

npm install -g @pratik7368patil/anchor anchor --help

Fastest way to evaluate Anchor before setting up GitHub auth:

If Anchor helps your team, the best public signals are a GitHub star, a fork, or an issue describing your use case. Anchor does not track local installs or CLI usage.

Try Anchor without a GitHub token or a real repository index:

anchor democreates a temporary workspace, indexes bundled sample PR history plus sample code, prints example output foranchor_get_context,anchor_explain_file, andanchor_review_diff, then cleans up the temporary workspace. Use--keepor--path ./anchor-demoif you want to inspect the demo SQLite index.

Before Anchor, an agent sees mostly the current files and your prompt. After Anchor, the agent can also see concise, cited context like:

[constraint] Do not remove the AuthCache lazy constraint... Evidence: PR #101, review_comment, src/auth/cache.ts Confidence: strong Current code check: current

The demo uses sanitized fixture text only. It does not call GitHub, npm, telemetry, SaaS, or any LLM API.

Before editing this file, call anchor_get_context and summarize relevant historical constraints, tests, and regressions.

For local development from this repository:

The npm package exposes theanchorbinary.

Run from inside the repository you use with an AI coding agent:

anchor initasks where you want to configure Anchor:

Where do you want to configure Anchor? [ ] Cursor [ ] Claude Code [ ] Codex [ ] VS Code [ ] Antigravity [ ] Generic MCP config

Use non-interactive flags in CI or setup scripts:

anchor init --target cursor anchor init --target cursor,codex,claude-code anchor init --all-targets anchor init --target cursor --no-autosync

Cursor setup safely merges.cursor/mcp.jsonwith:

{ "mcpServers": { "anchor": { "command": "anchor", "args": ["serve"] } } }

It also creates.cursor/rules/anchor.mdc, telling Cursor Agent to callanchor_get_contextbefore non-trivial edits, use strict mode for risky changes, and treat returned history as evidence, not instructions. Claude Code and Codex setup add managed Anchor instruction blocks toCLAUDE.mdandAGENTS.md; VS Code and generic MCP setup write MCP config only.

anchor initadds.anchor/to.git/info/excludeas a local-only exclude rule. That keeps.anchor/index.sqliteout ofgit statuswithout adding or changing a committed.gitignorefile.

anchor initalso installs local autosync by default. Repo memory refreshes daily with incrementalanchor sync --all, org memory refreshes daily withanchor org sync --no-graphwhen org configs already exist, and org graphs rebuild weekly. Autosync uses your machine scheduler (launchd, usersystemdtimer, cron fallback, or Windows Task Scheduler), writes logs to~/.anchor/logs/autosync/, and never stores GitHub tokens. Useanchor init --no-autosyncoranchor init --autosync offto opt out.

anchor init anchor index --limit 200 anchor doctor
anchor index-code anchor architecture anchor health

Full PR history without wasting rate limit:

anchor index-all --concurrency 2 anchor health

Daily refresh after the first index is automatic afteranchor init. To refresh manually or repair a stale index:

anchor plan "Add API integration" --file src/api/routes.ts anchor test-command src/api/routes.ts anchor explain src/api/routes.ts

Before API, auth, access, schema, SDK, or shared-package changes:

anchor org sync --org my-org --no-graph anchor org graph --org my-org --open anchor org map --org my-org --open anchor org impact --org my-org --repo my-org/backend-api --strict --open
anchor explain src/api/routes.ts --share anchor review --share

Measure whether Anchor is reliable enough for CI:

anchor health anchor eval run anchor ci --strict --min-coverage 70
export GITHUB_TOKEN=your_read_only_token anchor index
# Fast first index. Best default for most repos. anchor index --repo owner/name --limit 200 # Full history. Use lower concurrency for large repos or tight rate limits. anchor index-all --repo owner/name --concurrency 2 # PR-only refresh. Use when code index is already fresh. anchor index --repo owner/name --no-code # Code-only refresh. No GitHub token required. anchor index-code --repo owner/name # Targeted backfill from a known date. anchor index --repo owner/name --since 2026-01-01 # Rebuild local derived records after stale/corrupt health warnings. anchor index --repo owner/name --force

Default limit: 200 merged PRs.--limitis capped at 1000 merged PRs for normal runs. Useanchor index --alloranchor index-allwhen you intentionally want to fetch every merged PR in the repository. Existing indexing commands use GitHub GraphQL first for PR metadata, comments, reviews, commits, labels, and changed files, then use REST only to enrich PR file patches for diff-context extraction. Anchor adapts GraphQL page size from realrateLimit.costandremainingvalues, keeps a safety reserve before GitHub's hourly budget is exhausted, and saves a local resume checkpoint when a full-history run should continue after reset. Full-history indexing is still subject to GitHub rate limits, but GraphQL batching greatly reduces the number of round trips compared with fetching every PR detail endpoint through REST. Patch enrichment uses bounded parallelism. The default concurrency is 5, and--concurrencyis capped at 10 to reduce the chance of GitHub secondary rate limits.

Anchor also indexes the local codebase by default after PR indexing. Code discovery usesgit ls-files --cached --others --exclude-standard, so it includes tracked files plus untracked files that are not ignored by git. Generated/private paths such as.anchor/,.cursor/,.codex/,.aws/,.ssh/,node_modules/,.nuxt/,.next/,dist/,build/,coverage/, and secret-like files such as.env,.npmrc,.netrc,.pem,*.key, andid_rsaare always skipped.

Code indexing also refreshes Architecture Memory: deterministic file areas, import edges, exported symbols, repeated folder patterns, and nearby test conventions. This gives agents current-code guidance before adding APIs, services, components, hooks, tests, or refactors.

Useanchor index-codeto refresh only the local codebase index without GitHub authentication. Use--no-codeon PR indexing commands when you only want PR history.

After indexing, Anchor prints outcome counts for architecture decisions, constraints, API contracts, security notes, regressions, test links, team rules, and a local coverage score. It also suggests a next agent prompt.

anchor index: Use this as the normal first command. Add--repo owner/namewhen git remote detection is unavailable,--limit 50for a fast first pass,--since YYYY-MM-DDfor a targeted backfill,--no-codeto skip code indexing,--forceto rebuild local derived records, and--concurrency 1-10to tune supplemental patch enrichment. Use--allonly when you intentionally want all merged PRs through theindexcommand.

anchor index-all: Use this for complete merged PR history. Prefer--concurrency 1or--concurrency 2on large repositories. Use--no-codeif the code index is already fresh, and rerun the same command after a GitHub reset if Anchor saved a resume checkpoint.

anchor index-code: Use this when you do not have GitHub auth or only need current-code context. It refreshes code chunks, test links, test commands, and Architecture Memory. Use--forcewhenanchor healthreports stale or inconsistent code records.

anchor sync: Use this after the first index. It is incremental and safe to run repeatedly. Add--allto catch up from an old cursor,--since YYYY-MM-DDto override the cursor,--no-codefor PR-only sync, and--concurrency 1-10to tune patch enrichment pressure.

Anchor automatically chooses progress output: modern live progress in interactive terminals, plain line logs in CI or non-TTY shells, and no progress for JSON output. Long org commands show the active repo, phase, counts, elapsed time, and last update age across GitHub fetches, SQLite PR indexing, code indexing, architecture indexing, and graph creation.

Incrementally fetch PRs updated since the last sync:

anchor sync anchor sync --repo owner/name anchor sync --all --concurrency 6 anchor sync --no-code

anchor syncis safe to run repeatedly. Use--allto fetch every merged PR updated since the sync cursor. Use--forceto rebuild the local database. Codebase indexing is refreshed by default unless--no-codeis passed. Scheduled repo autosync runs the same incremental path with--all --concurrency 2and falls back to code-only refresh if GitHub auth is unavailable.

Anchor can also build a local, allowlisted organization memory across multiple repos. This is opt-in and local-only: Anchor never scans every org repo automatically.

anchor org init --org my-org anchor org add-repo --org my-org anchor org add-repo --org my-org --search api anchor org add-repo my-org/backend-api --org my-org --group backend anchor org sync --org my-org anchor org status --org my-org
~/.anchor/orgs/<org>/ org.json org.sqlite repos/

org.jsonis the explicit allowlist.anchor org cloneshallow-clones missing repos and pulls existing managed clones. It does not run install, build, tests, branch creation, commits, pushes, or GitHub write APIs.

anchor org list --org my-org anchor org clone --org my-org --concurrency 3 anchor org index --org my-org --code-only anchor org sync --org my-org --since 2026-01-01 anchor org sync --org my-org --no-graph --concurrency 2 anchor org graph --org my-org anchor org graph --org my-org --open anchor org map --org my-org --open anchor org impact --org my-org --repo my-org/backend-api --strict --open anchor org ci --org my-org --strict --min-coverage 70 --html

Use--org my-orgon every org command to select the local namespace under~/.anchor/orgs/<org>.

anchor org add-repo: Run without<owner/name>to fetch readable GitHub repos for--organd open a searchable multi-select picker. Type to filter, use arrows to move, space to select, and enter to confirm. Use--search textto prefill the picker,--include-archivedwhen you intentionally want archived repos, and--group backend|frontend|shared|infra|docs|unknownto apply one group to every selected repo. In scripts, CI, or non-TTY shells, passowner/nameexplicitly. Use--alias nameonly with one explicit repo.

anchor org clone: Use--repo owner/nameto retry one allowlisted repo. Use--concurrency 1-3to control local/network pressure while cloning or pulling multiple repos. Anchor automatically shows live progress in interactive terminals and plain logs in CI.

anchor org index: Use--repo owner/nameto refresh one repo,--code-onlywhen GitHub auth is unavailable or PR history is already fresh,--prs-onlywhen clones are already fresh,--no-graphwhen you want to skip the final cross-repo graph rebuild, and--forceafter stale index warnings.

anchor org sync: Use this as the manual org refresh command. Autosync runs it daily with--no-graph --concurrency 1for every configured org, then runsanchor org graphweekly. Add--repo owner/namefor a focused retry,--since YYYY-MM-DDfor targeted PR catch-up,--concurrency 1-3for large allowlists,--no-graphwhen you want clone/index work to finish first, and--forcewhen status reports stale org data. If a recent previous sync already finished PR/code indexing but was interrupted before graph completion, rerunninganchor org syncresumes from the graph phase and skips redundant PR fetches for completed repos.

While sync/index/graph runs, Anchor writes a small local heartbeat file at~/.anchor/orgs/<org>/sync-heartbeat.json.anchor org status --org my-orgreads that first, so it can still show the active command, pid, repo, phase, elapsed time, and last update age even if SQLite is temporarily locked by a writer.

anchor org graph: Rebuilds cross-repo edges, API contracts, and API consumers from the already-indexed org database without cloning repos, fetching GitHub, or re-indexing code. Use it afteranchor org sync --no-graph, or whenanchor org statusshows zero cross-repo edges/API consumers after indexing finishes. Add--htmlto generate a standalone local graph page,--opento open it in your browser, and--output path/to/graph.htmlto choose the file path.

For large organizations, split the expensive phases:

anchor org sync --org my-org --no-graph --concurrency 2 anchor org graph --org my-org --open anchor org status --org my-org

anchor org impact: Use--repo owner/nameto identify the repo being checked,--diff-file change.diffin CI or saved-diff review,--strictfor API/auth/access/shared-package changes, and--jsonfor automation. Add--htmlto write a standalone local impact report,--opento open it in your browser, and--output path/to/impact.htmlto choose the file path.

anchor org ci: Use--strictto fail on blocker/high anomalies and--min-coverage 70to enforce an org coverage threshold. Add--htmlto write a standalone local CI report,--opento open it in your browser, and--output path/to/ci.htmlto choose the file path.

anchor org map: Use--format mermaid|jsonto choose CLI output. Add--htmlto write a standalone local map report,--opento open it in your browser, and--output path/to/map.htmlto choose the file path.

Org Memory indexes current code and, when GitHub auth is available, PR history for each allowlisted repo into one local SQLite database. Re-runs are idempotent: unchanged code indexes are skipped, changed repos replace their current-code records, PRs are upserted by repo and number, recently completed PR syncs are reused when resuming unfinished graph work, and successful repos stay intact when another repo fails.

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.