localpdf-mcp
A local, offline MCP PDF server for AI agents that manipulates PDFs on disk and returns metadata rather than document contents.
Inspect a PDF: page count, byte size, encryption flag, producer, sha256.
Merge two or more PDFs in order into a new file.
Split/extract requested pages into individual files.
Compress structurally with object streams, reporting honest before/after sizes.
Extract the text layer to a
.txtfile with per-page character counts; return text only with explicitinline: true.Replace text cosmetically via overlay (white patch + new text), not for redaction.
OCR scanned PDFs offline with tesseract for
engandrus, adding an invisible text layer and returning counts/confidence.Keeps processing local: no network calls, no document bytes in tool results, inputs are not overwritten, and scratch files are pruned.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@localpdf-mcp inspect report.pdf and tell me its page count and size"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
localpdf-mcp
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 |
| page count, size, encryption flag, producer | metadata only |
| concatenate 2+ PDFs in order | out path, pages, sha256 |
| each requested page into its own file | file list with per-file sha256 |
| structural resave with object streams | before/after bytes + honest % |
| text layer → .txt on disk | per-page char counts; text only with |
| find a string, draw white patch + replacement | matches, bbox, page; |
| 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 protocolFrom 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.mjsOCR 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-mcpClaude 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 PDFsWhat "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.mjsBoth 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 — seetesseract.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 usageNothing 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:
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.
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_textreturns text only with an explicitinline: true, and says so in the result.Local is not the same as unsynced. Scratch files live in
~/.localpdf-mcp/tmp(mode 0700) and are pruned after an hour, precisely because~/Desktopand~/Documentsmay be synced to iCloud Drive — a document leak with no HTTP request involved. PointLOCALPDF_MCP_WORKDIRsomewhere 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_textis 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_compressdoes 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 withnpm i @tesseract.js-data/<lang>and one line insrc/engine.mjs.Encrypted PDFs are reported by
pdf_inspectbut 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 toolspdf_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
Scored across 7 tools
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.
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.
Seven tools is well-scoped for a local PDF utility set. Each tool earns its place covering a distinct manipulation operation with no filler.
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
Related MCP Connectors
PDF and image tools for AI agents: compress, merge, split, OCR, sign. Runs locally, never uploads.
PDF tools for AI agents: validate, extract, merge, split, compress, OCR, sign and redact.
Merge, split, extract, rotate, reorder and stamp PDF pages from your AI chat, all offline.
Merge, split, extract, rotate, reorder and stamp PDF pages from your AI chat, all offline.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables 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-
- AlicenseAqualityDmaintenanceEnables 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.446 npmMIT
- AlicenseBqualityCmaintenanceEnables 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.2514 PyPI1MIT
- AlicenseAqualityBmaintenanceEnables 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.1248 PyPI1Apache 2.0