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 分