AI 开发者、研究人员和专业人士在使用大语言模型分析大型文档时,常常会撞上一堵令人沮丧的墙:上下文窗口那隐蔽且不断累积的成本。把一个 200 页的 PDF 粘贴进对话,并不是一次性收费。因为每一轮对话都会把历史记录重新发送给模型,所以那份庞大的文档会在每一次追问时被再次计费。
Marktechpost AI 团队刚刚发布了 Token Saver,这是一个面向 Claude Desktop 的开源 Model Context Protocol(MCP)扩展(MIT 许可,当前版本为 v1.0)。它由 Arnav Rai(罗切斯特理工学院计算机科学专业学生)在 Marktechpost 实习期间,在 Jean-marc Mommessin 和 Asif Razzaq 的指导下,于 Marktechpost AI Media Inc 开发。Token Saver 从根本上改变了 Claude 与本地文档交互的方式。通过在你的机器上直接实现 Local Hybrid RAG 系统,它让你可以针对庞大的 PDF 提问,而无需将实际文件上传到模型。
Token 消耗削减了 92% 到 99%,隐私得到保障,而且设置完全不需要任何 Python 环境或终端配置。
效果展示!

大型 PDF 隐藏的 Token 消耗
大多数用户以为,把 PDF 拖进 Claude 后,它只是简单地提取文本。实际上,Claude 的默认行为是把每一页转换成图像,以保留图表和版式,同时另行提取文本。在哪怕一个图像 token 被计入之前,仅文本部分每页就可能达到 1,500 到 3,000 个 token。
虽然 Prompt Caching 和 Claude Projects 有助于缓解这一冲击,但它们并未解决核心问题:整份文档仍然要跨越边界,传到提供商的服务器上。此外,如果你只需要一本 1,000 页教材中的两个相关段落,却强迫 LLM 自己去检索全部 1,000 页,既低效又容易产生模型幻觉。
本地混合 RAG 如何解决这一问题
Marktechpost 的 Token Saver 充当一个本地 MCP server:一个运行在你机器上的轻量级后台程序,Claude 可以将其作为工具调用。PDF 永远不会离开你的硬盘。
当你提问时,Token Saver 会利用 本地混合 RAG 来寻找答案。混合 RAG 是文档检索的黄金标准,因为它结合了两种强大的搜索方法:
- 关键词匹配(BM25):运行在 SQLite 内置的 FTS5 搜索之上(权重为 0.4),用于查找精确术语。
- 语义搜索(余弦相似度):使用本地的 all-MiniLM-L6-v2 嵌入向量模型(权重为 0.6)来理解你问题的含义,而不仅仅是匹配精确的词。
通过在本地融合这两种方法,服务器会搜索文件,只把高度相关的段落交给 Claude。随后 Claude 综合出答案,引用确切的页码,并提供你刚刚节省下来的 token 的实时统计。
8 阶段处理流水线
Token Saver 完全运行在一个单一的、长期驻留的本地进程中。在任何文本到达 Claude 之前,本地混合 RAG 流水线会执行八个快速步骤:
- 提取:使用 pypdfium2(以 pypdf 作为回退)来提取文本。
- 分块:将文本切分为 180 词的段落,重叠 40 词,这样上下文就不会被生硬地截断。
- 评分(混合 RAG):使用融合的 BM25 和本地嵌入向量模型对文本块进行评估。
- 门控:强制执行质量阈值。不共享任何精确关键词的段落必须通过 0.25 的语义相似度下限才能入选。
- 去重: 剔除几乎完全相同的段落。
- 裁剪: 将段落严格缩小到能够回答用户提示词的那些句子。
- 预算: 将发送给 Claude 的总载荷上限设为 8,000 个字符。
- 封装: 将检索到的文本包裹在一个 document-chunk 元素中,其中包含源文件和精确页码。

(注:嵌入向量模型是可选的,但推荐使用。如果加载失败,系统会优雅地回退到仅关键词匹配)。
数据:规模化下节省 99%
由于 Hybrid RAG 流水线限制了返回的文本切片,token 节省量会随着文档规模的增大而呈指数级增长。以下是 Token Saver 在基准测试中的表现(通过 tiktoken 测量,假设每份文档一个问题):
| 文档 | 页数 | 整篇文档 token 数 | 返回的 token 数 | 节省的 Token |
| FDA 药品标签 | 33 | 23,959 | 1,021 | 95.7% |
| GDPR(欧盟 2016/679) | 88 | 70,260 | 996 | 98.6% |
| SFFA 诉哈佛案 | 233 | 133,349 | 740 | 99.4% |
免责声明:Token 计数使用 cl100k_base 作为替代,基线假设每次搜索都对整篇文档计费。
对于需要反复处理法院判决书、技术标准、财务报告或高密度教材的专业人士而言,Token Saver 消除了重复性的 token 税。
安全与本地隐私
对于企业用户和法律专业人士而言,数据隐私是不可妥协的。Token Saver 的安全模型建立在三大支柱之上:
- 零上传:文档永远不会离开你的机器。
- 文件夹白名单:你为 Token Saver 配置一个特定文件夹。服务器将主动拒绝读取该指定目录之外的文件。
- 网络隔离:服务器仅通过标准 I/O(stdio)与 Claude Desktop 通信。没有任何监听网络端口,从而大幅缩小了攻击面。
模型表现:Sonnet 与 Opus 对比
Marktechpost 的 Token Saver 在 Claude 3.5 的三个层级上均可运行,但测试揭示了不同的行为表现:
- Claude 3.5 Sonnet(推荐):稳妥的默认选择。它能完美处理松散的文件引用,当两个文件名称相似时会主动提出澄清性问题,并能正确应用检索到的页码。
- Claude 3 Opus:擅长处理包含多种声音的复杂文档(例如含多数意见与异议的法律裁决)。Opus 足够聪明,当它基于上下文而非明确文本推断出归属时,会主动标记出来。
几分钟即可上手
与许多需要复杂 Python 环境和 JSON 配置的开源 AI 工具不同,Token Saver 打包为单个 .mcpb 捆绑包。
- 从项目的 GitHub Releases 页面下载 token-saver-ccr.mcpb。
- 打开 Claude Desktop -> Settings -> Extensions -> Install extension。
- 启用该扩展,点击 Configure,然后选择一个专门用于存放参考 PDF 的文件夹。
- 在首次提示时,选择 Always allow。
在选择文件夹之前,该扩展不会运行,因为这一选择同时服务于三个目的。

这个文件夹值得花点时间思考。它设定了可读取内容的边界,正是它让你可以按文件名请求文件,而不必输入路径,它也是对话开始时服务器向 Claude 展示的列表。一个只存放你打算询问内容的小文件夹,效果要比把它指向整个 Documents 文件夹好得多。
核心要点
- 大幅降低成本:通过使用本地混合 RAG 仅将相关段落传给 LLM,token 成本最多可降低 99%。对话越长,节省越多。
- 可验证的准确性:由于 Token Saver 会为每个检索到的片段附上准确的页码,你可以通过打开本地 PDF 立即验证 Claude 的说法。
- 绝对隐私:边界就是你的本地机器。你的专有数据永远不会被上传到 AI 提供商的服务器。
- 无摩擦安装:无需 Python。只需安装一个简单的 .mcpb 文件,即可在 Claude Desktop 中立即运行。
查看 GitHub Repo。
参考文献: MCP Bundle 格式 | all-MiniLM-L6-v2 | pdfkb-mcp | wesleygriffin/pdfrag | 语料库:Dobbs 诉 Jackson 妇女健康组织案;Berkshire Hathaway 2023 年度报告
AI developers, researchers, and professionals frequently hit a frustrating wall when analyzing large documents with LLMs: the hidden, compounding cost of context windows. Pasting a 200-page PDF into a chat isn’t a one-time charge. Because the conversation history is re-sent to the model on every single turn, that massive document is paid for again with every follow-up question.
Marktechpost AI team just released Token Saver, an open-source Model Context Protocol (MCP) extension for Claude Desktop (MIT licensed, currently at v1.0). It was developed at Marktechpost AI Media Inc by Arnav Rai (CS student at Rochester Institute of Technology) during his internship at Marktechpost, supervised by Jean-marc Mommessin and Asif Razzaq. Token Saver fundamentally changes how Claude interacts with local documents. By implementing a Local Hybrid RAG (system directly on your machine, it allows you to ask questions about massive PDFs without ever uploading the actual file to the model.
Token consumption is slashed by 92% to 99%, privacy is guaranteed, and setup requires exactly zero Python environments or terminal configurations.
How it looks!

The Hidden Token Drain of Large PDFs
Most users assume that when they drop a PDF into Claude, it simply extracts the text. In reality, Claude’s default behavior converts each page into an image to preserve charts and layouts, while separately extracting text. Before a single image token is even counted, the text alone can run 1,500 to 3,000 tokens per page.
While Prompt Caching and Claude Projects help soften this blow, they don’t solve the core issue: the entire document still crosses the boundary to the provider’s servers. Furthermore, if you only need two relevant paragraphs from a 1,000-page textbook, forcing the LLM to search the entire 1,000 pages itself is both inefficient and prone to hallucination.
How Local Hybrid RAG Solves the Problem
Marktechpost’s Token Saver acts as a local MCP server : a lightweight background program on your machine that Claude can call as a tool. The PDF never leaves your hard drive.
When you ask a question, Token Saver utilizes Local Hybrid RAG to find the answer. Hybrid RAG is the gold standard for document retrieval because it combines two powerful search methods:
- Keyword Matching (BM25): Runs over SQLite’s built-in FTS5 search (weighted at 0.4) to find exact terminology.
- Semantic Search (Cosine Similarity): Uses a local all-MiniLM-L6-v2 embedding model (weighted at 0.6) to understand the meaning of your question, rather than just matching exact words.
By blending these two approaches locally, the server searches the file and hands Claude only the highly relevant passages. Claude then synthesizes the answer, citing the exact page numbers and providing a running tally of the tokens you just saved.
The 8-Stage Processing Pipeline
Token Saver runs entirely inside a single, long-running local process. Before any text reaches Claude, the local Hybrid RAG pipeline executes eight rapid steps:
- Extract: Uses pypdfium2 (with pypdf as a fallback) to pull text.
- Chunk: Splits text into 180-word passages, overlapping by 40 words so context is never blindly cut.
- Score (Hybrid RAG): Evaluates chunks using the blended BM25 and local embedding model.
- Gate: Enforces a quality threshold. Passages sharing no exact keywords must pass a semantic similarity floor of 0.25 to qualify.
- Deduplicate: Drops near-identical passages.
- Trim: Narrows the passage down strictly to the sentences that answer the user’s prompt.
- Budget: Caps the total payload sent to Claude at 8,000 characters.
- Envelope: Wraps the retrieved text in a document-chunk element containing the source file and precise page number.

(Note: The embedding model is optional but recommended. If it fails to load, the system gracefully falls back to keyword-only matching).
The Numbers: 99% Savings at Scale
Because the Hybrid RAG pipeline caps the returned text slice, the token savings grow exponentially with the size of the document. Here is how Token Saver performed in benchmarking (measured via tiktoken, assuming one question per document):
| Document | Pages | Whole Doc Tokens | Returned Tokens | Tokens Saved |
| FDA drug label | 33 | 23,959 | 1,021 | 95.7% |
| GDPR (EU 2016/679) | 88 | 70,260 | 996 | 98.6% |
| SFFA v. Harvard | 233 | 133,349 | 740 | 99.4% |
Disclaimer: Token counts use cl100k_base as a stand-in, and baselines assume the whole document is charged on every search.
For professionals working repeatedly with court opinions, technical standards, financial reports, or dense textbooks, Token Saver eliminates the repetitive token tax.
Security and Local Privacy
For enterprise users and legal professionals, data privacy is non-negotiable. Token Saver’s security model rests on three pillars:
- Zero Uploads: The document never leaves your machine.
- Folder Allowlisting: You configure a specific folder for Token Saver. The server will actively refuse to read files outside of this designated directory.
- Network Isolation: The server communicates with Claude Desktop over standard I/O (stdio) only. There are no listening network ports, drastically reducing the attack surface.
Model Performance: Sonnet vs. Opus
Marktechpost’s Token Saver works across all three Claude 3.5 tiers, but testing revealed distinct behaviors:
- Claude 3.5 Sonnet (Recommended): The sensible default. It handles loose file references perfectly, asks clarifying questions if two files have similar names, and correctly applies the retrieved page numbers.
- Claude 3 Opus: Excels at complex documents with multiple voices (e.g., legal rulings with majority opinions and dissents). Opus is smart enough to flag when it infers an attribution based on context rather than explicit text.
Getting Started in Minutes
Unlike many open-source AI tools that require complex Python environments and JSON configurations, Token Saver is packaged as a single .mcpb bundle.
- Download token-saver-ccr.mcpb from the project’s GitHub Releases page.
- Open Claude Desktop -> Settings -> Extensions -> Install extension.
- Enable the extension, click Configure, and select a dedicated folder where you keep your reference PDFs.
- At the first prompt, choose Always allow.
The extension will not run until a folder is chosen, because that single choice serves three purposes at once.

That folder is worth a moment’s thought. It sets the boundary of what can be read, it is what lets you ask for a file by name instead of typing a path, and it is the list the server shows Claude when a conversation starts. A small folder holding only what you intend to ask about works considerably better than pointing it at all of Documents.
Key Takeaways
- Massive Cost Reduction: By using Local Hybrid RAG to pass only relevant paragraphs to the LLM, token costs drop by up to 99%. The longer the chat, the more you save.
- Verifiable Accuracy: Because Token Saver attaches exact page numbers to every retrieved chunk, you can instantly verify Claude’s claims by opening your local PDF.
- Absolute Privacy: The boundary is your local machine. Your proprietary data is never uploaded to an AI provider’s server.
- Frictionless Setup: No Python required. A simple .mcpb file install gets you running in Claude Desktop instantly.
Check out the GitHub Repo.
References: MCP Bundle format | all-MiniLM-L6-v2 | pdfkb-mcp | wesleygriffin/pdfrag | Corpora: Dobbs v. Jackson Women’s Health Organization; Berkshire Hathaway 2023 Annual Report