Skip to main content
Glama
pdf-modifier-mcp

pdf-modifier-mcp

by mlorentedev

PDF Modifier

CLI + MCP server + Web UI for PDF text replacement with font style preservation.

CI PyPI Python 3.12+ Docs License: MIT

Quick start

pip install pdf-modifier

# CLI
pdf-mod modify input.pdf output.pdf -r "Draft=Final"

# MCP server (for Claude/Cursor/Codex)
claude mcp add -s user pdf-modifier -- uvx pdf-modifier

Related MCP server: 1pdf

Interfaces

Interface

Description

Run

CLI

pdf-mod — batch jobs, scripting, CI pipelines

make run cli ARGS="..."

MCP Server

pdf-modifier — AI agents edit PDFs

make run mcp

Web UI

FastAPI + SvelteKit — drag & drop, preview, replace

make up (Docker) or make run api + make run frontend

Features

  • Text replacement — find and replace with font style preservation (family, weight, size, color)

  • Regex support — pattern-based bulk replacements (--regex)

  • Hyperlinks — create clickable links or neutralize existing ones

  • Batch processing — apply same replacements to multiple files

  • Web UI — drag & drop PDF upload, structure browser, page preview with zoom, text highlighting

  • MCP tools — read_pdf_structure, inspect_pdf_fonts, list_pdf_hyperlinks, modify_pdf_content

Development

# Setup
make setup

# Run tests
make test

# Full check (lint + type + test)
make check

# Start dev stack (Docker)
make up
# API: http://localhost:8000 | Web: http://localhost:8080

# Start servers locally
make run api          # FastAPI dev server
make run frontend     # SvelteKit dev server

Documentation

License

MIT

Available Tools

6 tools
batch_modify_pdf_contentA

Apply the same text replacements to multiple PDF files at once.

Each file is processed independently -- a failure in one file does not stop the rest of the batch. Output files are written to output_dir using the same filename as the input.

Inputs: input_paths (required), output_dir (required), replacements (required), use_regex, +2 more. Returns: result

extract_embedded_fontsA

Extract metadata and buffers of all embedded fonts in a PDF.

Use this tool to inspect which fonts are actually embedded in a document. Custom fonts (TrueType, OpenType) appear as Type0 with their binary buffer. Base 14 system fonts (Helvetica, Times, Courier) are NOT embedded and will not appear in the results.

Inputs: input_path (required), password, max_file_size. Returns: result

inspect_pdf_fontsA

Search for specific text terms and report their font properties.

Use this tool to understand the exact font styling of text you want to replace. This ensures replacements will match the surrounding document style as closely as possible.

The tool searches through all pages and returns matches with:

  • Page number where the term was found

  • The search term that matched

  • Surrounding context (first 100 characters)

  • Font name (e.g., "Helvetica-Bold", "Times-Roman")

  • Font size in points

  • Origin coordinates for precise positioning

Inputs: input_path (required), terms (required), password, max_file_size. Returns: result

modify_pdf_contentA

Find and replace text in a PDF while preserving font styles.

This tool performs text replacement by:

  1. Locating all occurrences of the search text

  2. Redacting the original text (white fill)

  3. Inserting the replacement text with matched styling

IMPORTANT BEHAVIORS:

  • Text is matched within individual text spans

  • Font style is approximated using Base 14 fonts (Helvetica, Times, Courier)

  • Replacement text should be similar length to avoid overlap

  • Multiple replacements can be specified in a single call

HYPERLINK SUPPORT:

  • Append "|URL" to create a clickable link: "Click Here|https://example.com"

  • Use "|void(0)" to neutralize existing links: "Product|void(0)"

REGEX SUPPORT:

  • Set use_regex=true to treat keys as regex patterns

  • Useful for matching dates, IDs, or variable content

  • Example: {"Order #\d+": "Order #REDACTED"}

PAGE RANGE:

  • Use pages="1-3" to process only pages 1 through 3 (1-indexed, inclusive)

  • Use pages="5" to process only page 5

  • Omit to process all pages

Inputs: input_path (required), output_path (required), replacements (required), use_regex, +3 more. Returns: result

read_pdf_structureA

Extract the complete structural content of a PDF document.

Returns detailed information about each page including:

  • Page dimensions (width, height)

  • All text elements with their:

    • Exact text content

    • Bounding box coordinates (x0, y0, x1, y1)

    • Origin point for text insertion

    • Font name and size

    • Color value

Use this tool FIRST to understand the document layout before making any modifications. The output helps identify exact text to target for replacements.

Inputs: input_path (required), password, max_file_size. Returns: result

Tool Schema Changelog

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

Loading tool schema changelog…

    TDQS

    A4.4/5.0

    Scored across 6 tools

    Disambiguation4/5

    Most tools have clearly distinct purposes: reading structure, modifying content, listing hyperlinks, and batch processing are unambiguous. However, read_pdf_structure and inspect_pdf_fonts both report font name, size, and coordinates, so an agent could be uncertain which to use when investigating text styling.

    Naming Consistency5/5

    All tools follow a consistent verb_noun snake_case pattern (extract_, read_, inspect_, modify_, list_, batch_modify_). The batch_ prefix clearly signals the multi-file variant of modify_pdf_content, making the naming predictable and scannable.

    Tool Count5/5

    Six tools is a well-scoped set for a PDF modification server. Each tool covers a distinct aspect of the domain—inspection, single-file modification, batch modification, font analysis, and hyperlink inventory—without bloat or redundancy.

    Completeness4/5

    The core workflow is covered: read structure, inspect fonts, modify text, list hyperlinks, and batch process. Minor gaps exist such as no page-level operations (reorder, delete, rotate) or image extraction, but these fall outside the server's evident text-and-link modification focus.

    Maintenance

    ActivityActive
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • F
      license
      Not graded
      quality
      B
      maintenance
      Enables AI agents to perform 13 PDF operations (merge, split, compress, watermark, encrypt, and more) on local files via MCP.
      3
      -
    • A
      license
      C
      quality
      D
      maintenance
      Enables AI assistants to perform PDF operations like merge, split, compress, convert, encrypt, OCR, and summarize using natural language.
      98
      15 npm
      MIT
    • F
      license
      Not graded
      quality
      D
      maintenance
      Enables AI agents to extract structured data from PDFs with confidence scores and provenance, and to search, review, and correct documents via MCP tools, resources, and prompts.
      -
    • A
      license
      Not graded
      quality
      C
      maintenance
      It enables AI agents and MCP clients to read, fill, create, export, and reconstruct fillable PDF forms, plus extract, search, and edit text and layout blocks, entirely against local files over stdio.
      Apache 2.0