Skip to main content
Glama
xiongxingzhe

mcp-pdf-tokensaver

by xiongxingzhe

mcp-pdf-tokensaver

mcp-pdf-tokensaver MCP server mcp-pdf-tokensaver score

A layout-aware MCP server that analyzes PDF structures to save up to 90% context tokens for LLMs.

Stop wasting LLM tokens on PDFs. This MCP server provides layout-aware, two-pass chunking and formula protection for Cursor, Claude Desktop, and other AI editors.

License: MIT Node.js MCP npm

Why mcp-pdf-tokensaver?

Reading dense, multi-column technical papers, API documentation, or corporate PDFs inside AI editors often leads to two major frustrations:

  1. The Token Tax: Multi-column text gets scrambled, forcing you to upload full documents and waste tens of thousands of context tokens.

  2. Formula Corruption: LaTeX equations frequently get broken or mistranslated during full-text ingestion.

mcp-pdf-tokensaver provides a 100% local solution to shield your token window.

Related MCP server: pdf-agent-mcp

Features

  • Layout-Aware Inspection: Parse PDF structures (multi-columns, tables, headings) without uploading full text immediately.

  • Two-Pass Token Saving: LLMs first inspect the document outline via a condensed JSON schema, then selectively fetch exact text chunks based on blockId.

  • 100% Client-Side & Secure: All parsing happens locally. Your sensitive data never leaves your machine.

  • Scanned PDF Support: OCR integration for scanned documents (English).

How It Works

Instead of feeding raw PDF streams into the LLM, this server empowers your AI model with a Two-Pass Precise Retrieval Strategy:

  1. inspect_pdf_structure: The LLM scans a super-condensed layout skeleton of your PDF, mapping pages, columns, and headings in milliseconds.

  2. fetch_pdf_chunks: The LLM target-fetches only the exact text rows or equations it needs based on specific blockIds.

Token Savings Comparison

Solution

Working Principle

Token Impact

Traditional Full-Text

Dumps entire PDF as Markdown into context

🔴 Catastrophic: 40-page doc can burn 30K+ tokens per turn

Vector RAG

Local embedding search, returns top-3 chunks

🟡 Medium: No global document awareness

mcp-pdf-tokensaver

Structure-aware agentic retrieval

🟢 Minimal: Saves 90%+ tokens

Installation

npm install -g mcp-pdf-tokensaver

Option 2: Install from source

git clone https://github.com/anthropics/mcp-pdf-tokensaver.git
cd mcp-pdf-tokensaver
npm install
npm run build

Configuration

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "pdf-tokensaver": {
      "command": "mcp-pdf-tokensaver",
      "args": []
    }
  }
}

Cursor / Windsurf

Add to your MCP settings:

{
  "mcpServers": {
    "pdf-tokensaver": {
      "command": "mcp-pdf-tokensaver",
      "args": []
    }
  }
}

Custom Configuration

You can configure limits via environment variables:

{
  "mcpServers": {
    "pdf-tokensaver": {
      "command": "mcp-pdf-tokensaver",
      "args": [],
      "env": {
        "MCP_PDF_MAX_SIZE_MB": "100",
        "MCP_PDF_MAX_PAGES": "500",
        "MCP_OCR_TIMEOUT_MS": "30000"
      }
    }
  }
}

Usage

Once configured, simply ask your AI editor to analyze a PDF:

"Help me analyze the structure of paper.pdf on my desktop. Where are the core formulas?"

The LLM will automatically call inspect_pdf_structure to get a condensed layout skeleton, then use fetch_pdf_chunks to retrieve only the relevant sections.

Tools

inspect_pdf_structure

Analyzes the layout and structural skeleton of a local PDF file.

Input:

{
  "filePath": "/path/to/your/document.pdf"
}

Output:

{
  "status": "success",
  "documentMeta": {
    "path": "/path/to/your/document.pdf",
    "totalPages": 24,
    "isEncrypted": false,
    "hasScannedPages": [],
    "estimatedFullTextTokens": 84000
  },
  "structureSkeleton": [
    {
      "blockId": "page_1_para_1",
      "type": "heading",
      "pageIndex": 0,
      "level": 1,
      "summary": "1. Introduction",
      "tokenEstimate": 8
    },
    {
      "blockId": "page_2_para_3",
      "type": "text",
      "pageIndex": 1,
      "layoutType": "double-column",
      "summary": "Discusses client-side WebAssembly...",
      "tokenEstimate": 45
    }
  ]
}

fetch_pdf_chunks

Selectively fetch specific text paragraphs or equations based on their blockId.

Input:

{
  "filePath": "/path/to/your/document.pdf",
  "blockIds": ["page_2_para_3", "page_4_para_1"]
}

Output:

{
  "status": "success",
  "fetchedChunks": {
    "page_2_para_3": {
      "type": "text",
      "content": "We implement a pure client-side PDF parsing pipeline...",
      "pageContext": "Page 2"
    },
    "page_4_para_1": {
      "type": "equation",
      "content": "$$\\Theta(N) = \\sum_{i=1}^{N} \\alpha_i$$",
      "pageContext": "Page 4"
    }
  }
}

Limitations

  • Encrypted PDFs are not supported

  • Scanned PDF OCR is limited to English

  • Maximum file size: 100MB (configurable)

  • Maximum pages: 500 (configurable)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments


Optimized by the core layout engine of GoLocalPDF — the leading privacy-first client-side PDF utility.

If you need a seamless browser-based PDF reading experience with dual-pane translation, visit golocalpdf.com.

Available Tools

1 tool
fetch_pdf_chunksA

Selectively fetch the raw, highly-structured text paragraphs or equations of specific blocks based on their blockId. Use this after inspect_pdf_structure to pull only the necessary data chunks.

ParametersJSON Schema
NameRequiredDescriptionDefault
blockIdsYesAn array of specific blockId strings discovered via inspect_pdf_structure tool.
filePathYesThe absolute path to the local PDF file.

TDQS

A4.2/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It describes what the tool does (fetch structured text) but does not disclose behavioral traits such as error handling, performance, or limitations on blockIds.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences, no wasted words, and front-loads the purpose. It is appropriately concise for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simple two-parameter input and no output schema, the description is sufficient for an agent to use the tool correctly in conjunction with inspect_pdf_structure. It could include more on return format but is not incomplete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, baseline 3. The description adds value by specifying that blockIds come from inspect_pdf_structure and that filePath is the absolute path to the PDF file, providing context beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('fetch') and resource ('raw, highly-structured text paragraphs or equations'), and clearly distinguishes it from the sibling tool inspect_pdf_structure by stating it is used after that tool to pull specific chunks.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use this tool: 'after inspect_pdf_structure' and 'to pull only the necessary data chunks.' It provides clear context for usage, though it does not explicitly state when not to use it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

TDQS

A3.9/5.0
Disambiguation5/5

With only one tool, there is no ambiguity. The tool's purpose is clear and distinct by default.

Naming Consistency5/5

The single tool follows a clear verb_noun pattern (fetch_pdf_chunks), which is consistent within the set.

Tool Count2/5

A single tool is too few for a PDF processing server, especially since it references a missing tool (inspect_pdf_structure) that is essential for its intended workflow.

Completeness1/5

The server's sole tool cannot function as intended without a prerequisite tool for PDF structure inspection. This is a severe completeness gap.

Maintenance

ActivitySlowing
ResponsivenessSyncing

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A local-first MCP server that enables semantic search over PDF and DOCX documents using structure-aware parsing and vector storage. It allows users to query their local knowledge base through Claude Code without cloud dependencies or GPU requirements.
  • F
    license
    Not graded
    quality
    D
    maintenance
    A local MCP server that extracts text-layer content from PDF files, enabling AI agents to inspect, extract text, outlines, and page content.
  • A
    license
    A
    quality
    D
    maintenance
    Self-hosted MCP server for Claude Code that implements PageIndex vectorless RAG locally, enabling indexing, navigation, and content extraction of PDF documents without LLM calls during search.
    5
    128
    1
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    A local-first MCP server that ingests PDFs, extracts structure, and provides semantic search and sequential navigation tools for AI clients to query and learn from documents.
    10
    MIT

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/xiongxingzhe/mcp-pdf-tokensaver'

If you have feedback or need assistance with the MCP directory API, please join our Discord server