Skip to main content
Glama

localpdf-mcp

ci Localpdf MCP on mcprush

Local, offline PDF engine for AI agents, exposed as an MCP server.

The agent decides, the document stays put: every tool runs in this process on your machine, makes no network requests at all, and returns metadata — paths, sizes, sha256, counts — instead of document bytes or document text.

Status: 0.1.6, published on npm as localpdf-mcp. Requires Node 22+. No hosted service and no phone-home: nothing in this package calls localpdf.online or any other server.

Why this exists and where it stops: https://localpdf.online/pdf-mcp-server. The browser workspace that shares the same approach is at https://localpdf.online/app.

Tools

Tool

What it does

Returns

pdf_inspect

page count, size, encryption flag, producer

metadata only

pdf_merge

concatenate 2+ PDFs in order

out path, pages, sha256

pdf_split

each requested page into its own file

file list with per-file sha256

pdf_compress

structural resave with object streams

before/after bytes + honest %

pdf_extract_text

text layer → .txt on disk

per-page char counts; text only with inline: true

pdf_replace_text

find a string, draw white patch + replacement

matches, bbox, page; mode: "overlay"

pdf_ocr

invisible text layer for scans (tesseract, local traineddata)

per-page lines/chars/confidence

Page numbers are 1-based. The input file is never overwritten — out must differ.

Related MCP server: tooldash-mcp

Install

Zero-install (npx fetches the package and its deps once):

npx -y localpdf-mcp          # speaks MCP on stdio; nothing on stdout except protocol

From a checkout, if you want to hack on it:

git clone https://github.com/ulinycoin/localpdf-mcp && cd localpdf-mcp
npm install
node src/server.mjs

OCR is an optional extra: npm i tesseract.js @tesseract.js-data/eng @napi-rs/canvas (plus @tesseract.js-data/rus for Russian). Without them the other six tools work and pdf_ocr returns a clear "dependencies not installed" error.

The invisible OCR layer embeds a bundled Roboto subset that covers Latin, Cyrillic and Greek — Russian text used to fail with WinAnsi cannot encode "П". A line in another script (CJK, Arabic) has no glyphs in that font, so it is skipped and counted in lines_skipped instead of being written with holes.

Claude Code

claude mcp add localpdf -- npx -y localpdf-mcp

Claude Desktop / Cursor / other JSON-config clients

{
  "mcpServers": {
    "localpdf": {
      "command": "npx",
      "args": ["-y", "localpdf-mcp"]
    }
  }
}

Verify

node test/mcp-client.mjs      # real MCP handshake: initialize, tools/list, tools/call
node test/smoke.mjs           # 12 checks on real generated PDFs

What "offline" is proven by, not promised

Two independent gates, both run in CI-able form:

# 1. every socket/DNS/fetch attempt throws (also inherited by the tesseract child process)
NODE_OPTIONS="--import ./test/deny-net.mjs" node test/smoke.mjs

# 2. the OS denies the network for the whole process tree
sandbox-exec -p '(version 1)(allow default)(deny network*)' node test/smoke.mjs

Both pass with OCR enabled. The things that would otherwise phone home are pinned locally:

  • pdfjs standard fonts → node_modules/pdfjs-dist/standard_fonts/ (standardFontDataUrl)

  • tesseract traineddata → staged from node_modules/@tesseract.js-data/* into ~/.localpdf-mcp/tmp/tessdata (by default tesseract.js fetches from jsDelivr — see tesseract.js/src/worker-script/index.js)

  • no analytics, no version check, no network reporting: a local usage count (~/.localpdf-mcp/usage.jsonl: tool, outcome, version) stays on disk and is never sent

Local usage count

The server appends one line per tool call to ~/.localpdf-mcp/usage.jsonl: tool name, outcome (ok/error) and version. No arguments, paths, file names or document contents, and nothing leaves the machine — this package has no network code, and the gates above deny it.

Print the aggregate yourself:

npx localpdf-mcp usage

Nothing is sent automatically; share the output only if you choose to.

Privacy boundary — read this before quoting anything

This server keeps the engine and the files local. It cannot keep your agent local:

  1. What the model reads is gone. If your agent opens the PDF and reasons about its contents, that text goes to the model provider's context and logs. Nothing in this package changes that.

  2. Tool results are metadata on purpose. Returning document bytes in a tool result would ship the whole file into the model context — the classic MCP data leak. Tools return paths; pdf_extract_text returns text only with an explicit inline: true, and says so in the result.

  3. Local is not the same as unsynced. Scratch files live in ~/.localpdf-mcp/tmp (mode 0700) and are pruned after an hour, precisely because ~/Desktop and ~/Documents may be synced to iCloud Drive — a document leak with no HTTP request involved. Point LOCALPDF_MCP_WORKDIR somewhere unsynced if you disagree.

So the honest claim is: the engine and the files stay on your machine; whatever your agent reads itself goes to its provider. "No leak at all" is only true when the model is local too (Ollama, LM Studio), not when it is a cloud agent.

Known limitations

  • pdf_replace_text is an overlay, not a content-stream edit: a white patch and new drawn text on top. The original text layer survives, so search and copy-paste return the old string as well as the new one. Fine for cosmetic fixes; not for redaction.

  • Fonts are substituted with Helvetica → correct for Latin-1, wrong for Cyrillic/CJK.

  • pdf_compress does no image recompression. Text-only PDFs may not shrink at all, and already-optimised files can grow — the tool reports the real numbers instead of guessing.

  • OCR languages installed offline: eng, rus. Add more with npm i @tesseract.js-data/<lang> and one line in src/engine.mjs.

  • Encrypted PDFs are reported by pdf_inspect but not decrypted.

Layout

src/server.mjs   MCP surface (zod schemas, 7 tools)
src/engine.mjs   tool implementations, pdf-lib + pdfjs + tesseract, zero network
src/workdir.mjs  scratch dir (~/.localpdf-mcp/tmp), input/out collision guard
test/            smoke, MCP client, network-deny preload
get-started.md   the playbook you hand to an agent (Vercel-style onboarding)

Available Tools

7 tools
pdf_compressCompress PDFA

Structural resave with object streams. No image recompression: text-only PDFs may barely shrink, already-optimised ones may grow. Reports before/after sizes honestly.

Inputs: path (required), out, use_object_streams.

pdf_extract_textExtract textA

Extract the text layer to a .txt file and return per-page character counts. The text is NOT returned by default — set inline=true only if the caller really needs the content in its context (it then lands in the model provider logs).

Inputs: path (required), out, pages, inline.

pdf_inspectInspect PDFA

Read a PDF header: page count, byte size, encryption flag, producer, sha256. No content is returned.

Inputs: path (required).

pdf_mergeMerge PDFsA

Concatenate two or more PDFs into a new file, in the given order.

Inputs: out (required), paths (required).

pdf_ocrOCR (offline)B

Add an invisible text layer to a scanned PDF using tesseract with locally installed traineddata. Done for: eng, rus. Recognised text is not returned, only counts and confidence.

Inputs: path (required), out, langs, pages, +1 more.

pdf_replace_textReplace text (overlay)A

Find a string on a page and draw a white patch with the replacement on top. IMPORTANT: this is an overlay, not a true content-stream edit — the original text layer stays, so copy-paste still returns the old string. Font is substituted with Helvetica (Latin-1 only). Use it for cosmetic fixes, not for redaction.

Inputs: find (required), path (required), replace (required), all, +2 more.

pdf_splitSplit / extract pagesB

Write each requested page of a PDF into its own file inside out_dir.

Inputs: path (required), pages, out_dir.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A3.8/5.0

    Scored across 7 tools

    Disambiguation5/5

    Each tool targets a distinct PDF operation: OCR, inspect, merge, split, compress, extract, and replace. The two text-oriented tools (pdf_ocr vs pdf_extract_text) could superficially overlap, but descriptions clearly separate adding a text layer from extracting it, and pdf_replace_text is explicitly an overlay, keeping them distinct.

    Naming Consistency5/5

    All seven tools follow a uniform pdf_verb_noun snake_case pattern (pdf_ocr, pdf_inspect, pdf_merge, etc.). No mixed conventions or stray styles.

    Tool Count5/5

    Seven tools is well-scoped for a local PDF utility set. Each tool earns its place covering a distinct manipulation operation with no filler.

    Completeness4/5

    Core lifecycle is well covered: inspect, merge, split, compress, OCR, extract, and cosmetic text replacement. Notable gaps remain for true redaction (replace_text is only an overlay) and page-level operations like rotate, reorder, or delete pages.

    Maintenance

    ActivityMaintained
    ResponsivenessNo recent community issues

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables AI agents to perform comprehensive PDF operations locally, including compression, text extraction, PII redaction, page organization, splitting, merging, watermarking, creation, and form filling, all without cloud uploads.
      17 npm
      -
    • A
      license
      A
      quality
      D
      maintenance
      Enables AI agents to inspect PDFs, merge or extract pages, and clean text entirely offline through the Model Context Protocol, with no uploads, API keys, or network calls.
      4
      46 npm
      MIT
    • A
      license
      B
      quality
      C
      maintenance
      Enables AI agents to perform local-first PDF processing entirely on-device, including OCR write-back to make scans searchable, unlocking and re-encrypting PDFs, splitting/merging/rotating pages, and compressing files, with no cloud calls or file uploads.
      25
      14 PyPI
      1
      MIT
    • A
      license
      A
      quality
      B
      maintenance
      Enables AI agents to inspect and work with PDF files entirely on the local machine, covering page counts, metadata, layout, encryption permissions, scan-vs-text detection, and page rendering. Generated results land in a temporary workspace as short artifact ids that can be chained between tools and exported to real folders on request.
      12
      48 PyPI
      1
      Apache 2.0