Skip to main content

PDF Modifier

CI PyPI codecov Python 3.12+ Docs License: MIT

Give your AI coding assistant the ability to natively read, edit, and redact PDF documents.

Most AI assistants can generate Python scripts to edit PDFs, but running them requires manual execution, debugging missing fonts, and fixing broken layouts. PDF Modifier is an MCP server that gives your AI direct, native tools to safely manipulate PDFs in place.

The numbers:

Metric Without PDF Modifier With PDF Modifier
Workflow AI writes script -> You run it -> Debug errors AI edits PDF directly via MCP
Time to redact 10 invoices ~15 minutes (trial & error) Seconds (autonomous)
Layout preservation Often breaks styling or coordinates 100% (Base 14 font matching)
Interface Terminal only Native AI Tools + CLI fallback

Quick Install (30 seconds)

One command. No cloning, no venv. Use user scope (-s user) so the tools are available across all your projects.

Claude Code

claude mcp add -s user pdf-modifier -- uvx --upgrade pdf-modifier

Gemini CLI

gemini mcp add -s user pdf-modifier uvx -- --upgrade pdf-modifier

OpenAI Codex CLI

Add to ~/.codex/config.toml:

[mcp_servers.pdf-modifier]
command = "uvx"
args = ["--upgrade", "pdf-modifier"]

GitHub Copilot (VS Code)

Add to .vscode/mcp.json or your User Settings:

{
  "mcp": {
    "servers": {
      "pdf-modifier": {
        "command": "uvx",
        "args": ["--upgrade", "pdf-modifier"]
      }
    }
  }
}

Then ask your assistant:

"Read the structure of invoice.pdf and redact all credit card numbers"

That's it. You're running.

What You Get

5 MCP Tools — PDF manipulation, on demand

Tool What it does
read_pdf_structure Extract complete PDF structure with text positions, sizes, and fonts
inspect_pdf_fonts Search for terms and report their exact font properties
list_pdf_hyperlinks Inventory all existing hyperlinks and URIs in the document
modify_pdf_content Find and replace text (or regex) with strict style and layout preservation
batch_modify_pdf_content Apply the same replacements to multiple PDFs at once

CLI Interface (For Humans)

Still want to script it yourself? The package includes a powerful Typer CLI:

# Simple text replacement
pdf-mod modify input.pdf output.pdf -r "old text=new text"

# Inventory hyperlinks
pdf-mod links input.pdf

# Batch process multiple PDFs
pdf-mod batch *.pdf -o output/ -r "Draft=Final"

Regex replacement (dates, IDs, etc.)

pdf-mod modify input.pdf output.pdf -r "Order #\d+=Order #REDACTED" --regex

Create hyperlinks

pdf-mod modify input.pdf output.pdf -r "Click Here=Visit Site|https://example.com"


## Before / After

**Before PDF Modifier** — Manual scripting workflow:
```python
# The AI generates a script like this for you to run:
import fitz
doc = fitz.open("invoice.pdf")
for page in doc:
    # Hope the AI calculated the rects and fonts correctly...
    page.insert_text((100, 100), "REDACTED", fontname="helv")
doc.save("out.pdf")

With PDF Modifier — Autonomous AI action:

# The AI natively calls the tool without asking you to run scripts
modify_pdf_content(
    input_path="invoice.pdf",
    replacements={"pattern": r"\b\d{4}-\d{4}-\d{4}-\d{4}\b", "replacement": "XXXX-XXXX-XXXX-XXXX"},
    use_regex=True
)

Architecture

MCP Host (Claude, Gemini, Copilot)
  ↓ MCP protocol (stdio)
pdf-modifier (FastMCP Server)
  │
  ├── Core Layer (PDFModifier, PDFAnalyzer)
  │     ├── Regex matching & text extraction
  │     ├── Base 14 font fallback mapping
  │     └── Layout & coordinate preservation
  │
  └── PyMuPDF (fitz) Engine

Development

See CONTRIBUTING.md for setup, code standards, and PR workflow.

git clone https://github.com/mlorentedev/pdf-modifier.git
cd pdf-modifier
make setup     # create venv + install deps
make check     # lint + typecheck + test

License

MIT License - see LICENSE for details.

Documentation

Project-bound knowledge lives in docs/ (docs-as-code): ADRs, runbooks, troubleshooting, and lessons.

Metadata

Release files for pdf-modifier 1.9.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pdf-modifier 1.9.2
File Size Uploaded
pdf_modifier-1.9.2.tar.gz 260.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pdf-modifier 1.9.2
File Interpreter ABI Platform
pdf_modifier-1.9.2-py3-none-any.whl Python 3 none any Details

Total release size: 313.0 kB

Release files / pdf_modifier-1.9.2.tar.gz

Download URL pdf_modifier-1.9.2.tar.gz
Size 260.4 kB
Tags Source
SHA-256 checksum
How to use checksums
fa401e70f28b8c27e9791903b95a9456705d86be2b34a90c89f12ce1b3c31bfc
BLAKE2b-256 checksum
How to use checksums
5aa8739be0662719d849642189c3467505ab616243a2dff42a763e98add33c45
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release files / pdf_modifier-1.9.2-py3-none-any.whl

Download URL pdf_modifier-1.9.2-py3-none-any.whl
Size 52.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1e252a4ffac67a1bde1280a6cf1b139e83653b763a47f621491dc57db00c0056
BLAKE2b-256 checksum
How to use checksums
4d21ecc28bfee87da3d629bc69af8fedfaabb5a565cbdaf41a345312620ac49e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 13, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.9.2 This release

2 release files

1.9.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page