officegrep

io.github.Asgoresmilelong由 GitHub 帳號 Asgoresmilelong 發布v0.1.3更新於 Oct 26, 2026

Full-text search inside Word, PPT, Excel and PDF files, with precise locators.

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

概覽

AI 產生的概覽

本機 MCP 伺服器,將 Word、PowerPoint、Excel、PDF 與文字檔索引到 SQLite,讓助理進行全文檢索並提供精確定位。

可以做什麼
  • 以字面全文檢索已索引文件,回傳檔案路徑、頁碼/投影片/工作表儲存格等定位資訊與醒目片段
  • 列出已索引檔案及其文字區塊數量
  • 為指定資料夾建立或增量更新索引
  • 透過命令列或伺服器背景監看資料夾變動,讓索引保持同步
適用情境
當助理需要在本機 Office 文件與 PDF 中找出特定段落,而一般 grep 讀不到這些內容時適用;適合想要離線、增量檢索、不依賴嵌入服務或向量資料庫的情境。
執行需求
以本機程序在桌面環境執行,可透過 pip 或 .mcpb 安裝包安裝(安裝包需要 uv)。執行時相依 lxml 與 openpyxl,PDF 支援需選用 pypdf。不需帳號或 API 金鑰。選用環境變數 OFFICEGREP_DB、OFFICEGREP_AUTOINDEX、OFFICEGREP_ROOTS、OFFICEGREP_WATCH 分別控制索引路徑、首次自動掃描、掃描資料夾與背景監看。
安裝前請注意
索引為空時首次啟動會在背景掃描「文件」「下載」「桌面」資料夾,除非將 OFFICEGREP_AUTOINDEX 設為 0,因此本機檔案內容會被讀取並寫入 SQLite 索引。檢索為字面比對而非語意搜尋;掃描版 PDF 不會有結果(不支援 OCR);僅索引正文,不含註解、追蹤修訂、頁首頁尾。

安裝

在 SourceWeft 中

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

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

其他 MCP 客戶端

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

README

officegrep

[ci] [license: MIT] [python] [MCP]

Full-text search inside Word, PowerPoint, Excel and PDF — for agents.

grep cannot see a single character inside a .docx. officegrep extracts the text, indexes it into one SQLite file, and hands it to any agent over MCP.

$ officegrep search "bending moment"
Found 3 hits:
F:\reports\pole-design.docx  [table p 89]  design bending moment (load point 0.25 m from tip); deflection limit; test moment = 2× …
F:\notes\composites.md  [line 32]  … utilization 81%. **test bending moment = 2× the standard test moment** …

中文说明:README.zh-CN.md

Why

  • grep / ripgrep only read plain text. .docx is a zip of XML, .xlsx keeps strings in a shared table, .pdf is a compressed stream.
  • Generic RAG needs an embedding service, a vector store, and a network round-trip.
  • This needs one SQLite file: offline, incremental, milliseconds.

Install

bash
# one command, no clone, no uvpip install https://github.com/Asgoresmilelong/officegrep/releases/download/v0.1.1/officegrep-0.1.1-py3-none-any.whl
# or from sourcepip install git+https://github.com/Asgoresmilelong/officegrep

Runtime deps: lxml, openpyxl; PDF support adds optional pypdf.

Listed in the official MCP Registry as io.github.Asgoresmilelong/officegrep; there is also an .mcpb bundle on the releases page for MCP hosts that install bundles (needs uv).

CLI

bash
officegrep index ~/Documents ~/Downloads     # build / update (incremental)officegrep search "island reef" --limit 5officegrep search "wind load" --under ~/Documentsofficegrep stats

The index lives in ~/.officegrep/index.db; override with --db or OFFICEGREP_DB.

First run

Nothing to do. If the index is empty when officegrep mcp starts, it scans ~/Documents, ~/Downloads and ~/Desktop in the background (25 MB per-file cap) while the agent keeps talking; a search_docs call made in the meantime answers with a "still building" note instead of a misleading "no results".

  • opt out: OFFICEGREP_AUTOINDEX=0
  • scan other folders: OFFICEGREP_ROOTS="~/work;~/papers"

Stay in sync

bash
officegrep watch ~/Documents           # re-index on change: 2s poll, no extra dependencyofficegrep watch ~/Documents --once    # single sync pass (cron / CI friendly)

Or let the MCP server watch in the background:

bash
OFFICEGREP_WATCH="~/Documents;~/Downloads" officegrep mcp

The index runs in WAL mode, so a watch process and an MCP server can share one database file concurrently — something that fails with database is locked on a default rollback journal.

MCP server

bash
officegrep mcp

Client config (Claude Desktop / Cursor / Codex / any MCP host):

json
{  "mcpServers": {    "officegrep": {      "command": "officegrep",      "args": ["mcp", "--db", "/Users/me/.officegrep/index.db"]    }  }}
ToolWhat it does
search_docsFull-text search → file path, locator (p 42, slide 3, Sheet1!12, page 7), highlighted snippet
list_docsIndexed files with block counts
index_folderBuild / refresh the index (incremental)

The protocol is a hand-written JSON-RPC over stdio — no MCP SDK dependency.

How it works

docx / pptx  →  zipfile + lxml, read the XML directlyxlsx         →  openpyxl (read_only)pdf          →  pypdf (optional)txt / md     →  line chunks, line numbers kept
  • Every block carries a human-readable locator, because the first question an agent asks is "where?".
  • The index uses SQLite FTS5 with the trigram tokenizer: substring matching for both CJK and Latin text, no word segmenter required, ranked by bm25().
  • Queries of 1–2 characters cannot match trigrams, so they fall back to a scan ranked by hit count (CJK queries are frequently two characters).
  • Incremental: compare (size, mtime) first, hash with SHA-1 only when they differ.

Benchmark on a real engineering corpus:

MetricValue
Files43 (docx / pptx / xlsx / md, incl. an 8.6 MB deck)
Text blocks2,260
First index2.16 s
Database1.9 MiB

Limits

  • No OCR: scanned PDFs yield nothing.
  • Literal search, not semantic — "tower" will not find "pole" unless both appear.
  • 1–2 character queries scan the table; slow past a few hundred thousand blocks.
  • Indexes body text only: no comments, tracked changes, headers or footers.

License

MIT

來源:README.md,提交 7c1314a

工具

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

版本歷史

2
  1. v0.1.3最新Oct 18, 2026
  2. v0.1.1Oct 18, 2026

評分

已滿足適用檢查項的 50%

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

  • 近 30 天內可連通25 分

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

  • 已宣告認證方式10 分

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

  • 已列出工具15 分

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

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