ContextPull

io.github.mi2arun由 GitHub 帳號 mi2arun 發布v0.2.1更新於 Nov 3, 2026

Exact document sections on demand for LLM agents: index in context, search, read, grep, neighbours.

已驗證STDIO僅桌面檔案與儲存知識與記憶

概覽

AI 產生的概覽

把文件資料夾轉成本地 SQLite 索引,並提供五個工具,讓助理按需拉取精確章節,而不是被動接收推送的上下文。

可以做什麼
  • 顯示語料庫的權杖預算目錄,語料過大時自動分層
  • 搜尋章節,只回傳編號與片段,不回傳正文
  • 依穩定編號(例如 path.md#3)逐字讀取某個章節
  • 精確 grep 比對,並保持識別字完整
  • 取得相鄰章節,例如表頭列或下一條款
  • 把 Markdown、文字、docx、xlsx、pptx 及選用 PDF 切成依標題劃分的章節
適用情境
適合讓助理根據本地文件資料夾回答問題,且只讀取它主動要求的章節並附上引用,而不是載入整個檔案。適用於離線單機環境以及唯讀的共享部署。
執行需求
以本地 stdio 程序執行,可從 PyPI 用 uvx 或 pip 安裝,TypeScript 讀取器可從 npm 用 npx 執行。需先將文件匯入為 SQLite 儲存檔。選用項目:PDF 附加元件、用於混合檢索的嵌入模型、用於索引單行摘要的摘要模型。未宣告任何身分驗證。
安裝前請注意
伺服器會在匯入的資料夾內寫入儲存檔。選用的摘要與嵌入功能會把文件內容傳送給外部模型供應商。拉取式檢索每次查詢可能耗費數萬個權杖,README 也指出無推理能力的小模型效果較弱。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 ContextPull,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

ContextPull

Website: https://mi2arun.github.io/contextpull/ · demo · docs · MCP Registry io.github.mi2arun/contextpull

Pull, don't push. ContextPull turns a folder of documents into something an LLM agent can pull from the way Claude Code pulls from a codebase: a small index that is always in context, and five tools that return exact sections on demand. The model never receives content it did not ask for.

Zero runtime dependencies. One SQLite file. Works offline.

ContextPull ships with a companion, ragbisect (formerly stagewise): a neutral benchmark harness that builds an eval set from your corpus and scores ContextPull next to bm25, dense and hybrid pipelines. Two names, one project, kept apart so the measurement stays independent of the thing it measures.

Status

M1 to M3 are built: store, ingest, the five operations, CLI, conformance suite, MCP server, Claude Code integration, LLM summaries, protocol client examples, ragbisect adapters, and a TypeScript reader and server. See the roadmap.

Measured

uv documentation, 603 sections, 221 self-generated questions, recall@5, from docs/testing.md:

configrecall@5ms/qmodel tokens/q
hybrid push (dense + bm25)0.964690
bm25 push0.92350
pull, Claude Code (10-question sample)1.00026,56586,656
pull, gpt-5.4-mini with reasoning off0.61516,02310,891

A strong agent reads the right section every time; a small no-reasoning model reads the right section when it reads (NDCG 0.96 given a hit) but misses the gold section on 38% of questions. Push retrieval is nearly free per query; pull costs tens of thousands of tokens. Both facts are in the table on purpose. The model's own searches surfaced the gold section on 88% of a sample, so most of the gap is snippets being answered from rather than read; a stricter prompt did not change that. An earlier version of this table showed 0.045 for the small model; that number came from a threading bug in the benchmark adapter and is retracted in docs/testing.md.

Try it

Fastest: ./scripts/demo.sh ingests the bundled fixture corpus and walks through index, search, read and grep, then prints the exact claude mcp add line. ./scripts/demo.sh ./your-docs does the same on your own folder.

sh
uv tool install contextpull            # or: pip install contextpull   (PyPI: contextpull 0.2.0)contextpull ingest ./docs              # writes .contextpull/store.sqlitecontextpull index                      # the always-in-context table of contentscontextpull search "refund window" --in policy-2025.mdcontextpull read policy-2025.md#3 --context 1contextpull grep TX-4419contextpull neighbours specs.md#1contextpull export-chunks > chunks.jsonl   # ragbisect-compatible sections

In Claude Code

sh
claude mcp add contextpull -- uvx --from "contextpull[mcp]" contextpull serve ./docs

The server ingests ./docs into ./docs/.contextpull/store.sqlite, puts the index into its instructions so it is always in context, and exposes the five tools. Ask a question; the trace shows search, then read, then an answer with [path.md#3] citations. contextpull claude-md prints a CLAUDE.md snippet if you want to tell the model about it explicitly. Add --summarizer openai:gpt-5.4-mini for model-written one-line summaries in the index (cached by document hash).

Any other MCP host works the same way; see examples/clients/ for TypeScript, Go and Java protocol clients and examples/direct_api_loop.py for using the tools straight from a model API with no server.

More

sh
uv sync --extra pdf                                             # PDFs: headings inferred from font sizeuv run contextpull ingest ./docs --embed-model openai:text-embedding-3-small   # enables: search --mode hybriduv run contextpull serve ./docs --transport http --port 8765    # streamable HTTP at /mcp for a shared read-only server

As a library

Embedding it in your own product, with access control and air-gap notes: docs/embedding.md and examples/embed_with_acl.py.

python
from contextpull import Store, Ops
with Store.open(".contextpull/store.sqlite") as store:    ops = Ops(store)    print(ops.index())    hits = ops.search("refund window", in_=["policy-2024.md", "policy-2025.md"]).hits    for h in hits:        print(h.id, h.heading_path, h.snippet)    section = ops.read(hits[0].id).section

Tool definitions for any model API are in contextpull.tools.TOOLS (Anthropic shape) and openai_tools(); tools.json at the repo root is the same thing for other languages.

How it works

  1. Ingest parses Markdown, text, docx, xlsx, pptx and (with the pdf extra) PDF into headings, paragraphs, tables and code, and cuts heading-aware sections with stable ids like policy-2025.md#3. Tables and code are never split mid-block; long tables are split by rows and every part carries the header. Unchanged files are skipped on re-ingest.
  2. Store is one SQLite file with an FTS5 index whose tokenizer keeps identifiers whole (--no-cache, UV_CACHE_DIR, TX-4419, 3.12).
  3. Index is a token-budgeted table of contents, one line per document, delivered into the model's context. It goes hierarchical when a corpus is too large for the budget.
  4. Tools: index, search (ids and snippets, never bodies), read (verbatim), grep (exact matches), neighbours (the header row, the next clause).

Node

sdk/typescript/ is a store-native reader and MCP server in TypeScript over better-sqlite3: open the same store file, no Python at query time. Published to npm as contextpull.

sh
npx contextpull serve /path/store.sqlite                   # npm: contextpull 0.1.0claude mcp add contextpull -- npx -y contextpull serve /path/store.sqlite

It passes the same conformance suite as the Python reference and returns identical results over MCP. Ingest stays in Python (npx contextpull ingest delegates to uvx contextpull ingest).

Go

sdk/go/ is a store-native reader and a single static binary server, pure Go, no cgo: the shape for a shared read-only deployment.

sh
cd sdk/go && go build -o contextpull-server ./cmd/contextpull-server./contextpull-server serve /data/store.sqlite --http 0.0.0.0:8765    # or without --http for stdio

Same conformance suite, identical results to Python over MCP.

Other languages

The store file is the contract. docs/store-format.md says what a reader must do; conformance/ holds a fixture corpus, its store and expected results. An SDK in any language is done when check passes. See the SDK plan.

Docs

Start at docs/README.md: architecture, design, system design, tool reference, evaluation, roadmap, decision records.

Measured with ragbisect, which lives next door.

來源:README.md,提交 d544b83

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.2.1最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分