
mcp-vl-msa-rs
io.github.DioNanos由 GitHub 帳號 DioNanos 發布v0.4.1更新於 Oct 24, 2026
Searchable agent memory: BM25 corpus recall, original-text injection, remember/forget capsules.
概覽
本機 stdio MCP 伺服器,為 AI 助理提供可檢索的長期記憶:對已索引文件做 BM25 語料召回、回傳原文,並支援記憶的寫入與遺忘。
- 可以做什麼
- 在具名集合中索引、取代與刪除文件,並把目錄鏡像同步進集合
- 檢索集合中得分最高的文字區塊,支援中繼資料篩選與多輪反覆檢索
- 取得文件完整原文,查看各集合統計資訊與已開啟的集合清單
- 寫入與刪除代理記憶,具備內容強化、低訊號過濾與內容雜湊去重
- 可在單次檢索中把 BM25 與行程內稠密餘弦重排混合計分
- 適用情境
- 適合需要跨工作階段、跨模型維持長期記憶的助理,用於知識庫、文件目錄或自身對話紀錄的檢索,且不想依賴雲端帳號或嵌入服務。也適合重視回傳原文而非嵌入向量的本機離線情境。
- 執行需求
- 以本機 stdio 行程執行,僅限桌面環境。可安裝 Linux/Android 預先編譯的執行檔,或以 Rust 工具鏈從原始碼建置(macOS 無預先編譯版本)。儲存預設在本機狀態目錄,可選用 MCP_VL_MSA_CONFIG 與 MCP_DEVICE 設定。稠密重排需建置特性並事先準備本機模型包。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 mcp-vl-msa-rs,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
mcp-vl-msa-rs
[CI] [Tests] [Benchmarks] [License: Apache-2.0] [Rust]
A searchable long-term memory for AI agents, exposed as an MCP stdio server.
Index documents, notes and past conversations into collections; retrieve the
top-k relevant chunks for a query and inject the original text back to the
model; add or drop agent memories with msa_remember / msa_forget. Pure
Rust, BM25 over tantivy, zero ML
deps in the default build; optional in-process dense rerank.
Any MCP client (Claude Code, Codex, or anything speaking MCP stdio) gets the same memory: a queryable corpus that survives across sessions and model swaps, with no cloud account and no embedding service required. Use it to give an agent durable recall over a knowledge base, a docs tree, or its own chat history — retrieval that returns the original text, not just embeddings.
It is one half of a two-part memory: this server is the library (corpus recall), its companion mcp-memory-rs is the notebook (curated state). An agent that swaps models loses neither.
The name: msa is the retrieval pattern it borrows from the Memory Sparse
Attention paper (arXiv:2603.23516) — an extrinsic approximation, not the
neural model; distinct from MiniMax's MSA-architecture LLMs, which are
intrinsic (in-model) generators. vl is for Vivling (codex-vl), its first
adopter — but the server is fully AI-agnostic and depends on nothing from it.
Status: v0.4 — hybrid sparse+dense optional.
Why
The original Memory Sparse Attention paper (EverMind-AI) describes an end-to-end trainable sparse attention layer over chunk-pooled KV caches. That is a neural artifact and is not portable to a pure-Rust MCP server. What is portable, and what this repo aims to deliver, is the MSA macro pattern:
- Chunked storage of long-form text with a small fixed pool size (
P=64words by default, mirroring the paper). - Top-k sparse routing over chunks (BM25 surrogate; learned routing is out of scope).
- Original text injection (paper §4.3, ablation -37.1% without):
msa_searchreturns chunks,msa_fetch_docreturns the full document. - Memory Interleave as a protocol (planned v0.4): the AI client orchestrates multi-hop retrieval through repeated tool calls with a server-side cursor.
Design and rationale are documented in the project notes (negative results, gate methodology); see docs/NEGATIVE_RESULTS.md.
Benchmarks
Retrieval changes are decided on pre-registered, paired deltas with
bootstrap confidence intervals — not on absolute scores. Workloads: HotpotQA
(extractive QA), MLDR-it (long-doc retrieval, Italian), LongMemEval-S (500
conversational-memory questions). Full methodology, acceptance gates and
refuted hypotheses live in docs/NEGATIVE_RESULTS.md.
Headline measurements:
- BM25 is the engine, not a placeholder. Three pre-registered attempts; no
hybrid (BM25 + dense rerank) configuration beat the gate on these workloads.
Dense rerank stays available (
dense_alpha, off by default) for re-testing as encoders improve. - Rich capsules at ingestion (deterministic enrich, no LLM): +7 to +20 recall@5 across every category.
- Original-text injection (
msa_fetch_docaftermsa_search): +14.6 F1 exactly on the stratum where snippets miss the content. - Recency priors lose — handle time at serving, not in the retrieval score.
Reproduce:
Tool surface
Install
Prebuilt binary (recommended) — download the archive for your platform from the latest release, extract, and point your MCP client at the binary:
Prebuilt targets (Linux + Android): x86_64-unknown-linux-gnu,
x86_64-unknown-linux-musl, aarch64-unknown-linux-gnu,
aarch64-unknown-linux-musl (edge / ARM / Termux), aarch64-linux-android.
macOS: no prebuilt binary is shipped (it would need Apple code-signing).
Install from source instead — cargo install below compiles it on your Mac in
one command, no signing needed.
From source (Rust toolchain) — --locked is required (the workspace
Cargo.lock pins a working time / tantivy-common resolution; a fresh
resolve breaks the build), and mcp-msa-server is the package name (the
binary it installs is mcp-vl-msa-rs):
Build & test
Hybrid mode config
Add [embeddings] to MCP_MSA_CONFIG to activate dense rerank. Without
this section the server stays in BM25-only mode even when the binary was
built with --features embeddings.
The production backend is candle-modernbert: the encoder runs in-process
(Candle), offline-deterministic, from a local model bundle — no daemon, no
network at runtime, no automatic downloads. Prepare the bundle once with
scripts/prepare-granite-r2-97m.sh.
A transitional backend = "ollama" (HTTP to an Ollama-compatible service)
still exists but is deprecated and scheduled for removal in v0.6 — do not
build new setups on it.
The AI client opts into hybrid scoring per-call by passing dense_alpha
to msa_search (or any future tool that supports it). dense_alpha = 1.0
(default) is BM25-only; 0.0 is dense-only; intermediate values are a
linear blend α·bm25 + (1-α)·((cos+1)/2). Cosine is shifted to [0,1]
so it composes linearly with the already max-normalized BM25 score.
Run as MCP stdio
Example ~/.codex/config.toml entry:
Equivalent ~/.claude.json entry for Claude Code:
AI client compatibility
- Clients with partial MCP support may not surface the server's
instructionstext. The tool descriptions and request-field descriptions are self-contained, so a model can work from those alone. - Read-only tools (
msa_search,msa_fetch_doc,msa_stats,msa_list_collections,msa_manifest,msa_search_iterative,msa_interleave_round) carry thereadOnlyHintannotation, which lets a gating client auto-approve them. - If a model reports an "unsupported call" or "user cancelled" on codex, that is
the approval gate, not a server fault — set
default_tools_approval_mode(above) so tool calls are not blocked on a prompt.
Storage layout
Each collection is an independent tantivy index. Collection names are validated
(rejected if they contain path separators, .., etc.) so a collection cannot
escape the root.
Roadmap
Shipped:
- v0.2 —
SearchFilter(where_eq / where_in / created range), post-retrieval. - v0.3 —
msa_search_iterativeMemory Interleave with server-side cursor + TTL'dMsaSessionregistry. - v0.4 — hybrid BM25 + dense rerank behind feature flag
embeddings, Ollama backend, per-calldense_alpha; agent-memory surface (msa_remember/msa_forget); filesystem source metadata (created_at/source/ext/dir) at index time; exactnum_documents/total_tokensinmsa_stats;msa-benchreproducible benchmark crate; prebuilt-binary packaging.
Next (not yet built):
- Query-time tantivy filter (today
SearchFilterruns post-retrieval; fine for normal corpora, but a pre-filter would help when selectivity is high on a very large index). - ACL for multi-tenant collections.
- Tool-description tuning.
Related work
- MSA paper (arXiv:2603.23516) — the architectural inspiration (neural, intrinsic); this repo is an extrinsic, pure-Rust approximation of the macro pattern.
- Vivling (in
codex-vl) — the first downstream consumer: this server is its long-term memory. - mcp-memory-rs — the companion server for curated agent state (named JSON categories, per-device ACL, fleet sync). This server does corpus recall; together they cover both halves of agent memory: the curated notebook and the queryable library.
License
Apache-2.0. See LICENSE.
來源:README.md,提交 13bb3eb
工具
0版本歷史
1- v0.4.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分