Skip to main content
Glama
pdf-toolkit-mcp

pdf-toolkit-mcp

by 0xmortuex

pdf-toolkit-mcp

Everyday PDF tasks for your AI agent, with nothing to install but Python.

pdf-toolkit-mcp is an MCP server that lets an agent look inside a PDF, read it in budget-sized pieces, search it, pull out tables and images, and merge, split, reorder or rotate pages. It is built on pure-Python wheels only (pypdf and pdfplumber), so uvx pdf-toolkit-mcp works the same on Windows, macOS and Linux: no Java, no Ghostscript, no Poppler, no Camelot, no compiler.

What it looks like

> pdf_info report.pdf
Pages: 312
Encrypted: no
Text layer: yes (10/10 sampled pages have extractable text)
Page sizes (points, 72 per inch):
  595 x 842 (A4): pages 1-311
  842 x 595 (A4 landscape): pages 312
Outline / bookmarks:
  - Introduction (page 3)
  - Results (page 41)
    - Revenue by region (page 44)

> read_pdf report.pdf pages="41-"
--- Page 41 of 312 ---
...
[Output truncated at about 8000 tokens. Continue with pages="47-312" (266 more page(s), starting at page 47).]

> search_pdf report.pdf query="net revenue"
14 match(es) on 6 page(s) (44-46,88,201-202):
Page 44: ...Q3 net revenue rose 12% to 4.1M, driven by...

> read_pdf scan.pdf
WARNING: none of the selected pages has a text layer. This PDF looks scanned (images
only); extracting text needs OCR, which this server does not do.

Related MCP server: benspdf

Install

You need uv (or pip install pdf-toolkit-mcp).

Claude Code

claude mcp add pdf -- uvx pdf-toolkit-mcp --dir ~/Documents --dir ~/Downloads

Claude Desktop (claude_desktop_config.json)

{
  "mcpServers": {
    "pdf": {
      "command": "uvx",
      "args": ["pdf-toolkit-mcp", "--dir", "C:\\Users\\you\\Documents", "--dir", "C:\\Users\\you\\Downloads"]
    }
  }
}

The server can only touch the folders you pass with --dir (repeat the flag for more). With no --dir it uses the folder it was started in, which for Claude Desktop is rarely where your PDFs are, so pass at least one.

Tools

Tool

What it does

pdf_info

Pages, metadata, encrypted?, has a text layer?, page sizes, outline with page numbers. Call first.

read_pdf

Text by page range, optional layout mode, token budget with a "continue with pages=..." hint, clear notice for scanned pages.

search_pdf

Matches with page numbers and context snippets; plain (case-insensitive, line-wrap tolerant) or regex.

extract_tables

Tables as markdown or CSV text; lines strategy for ruled tables, text for borderless ones.

merge_pdfs

Concatenate PDFs in order, keeping bookmarks.

split_pdf

One file per range part: 1-3,5,7- makes three files.

extract_pages

New PDF from chosen pages, in the order written (reorders and repeats allowed).

rotate_pages

Rotate chosen pages by a multiple of 90 degrees.

extract_images

Save embedded images to a folder.

Page ranges are 1-based: 1-3,5,7- (7- means page 7 to the end).

Try asking

  • "What is in ~/Downloads/contract.pdf? How many pages, and does it have bookmarks?"

  • "Find every mention of 'termination' in the contract and tell me which pages."

  • "Read pages 12 to 15 of the annual report and summarise the revenue section."

  • "Pull the tables from pages 30-35 of statement.pdf as CSV."

  • "Split book.pdf into chapters: 1-24, 25-60 and 61 to the end."

  • "Merge cover.pdf, body.pdf and appendix.pdf into final.pdf."

  • "Page 4 of scan-001.pdf is sideways. Rotate it and save a fixed copy."

  • "Pull all the photos out of brochure.pdf."

  • "This PDF is password protected, the password is ... Read the first page."

Safety

  • Folder allow-list. Every read and every write must resolve inside a --dir folder. .. tricks, symlinks that point outside and sibling folders with a similar name are all rejected.

  • No silent overwrites. Write tools refuse to replace an existing file unless the call passes overwrite=true. split_pdf checks every output name before writing any, and overwrites go through a temporary file so a failure cannot leave a half-written PDF.

  • Originals are never modified unless you point output_path at the input and set overwrite=true yourself.

  • Passwords are a call parameter. They are handed to the PDF library and nowhere else: never logged, stored, or included in an error message. Output PDFs are not encrypted.

  • Errors are explicit and say what to do next (wrong password, page out of range, file exists, path outside the allowed folders). Nothing falls back silently.

Limits

  • No OCR. A scanned PDF has no text to extract. The tools detect this and say so rather than return an empty string; use an OCR tool on the page images (extract_images can export them).

  • Text extraction follows the PDF's own text layer. Multi-column pages can interleave; layout=true often helps.

  • Table detection is heuristic. Ruled tables are reliable; borderless ones need strategy="text" and may need checking.

  • Encrypted outputs, form filling, annotations and redaction are out of scope.

Learn how it is built

pdf-mcp-the-hard-way is a seven-module tutorial that builds a minimal version of this server from the raw bytes of a PDF up.

Tests

uv sync --extra test
uv run pytest tests

The tests generate real PDFs with reportlab (multi-page, Turkish text, ruled and borderless tables, bookmarks, AES-256 encryption, image-only scans, a 300-page document), run every tool against them, and drive the installed server over a real MCP stdio session.

License

MIT

Available Tools

9 tools
extract_imagesA

Save the images embedded in a PDF (photos, scans, logos) as files named p., in their original format where possible. Lists the files written. Vector drawings and text are not images and are not extracted.

output_dir: default _images next to the input. Created if missing. max_images: safety cap; the call fails (writing nothing) if more are found.

Inputs: path (required), pages, password, overwrite, +2 more. Returns: result

extract_pagesA

Copy selected pages into one new PDF, in the order written ('3,1,2' reorders; '2,2' repeats).

output_path: must end in .pdf. Default: _extracted.pdf next to the input. overwrite: replace the output if it exists. Default false.

Inputs: path (required), pages (required), password, overwrite, +1 more. Returns: result

extract_tablesA
Read-only

Extract tables from a PDF as markdown or CSV text, labelled with page number and size.

strategy 'lines' (default) finds tables drawn with ruling lines; use 'text' for borderless tables aligned by whitespace (less precise). Scanned PDFs have no tables to find. Output is capped at roughly max_tokens with a continue hint, like read_pdf.

pages: 1-based ranges like '2-4,9'. Limiting pages is much faster on big files.

Inputs: path (required), pages, format, password, +2 more. Returns: result

merge_pdfsA

Concatenate PDFs in the order given into one new file (bookmarks are kept).

output_path: must end in .pdf. Default: merged.pdf next to the first input. overwrite: replace the output if it exists. Default false: an existing file is an error. password: if any input is encrypted (one password for all; the output is not encrypted).

Inputs: paths (required), password, overwrite, output_path. Returns: result

pdf_infoA
Read-only

Summarise a PDF: page count, metadata, whether it is encrypted, whether it has a text layer (a scanned PDF does not), page sizes, and the outline/bookmarks with page numbers. Call this first to decide how to read the file.

path: PDF file inside an allowed folder (absolute, or relative to the first allowed folder). password: only for encrypted PDFs. Without it an encrypted file just reports that it is locked.

Inputs: path (required), password. Returns: result

read_pdfA
Read-only

Read the text of a PDF, page by page, each page headed '--- Page N of M ---'.

Output is capped at roughly max_tokens. When it is cut off, the last line says exactly which pages= value to pass to continue. Pages without a text layer (scanned images) are reported as such instead of coming back empty; there is no OCR.

pages: 1-based ranges like '1-3,5,7-' ('7-' = page 7 to the end). Empty = all pages. layout: true keeps the visual column layout (better for forms and statements; wider output). max_tokens: output budget, about 4 characters per token.

Inputs: path (required), pages, layout, password, +1 more. Returns: result

rotate_pagesA

Rotate pages and save a new PDF. degrees is a multiple of 90, clockwise (90, 180, 270, or -90 for counter-clockwise). pages empty = every page.

output_path: must end in .pdf. Default: _rotated.pdf next to the input. To rotate a file in place, pass its own path as output_path together with overwrite=true.

Inputs: path (required), degrees (required), pages, password, +2 more. Returns: result

search_pdfA
Read-only

Find text in a PDF. Returns each match as 'Page N: ...context...' plus the list of pages hit. Use it to locate the right pages, then read_pdf with pages=. A plain query matches across line breaks and ignores case; set regex=true for a regular expression.

pages: optional 1-based ranges like '1-3,5,7-' to limit the search. context_chars: characters of surrounding text on each side of a match. max_results: snippets to return (the total match count is always reported).

Inputs: path (required), query (required), pages, regex, +4 more. Returns: result

split_pdfA

Split a PDF into several files. Each comma-separated part of ranges becomes one file, e.g. '1-3,5,7-' makes three files (pages 1-3, page 5, page 7 to the end). Files are named _part_p.pdf. The original is untouched. All names are checked before anything is written, so a conflict never leaves a half-done split.

output_dir: default is the input's folder. Created if missing. overwrite: replace existing outputs. Default false.

Inputs: path (required), ranges (required), password, overwrite, +1 more. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4/5.0

    Scored across 9 tools

    Disambiguation5/5

    Each tool has a distinct action on PDFs: inspecting, reading text, searching, extracting tables/images/pages, merging, splitting, and rotating. The only close pair is split_pdf versus extract_pages, but the descriptions clearly separate multi-file splitting from reordering/repeating pages into one file.

    Naming Consistency4/5

    Most names follow a consistent verb_noun pattern (read_pdf, search_pdf, merge_pdfs, split_pdf, extract_tables, extract_pages, rotate_pages, extract_images). The outlier is pdf_info, which is noun_noun and breaks the otherwise predictable convention.

    Tool Count5/5

    Nine tools is well-scoped for a PDF toolkit, with each tool covering a meaningful operation. There is no obvious redundancy or excessive breadth.

    Completeness4/5

    The surface covers common PDF workflows: inspect, read, search, extract tables/images/pages, merge, split, and rotate. Some gaps remain, such as creating PDFs from images/text, encryption/decryption changes, compression, or form filling, but core lifecycle operations are well covered.

    Maintenance

    ActivityMaintained
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables safe interaction with PDFs, including listing files, extracting highlights with exact text, reading annotations and page text, and viewing metadata, all restricted to configured directories.
      2
      -
    • 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
      24 PyPI
      1
      Apache 2.0
    • A
      license
      A
      quality
      B
      maintenance
      Gives AI assistants a full PDF toolkit — encrypting, decrypting, merging, splitting, reordering, rotating, optimizing, repairing, and converting PDFs through natural-language requests, with sandboxed file access and safe handling of damaged or password-protected files.
      51
      MIT
    • A
      license
      A
      quality
      C
      maintenance
      Enables AI apps to edit PDFs on the local machine through natural language, merging, splitting, extracting, rotating, deleting, reordering and duplicating pages, plus inspecting page counts and encryption status. All work runs locally with no uploads, and every operation writes a new file beside the untouched original.
      8
      80 npm
      MIT