
Vectr
io.github.swapnanil由 GitHub 账号 swapnanil 发布v1.12.0更新于 Oct 25, 2026
Semantic codebase search + persistent working memory for AI code editors. Local, no API key.
概览
Vectr 是一个本地守护进程,为 AI 代码编辑器提供语义化代码库搜索和持久工作记忆,无需 API 密钥。
- 可以做什么
- 对代码库进行语义搜索、按名称定位符号、追踪调用方与被调用方,并获取架构概览或索引状态。保存、召回、置顶、锚定、提升和删除结构化笔记,笔记可跨会话和上下文压缩保留。恢复上次会话、创建和列出快照,并在上下文将满时按 id 重新取回早前片段。查看自动捕获的失败转成功经验,并把运行时调用数据注入索引。
- 适用场景
- 适合大型或不熟悉的代码库、需要跨会话继续的工作,以及反复读取文件和搜索符号会浪费 token 的长对话。若只是在小而熟悉的仓库里做一次精确查找,直接用 grep 更便宜也更快。
- 运行要求
- 以 Python 包形式在本地运行(需 Python 3.14 及以上),用 vectr start 启动,或作为 stdio 子进程运行;清单中提供 VECTR_PORT 用于本地守护进程端口。首次运行会下载约 290 MB 的嵌入模型。默认不需要 API 密钥或账号;写入 MCP 配置后需重启编辑器一次。
安装
在 SourceWeft 中
- 打开 控制台中的 Vectr,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
[vectr: semantic codebase search and persistent working memory for AI code editors]
Vectr
Delivery, not storage. A local daemon that gives an AI code editor semantic search over your codebase, plus working memory that shows up on its own when it is relevant.
[CI] [License: MIT] [Python 3.14+] [Version 1.12.0] [MCP: 23 tools]
Version 1.12.0 · Last updated 2026-09-03 · CHANGELOG
In 30 seconds
Your AI code editor pays for the same knowledge twice. It re-reads files it read yesterday, re-greps symbols it already found, and loses the exact signature it discovered at turn 5 the moment the conversation is compacted. Vectr is one local process that removes both halves of that bill:
- Retrieval that understands code. AST-aware chunks, a symbol and call graph, and hybrid semantic plus BM25 ranking. Describe a behaviour and get the whole function back, in one call instead of a grep loop and three blind file reads.
- Working memory that gets delivered. Save a finding once. It comes back verbatim in under 50ms, and on editors that expose session hooks it arrives automatically at the moment it applies, without the agent choosing to ask for it.
- Local, keyless, zero config. One
pip install, onevectr start. The embedding model runs on your machine. Nothing is transmitted anywhere, and there is no API key.
That is the whole setup. Vectr writes the MCP config for your editor, then indexes in the background.
How vectr differs from other AI agent memory tools
There is a healthy category of general-purpose memory layers for AI agents, and the good ones solve a real problem well. Vectr is most often compared to them, so here is the difference stated plainly. The left column describes the design these tools tend to share, not any one product; individual tools vary, so check the one you are considering.
Why the first row is the one that matters. Storage is not the bottleneck. Retrieval that an agent must volunteer to call is, because it largely does not call it. In our controlled evaluation the agent performed 0 memory operations across 114 turns even when the store was pre-seeded with knowledge directly relevant to its task. Deterministic injection delivered in every injection-equipped run, with zero false-alarm fires across the audit-logged trigger evaluations. Under repeated compaction, ten facts held only in the conversation were absent from 106 of 108 forced compactions, while the same ten facts injected from a harness-owned store arrived intact across 138 of 138 compact-resumes.
Full method and results: Delivery, Not Storage: Cue-Anchored Working Memory as a Harness Property for Coding Agents (arXiv:2607.20972).
What it costs and what it saves
Measured, not hypothetical. Recalling 3 stored notes with vectr_recall costs 360 tokens in one tool call. Re-deriving the same three facts with grep plus Read costs about 2,060 tokens across six tool calls on the same 182-file Python repo. That is roughly 5.7x fewer tokens and 6x fewer tool calls, in under 50ms (chars/4 tokenization, full breakdown in Measured costs, honestly).
Notes are persisted to disk, not held in the conversation, so they survive /compact and a fresh session equally. The session boundary does not matter: saving at turn 5 and recalling at turn 15 is the same mechanism as recalling three days later.
Where it pays off: unfamiliar or large codebases, work you resume, and long sessions with many turns. Where it does not: a one-off grep on code you already know cold. Reach for grep instead, and see When vectr can hurt.
Benchmarks
Public results live in benchmarks/. The corpora below are witnesses chosen because they are large and unfamiliar to the model, nothing more.
A six-task sprint on a large unfamiliar C codebase simulates a week of feature work. One research session stores findings with vectr_remember. Six isolated implementation sessions each open cold and call vectr_recall.
Implementation sessions only, 6 tasks combined:
Per-task re-discovery (Read and Bash calls before the first write):
The 0% row is real and kept on purpose: that task was one the model could already navigate from training knowledge alone.
Research versus implementation, stated honestly. The research phase is paid once and costs more with vectr (+94%), because storing rich code stubs and signatures produces output tokens. The implementation phases repeat every task and cost less, because recall replaces re-discovery. The overhead breaks even after roughly 8 tasks of note reuse.
An earlier run on a 5,856-file Java corpus measured -58% implementation cost, -72% implementation tool calls, and -39% wall time.
Measured costs, honestly
Per-call token cost (median, 182-file Python repo, chars/4 tokenization):
The trade-off, stated plainly: for a single pointed lookup on a small, already-familiar repo, grep is cheaper. Vectr's median cost across 5 single-fact tasks was 60% more tokens, and it is slower too, since a vectr_search round trip takes 1.7 to 3.6 seconds against about 28ms for grep. Vectr does not win on per-call cost. It wins on tool-call count (one round trip instead of several), on answer completeness (a whole symbol back, not a partial file read), and on everything in working memory, where the 5.7x recall refund compounds with every task you resume.
Fine print: the automatic eviction and reminder banners riding along on tool responses cost tokens too. An always-on re-fetch footer runs about 27 tokens, a light nudge about 89 tokens, and the escalated action-required banner (which fires only after both the chunk and token thresholds are crossed without a save) scales from about 480 to 535 tokens before it plateaus.
Quick start
Local (recommended)
Requires Python 3.14+. To install:
- macOS:
brew install [email protected] - Ubuntu/Debian:
sudo add-apt-repository ppa:deadsnakes/ppa && sudo apt install python3.14 python3.14-venv - Windows: python.org/downloads
vectr start returns immediately. Indexing runs in the background, so run vectr status to check progress. On first run the embedding model downloads once (about 290 MB). Restart your AI code editor once to pick up the new MCP config.
Docker (CI and servers)
Exposes port 8765. Docker does not auto-write IDE config files, so use the local install for IDE integration.
Connect to your AI code editor
vectr start writes the MCP config for your editor automatically. Restart your editor once.
"Verified" means the full integration (config, guidance, and hooks) has been exercised end to end. "Experimental" means the MCP config is written and works, but the integration has not been run through the same verification pass.
Automatic delivery of memory depends on the host exposing session hooks. Where it does not, every tool below still works on demand over MCP.
Manual setup
Claude Code, .claude/settings.json:
Cursor, .cursor/mcp.json:
VS Code / GitHub Copilot (1.99+), .vscode/mcp.json:
Windsurf, ~/.codeium/windsurf/mcp_settings.json:
Continue.dev, .continue/config.json:
Codex CLI, project-scoped .codex/config.toml (written automatically by vectr start):
On its first run in the workspace, Codex shows a one-time interactive prompt to trust the project before it loads a project-scoped config. If you also ran vectr init --hooks, Codex shows a second one-time prompt to trust the hook commands. Both persist after you accept them once, and a config writer cannot clear them for you without weakening your security posture.
Stdio transport
The editors above connect over HTTP (vectr start plus POST /mcp). For MCP clients and hosting platforms that spawn the server as a subprocess and speak MCP over its stdin and stdout instead of opening an HTTP connection, run:
No port, no daemon: a single foreground process framed as newline-delimited JSON-RPC 2.0 (one JSON object per line on each of stdin and stdout, no Content-Length headers). initialize and tools/list answer immediately, while the embedding model load and initial indexing happen on a background thread. A tools/call made before that finishes gets a graceful "still starting up" response instead of hanging. Stdout carries protocol JSON only, and all logging goes to stderr. The process exits cleanly on stdin EOF. --memory-only and --search-only behave the same as on vectr start.
How it works
- AST-aware chunking. tree-sitter parses each file and splits at function, class, and method boundaries. No chunk breaks mid-logic.
- Code embeddings.
ibm-granite/granite-embedding-english-r2(local, CPU-fast, overridable) maps natural-language queries to code symbols, so "JWT validation" findsverify_jwt_token. BM25 handles exact symbol names. - Hybrid search. Vector similarity and BM25 combined, weighted by codebase characteristics. Large and unfamiliar leans semantic, small and well-documented leans BM25.
- Symbol graph. Call edges, import chains, and HTTP routes (Flask, FastAPI, Express, Spring) are extracted and stored.
vectr_locateresolves a name through a 6-strategy cascade: exact match, suffix, same-module, import-chain, substring, then fuzzy. A fuzzy answer is always rendered as explicitly inexact rather than presented as a confident match, because a confident wrong symbol is worse than a not-found. - Working memory.
vectr_rememberstores structured notes to SQLite and ChromaDB.vectr_recallruns semantic search over notes rather than a SQL LIKE, so multi-word queries still find the relevant context. - Trigger evaluation. Each note's conditions are checked deterministically by the daemon at lifecycle moments, with a per-session fire ledger and injection budgets, so a note resurfaces exactly when it applies and never twice in the same window.
- MCP protocol. 23 tools served over HTTP. Any MCP-compatible AI code editor connects without plugins.
23 MCP tools
vectr start writes a guidance file into your workspace with this table, so your AI code editor knows which tool to reach for without being prompted.
Search tools, which retrieve code from the index:
Memory tools, which store and recall across sessions:
Triggers: the delivery layer
Those kind values carry sensible defaults. A note can also declare explicit per-note triggers on vectr_remember:
Conditions AND within one entry and OR across entries. Every fire carries a one-line explanation of which trigger matched. Injection is budgeted (a hard per-turn cap spent jointly across surfaces), deduplicated by note id across every surface within a turn, and framed by provenance, so an unreviewed auto-captured note never renders with the authority of a standing rule from you. A note is never partially truncated: it arrives whole, as an index-tier line, or not at all.
Workspace-scoped notes double as a shared bus for multi-agent workflows. An orchestrator and its subagents all read and write the same note store, so a subagent can call vectr_remember(..., agent="coder-2") with its findings before finishing, and the orchestrator recalls them instead of re-reading the subagent's full transcript. The agent parameter is never inferred. It is explicit attribution, and it shows up as a tag in vectr_recall index output.
CLI reference
Importing existing memory
vectr memory export and vectr memory edit are the one-way-out and check-out/check-in paths. vectr memory import is the one-way-in: it brings existing on-disk memory into the working-memory store without re-entering it by hand. This is the on-ramp for a new user who already has memory written down.
Discovery. With no --path, the importer walks a closed list of default candidate files at the workspace root: MEMORY.md, CLAUDE.md, AGENTS.md, .cursorrules, and .github/copilot-instructions.md. Pass --path (repeatable) to point at any other file or directory; a directory is walked recursively for *.md and *.mdc files. Files that don't exist are reported but never raised on, since most workspaces will not have every default file.
Granularity. A source file is not one note and not one note per line. It is split at Markdown heading boundaries (^#{1,6}\s+), the same way a human skims a MEMORY.md. A heading-less file becomes one note. Headings inside fenced code blocks and HTML comment blocks are skipped, so a code example or the export-file header comment does not become a section boundary. A file previously exported by vectr memory export is detected by its <!-- Generated by ... --> header and parsed through the same block grammar vectr memory edit uses, recovering each original block as a note with its declared kind, priority, tags, and provenance carried forward.
Dry run. --dry-run prints exactly what would be created (kind, title, source file, source-line range, provenance) and changes nothing. Memory is the one resource the user cannot easily reconstruct, so dry run is the path of first resort:
Idempotency. Every imported note carries a src:, src-sha:, and src-lines: tag triple. A re-run of vectr memory import against an unchanged source file recognizes those tags and creates zero new notes. Editing a section of the source file produces a new body whose hash does not match the stored one, so it becomes a new note, and the old one is left untouched, since silently deleting a prior import behind the user's back is exactly the silent loss the design defends against on the export side.
Provenance. Imported notes carry a source-file tag (imported and src:FILENAME, where FILENAME is the basename of the source file), so a recall that lists a note carrying imported is telling the user "this came from a file, not from this session's observations." The note's provenance defaults to auto, the class machine-captured facts with no reviewing judgment already carry, since a hand-written MEMORY.md is structurally indistinguishable from a generator's output to a parser. The exception is narrow and structural, not semantic: a note whose body contains imperative-rule markers (the closed keyword set MUST, MUST NOT, NEVER, ALWAYS, DO NOT, DON'T, REQUIRED, FORBIDDEN) is classified as kind="directive" and upgraded to provenance="agent". The reason is the auto + directive write-time guard in remember(): an unreviewed standing rule is a contradiction in terms, and an imported rule is exactly that pair. Promoting to agent is the smallest possible deviation from auto, exactly enough to satisfy the guard, and the user promotes further with vectr_promote after review.
Excluding paths
Create .vectrignore in your project root (same syntax as .gitignore):
Or pass --exclude at init time:
Exclusions apply to both the initial index walk and the live file watcher, so adding a directory to .vectrignore stops a running instance from re-indexing it. The next index also prunes any chunks already stored for now-excluded or deleted files, so you do not have to rebuild from scratch. If you ever need a clean rebuild, for example after changing the embedding model, force one:
Supported languages
HTTP routes (Flask and FastAPI decorators, Express app.get(), Spring @GetMapping) are extracted as symbols and searchable via vectr_locate("GET /api/users").
Cost
Security
The default is unchanged and stays the headline: local, no API key, zero config, for a solo developer on a personal machine. Out of the box, the daemon binds to 127.0.0.1 only, CORS is restricted to localhost origins, each workspace gets its own isolated DB directory, port, and process (owner-only 0700 on POSIX), and the index and notes persist locally in ~/.cache/vectr/.
Everything below is opt in. Enabling nothing changes nothing.
Authentication. Set VECTR_API_KEY and every request to /v1/* and /mcp must carry it (X-Api-Key: <key> or Authorization: Bearer <key>, constant-time comparison, with /v1/health left open for liveness probes). Generate a key with vectr key. When the key is set at start time, the editor MCP configs vectr writes include the header automatically. Those files (.mcp.json, .cursor/mcp.json, .vscode/mcp.json) then hold the key in plaintext, so treat them as secrets and keep them out of shared or public version control.
Encryption at rest. Set VECTR_ENCRYPT_KEY, or store a passphrase in the OS keychain (service vectr, username encrypt-key, requires pip install vectr[encryption]), and note content, note titles, and snapshot payloads are encrypted with Fernet and a PBKDF2-derived key. Honest boundary: the code index is not encrypted, because the search engine needs readable chunk text and vectors. Protect it with OS full-disk encryption. Note tags and metadata stay plaintext, and note embedding vectors (a lossy projection of note text) are kept for semantic recall unless you set VECTR_ENCRYPT_DISABLE_NOTE_VECTORS=1.
Retention and audit. Notes are kept until you delete them. Set VECTR_NOTES_TTL_DAYS to auto-purge older notes at startup. vectr_forget(all=true) and vectr forget --all delete notes, snapshots, and note vectors, so everything means everything. Set VECTR_AUDIT_LOG=<path> for a rotating local log of index, search, remember, and recall events (off by default, and it records query text, which is its purpose, and is never transmitted). Full policy: docs/data-handling.md.
Team mode (shared instance). One central daemon can serve a team on one repo. Run VECTR_API_KEY=<key> vectr start --host 0.0.0.0 on the server (a non-loopback bind refuses to start without a key), then vectr connect --url http://<host>:<port> --api-key <key> --label <you> on each client to point the editor at it. Working memory is shared: a note one agent stores, every connected agent can recall, and --label attributes notes and audit lines. Note IDs are allocated by the central store in the order writes arrive, so with concurrent clients your notes are not a contiguous block. They interleave with other clients'. The Stored note #N line the write returns is the canonical reference to that specific note, so do not assume the next ID is also yours. Plain limits: one shared key means every holder is an equal, trusted peer (no roles, no per-user permissions), the server operator can read everything, search results reference the server's checkout, which may differ from your local tree, and vectr speaks plain HTTP, so put TLS at a reverse proxy or tunnel if the network is not trusted.
Proactive context (experimental, localhost only)
Pull-based recall means the agent has to ask. Proactive context extends deterministic delivery to hosts without session hooks, by sitting on the wire instead. It is experimental and localhost only. Since 1.6.0 proactive delivery is on by default on local instances (proactive.enabled; turn off with VECTR_PROACTIVE=0). The wire channel below is governed by launch consent instead of that switch: starting the proxy and pointing your agent at it is the opt-in, and stopping it or unsetting the base URL is the opt-out.
The vectr proxy command runs a small local proxy between your agent and the model API:
What it does and does not do, plainly:
- Transparent by default. It forwards every request to the real API, and streaming responses and tool calls pass through byte for byte. Your API key is forwarded untouched and never stored or logged.
- Deterministic injection. With the workspace daemon running, it appends matched working-memory notes to the request after the last prompt-cache breakpoint, so your prompt cache is never invalidated. Triggering is a similarity threshold plus exact structural matches, never keyword guessing, with a strict per-request budget so a hint only lands when it is worth the tokens.
- Fail open. If the intelligence layer is slow or errors, your request goes through unchanged. To bypass the proxy entirely, unset the base URL:
unset ANTHROPIC_BASE_URL. The proxy is on the request path, so if it is down, unset the variable to talk to the API directly. - Solo and localhost only. It reads your conversation to compute context, so it refuses any non-loopback bind and is mutually exclusive with team mode.
- Caveats on a non-first-party base URL, per the host's own documentation: MCP tool search is disabled unless
ENABLE_TOOL_SEARCH=trueand the proxy forwards tool-reference blocks, and Remote Control is disabled on a non-api.anthropic.combase URL.
Org-wide caching (team mode). With a central shared instance, vectr can cache its own expensive artifacts, namely semantic search and recall results, keyed by exact identity and the current index state, so a re-index or note change invalidates them automatically and every connected developer benefits. It is off by default (proactive.cache), and vectr status reports its hit rate and estimated tokens saved so the value is measured rather than asserted. Vectr does not cache LLM responses across similar requests, only byte-identical ones, locally, and opt in, because a wrong cache hit would silently corrupt a conversation.
When vectr can hurt
Stale notes after codebase churn. Notes store file paths at write time. After a large refactor, vectr_recall flags changed referenced files with [STALE]. Re-verify before acting, delete the stale note with vectr_forget(note_id=N), or clear everything with vectr_forget(all=true).
Over-retrieval on a well-known API. If the model already knows a framework deeply from training, vectr's research overhead may exceed the savings. The benchmark above shows exactly that on debug_descriptor_priority, a task where training knowledge alone was enough to navigate.
Stale architectural overview. A passport saved by vectr_map_save describes the architecture at index time. After renamed modules or restructured entry points it can be confidently wrong, so vectr_map surfaces a staleness warning and you should re-run vectr_map_save.
Broad recall costs tokens. vectr_recall() with no query returns everything. Pass a targeted query, and check vectr_status() first if you are unsure whether recall is warranted at all.
Built with
Python 3.14 · FastAPI · sentence-transformers · tree-sitter · ChromaDB · BM25 · Docker
Author
Swapnanil Saha · swapnanilsaha.com
来源:README.md,提交 726e798
工具
0版本历史
1- v1.12.0最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分