PDF modification tool with CLI and MCP interfaces for AI agents.
Project description
PDF Modifier MCP
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 MCP | With PDF Modifier MCP |
|---|---|---|
| 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-mcp
Gemini CLI
gemini mcp add -s user pdf-modifier uvx -- --upgrade pdf-modifier-mcp
OpenAI Codex CLI
Add to ~/.codex/config.toml:
[mcp_servers.pdf-modifier]
command = "uvx"
args = ["--upgrade", "pdf-modifier-mcp"]
GitHub Copilot (VS Code)
Add to .vscode/mcp.json or your User Settings:
{
"mcp": {
"servers": {
"pdf-modifier": {
"command": "uvx",
"args": ["--upgrade", "pdf-modifier-mcp"]
}
}
}
}
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
3 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 |
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
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 MCP** — 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 MCP — 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-mcp (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-mcp.git
cd pdf-modifier-mcp
make setup # create venv + install deps
make check # lint + typecheck + test
License
MIT License - see LICENSE for details.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pdf_modifier_mcp-1.3.0.tar.gz.
File metadata
- Download URL: pdf_modifier_mcp-1.3.0.tar.gz
- Upload date:
- Size: 233.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
898644cea46bf141187d96e77f4db1d25e10b01b73659b93a1f040ec12a295a9
|
|
| MD5 |
09b38f06412b864535dc90fcde6be199
|
|
| BLAKE2b-256 |
88ab3731566b4a590bda80af33a962534fe4d87c5eb52370ce391888ca95f909
|
Provenance
The following attestation bundles were made for pdf_modifier_mcp-1.3.0.tar.gz:
Publisher:
release.yml on mlorentedev/pdf-modifier-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdf_modifier_mcp-1.3.0.tar.gz -
Subject digest:
898644cea46bf141187d96e77f4db1d25e10b01b73659b93a1f040ec12a295a9 - Sigstore transparency entry: 1106386879
- Sigstore integration time:
-
Permalink:
mlorentedev/pdf-modifier-mcp@e9293b0f7348db0ce18908d8fc48b24b497d8ff9 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/mlorentedev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e9293b0f7348db0ce18908d8fc48b24b497d8ff9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file pdf_modifier_mcp-1.3.0-py3-none-any.whl.
File metadata
- Download URL: pdf_modifier_mcp-1.3.0-py3-none-any.whl
- Upload date:
- Size: 19.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9f28b22f6e43d2a405267910a5fdaff32d0062b877dd7593984dce44378ef91e
|
|
| MD5 |
5c38633464d5be299541babaaa8cd33c
|
|
| BLAKE2b-256 |
dd77a079b06d4d2cc3d4ce7170ccda56c772535a4f22fed3643fa33c0bcea192
|
Provenance
The following attestation bundles were made for pdf_modifier_mcp-1.3.0-py3-none-any.whl:
Publisher:
release.yml on mlorentedev/pdf-modifier-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pdf_modifier_mcp-1.3.0-py3-none-any.whl -
Subject digest:
9f28b22f6e43d2a405267910a5fdaff32d0062b877dd7593984dce44378ef91e - Sigstore transparency entry: 1106386934
- Sigstore integration time:
-
Permalink:
mlorentedev/pdf-modifier-mcp@e9293b0f7348db0ce18908d8fc48b24b497d8ff9 -
Branch / Tag:
refs/heads/master - Owner: https://github.com/mlorentedev
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@e9293b0f7348db0ce18908d8fc48b24b497d8ff9 -
Trigger Event:
push
-
Statement type: