Technology & AI

Meet the Token Saver: An Open Source MCP Extension Using Local Hybrid RAG to Reduce Token Costs Claude PDF 90-99%

AI developers, researchers, and experts often hit a frustrating wall when analyzing large documents with LLMs: the hidden, integrated costs of context windows. Attaching a 200-page PDF to a thread is not a one-time charge. Because the conversation history is resubmitted to the model every time, that large document is repaid with every follow-up query.

The Marktechpost AI team has just been released Token saveran open source Model Context Protocol (MCP) extension for Claude Desktop (MIT license, currently in 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 the way Claude interacts with local documents. By using a Local Hybrid RAG (the program directly on your machine, allows you to query large PDFs without uploading the actual file to the model.

Token usage is reduced by 92% to 99%, privacy is guaranteed, and setup directly requires zero Python environments or terminal configuration.

What a sight!

Hidden Token for Large PDFs

Many users think that when they throw a PDF into Claude, it just outputs the text. In fact, Claude’s default behavior converts each page into an image to store the charts and layouts, while outputting the text separately. Before a single image token is counted, text alone can use 1,500 to 3,000 tokens per page.

Although the Quick Backup and Claude projects help to reduce this impact, they do not solve the main problem: every document still crosses the border to the provider’s servers. Furthermore, if you only need two relevant paragraphs from a 1,000-page book, forcing the LLM to search all 1,000 pages itself is inefficient and prone to misidentification.

Local Hybrid RAG Solves the Problem

Image by Marktechpost Token saver it works as a local MCP server : a simple 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 uses Local Hybrid RAG to find the answer. Hybrid RAG is the gold standard for document retrieval because it combines two powerful search methods:

  1. Keyword matching (BM25): It runs on top of FTS5’s built-in SQLite search (weighted 0.4) to find exact words.
  2. Semantic Search (Cosine Similarity): It uses space all-MiniLM-L6-v2 embedding model (with weight 0.6) to understand definition of your question, rather than just matching exact words.

By combining these two methods locally, the server searches the file and treats Claude only the most relevant episodes. Claude then compiles the answer, quoting the exact page numbers and giving a practical calculation of the tokens you just saved.

8-Step Processing Pipeline

Token Saver operates within a single, long-running local process. Before any text reaches Claude, the Hybrid RAG local pipeline performs eight quick steps:

  1. Release: It uses pypdfium2 (with pypdf as a fallback) to pull the text.
  2. Chunk: It breaks the text into chunks of 180 words, overlapping by 40 words so that context is never blindly cut.
  3. Score (Hybrid RAG): Inspects components using BM25 integrated with local embedding model.
  4. Gate: It enforces the quality limit. Articles that do not share specific keywords must exceed a semantic similarity level of 0.25 to be eligible.
  5. Separate: Drops almost identical passages.
  6. Decide: Reduce the role strictly to sentences that respond to user input.
  7. Budget: It includes the payload sent to Claude in 8,000 letters.
  8. Envelope: Wraps the returned text in the document section that contains the source file and the exact page number.

(Note: The embedding model is optional but recommended. If it fails to load, the system defaults back to keyword matching only).

The Numbers: 99% Economies of Scale

Because the Hybrid RAG pipeline encapsulates the piece of text returned, the token savings increase exponentially with the size of the document. Here’s how Token Saver works in scaling (measured in tiktoken, assuming one query per document):

DocumentPagesWhole Doc TokensTokens returnedSaved Tokens
FDA drug label3323,9591,02195.7%
GDPR (EU 2016/679)8870,26099698.6%
SFFA v. Harvard233133,34974099.4%

Disclaimer: Token calculations use cl100k_base as the entry point, and the bases assume that every document is charged for every search.

For professionals who work repeatedly on court opinions, technical standards, financial reports, or dense documents, the Token Saver eliminates the burden of repetitive tokens.

Site Security and Privacy

For business users and legal professionals, data privacy is non-negotiable. Token Saver’s security model is based on three pillars:

  • Zero Loading: The document never leaves your device.
  • Folder Allow List: Configures a specific Token Saver folder. The server will refuse to read files outside of this designated directory.
  • Network Classification: The server communicates with Claude Desktop via standard I/O (stdio) only. There are no listening network ports, which greatly reduces the attack surface.

Model Performance: Sonnet vs. Op

Image by Marktechpost Token Saver works on all three versions of Claude 3.5, but testing revealed different behavior:

  • Claude 3.5 Sonnet (Recommended): A logical default. It handles loose file pointers well, asks clarifying questions if two files have the same name, and correctly uses returned page numbers.
  • Claude 3 Opus: It works well for complex documents with many voices (eg, legal decisions with many opinions and dissents). Opus is smart enough to flag when it displays a context-based attribute instead of plain text.

Getting Started in Minutes

Unlike many open source AI tools that require complex Python environments and JSON configuration, Token Saver is packaged as one. .mcpb a lot.

  1. Download token-saver-ccr.mcpb from the GitHub Releases project page.
  2. Open it Claude Desktop -> Settings -> Extensions -> Enter the extension.
  3. Enable the extension, click Prepareand choose a dedicated folder where you store your reference PDFs.
  4. At the first command, choose Always allow.

The extension won’t work until a folder is selected, because that one option has three purposes at once.

That folder is worth a moment’s thought. It limits what can be read, it’s what allows you to request a file by name instead of typing the path, and it’s a list the server shows Claude when a conversation starts. A subfolder that holds only what you intend to ask about works much better than indexing through all the Documents.

Key Takeaways

  • Big Cost Reduction: By using Local Hybrid RAG to transfer only relevant sections to LLM, token costs are reduced by 99%. The longer the conversation, the more conservative you are.
  • Guaranteed Accuracy: Because the Token Saver attaches exact page numbers to all retrieved passages, you can quickly verify Claude’s claims by opening your local PDF.
  • Absolute privacy: The border is your local machine. Your proprietary data is never uploaded to the AI ​​provider’s server.
  • Frictionless Setup: No Python is required. A simple .mcpb file installation gets you up and running on Claude Desktop in no time.

Check out the GitHub Repo.

References: MCP batch format | all-MiniLM-L6-v2 | pdfkb-mcp | wesleygriffin/pdfrag | Corpora: Dobbs v. Jackson Women’s Health Organization; Berkshire Hathaway Annual Report 2023


Arnav Rai

Arnav is currently a student at Rochester Institute of Technology pursuing a Bachelor’s degree in Computer Science and a minor in Economics with experience in backend development, and contributes to Marktechpost, where he writes about AI/ML research.


Jean-marc is a successful AI business executive .He leads and accelerates the growth of AI powered solutions and started a computer vision company in 2006. He is a well-known speaker at AI conferences and has an MBA from Stanford.


Asif Razzaq is the CEO of Marktechpost Media Inc. As a visionary entrepreneur and engineer, Asif is committed to harnessing the power of Artificial Intelligence for the benefit of society. His latest endeavor is the launch of Artificial Intelligence Media Platform, Marktechpost, which stands out for its extensive coverage of machine learning and deep learning stories that are technically sound and easily understood by a wide audience. The platform boasts of more than 2 million monthly views, which shows its popularity among viewers.



Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button