PDF modification tool with CLI and MCP interfaces for AI agents.
Project description
PDF Modifier MCP
A Python tool for modifying text within PDF files while preserving the original layout and font styles. Features dual interfaces: a human-friendly CLI and an MCP server for AI agent integration.
Features
- Text Replacement: Find and replace text while preserving font styles
- Regex Support: Pattern-based replacements for dates, IDs, prices
- Hyperlink Management: Create or neutralize clickable links
- Style Preservation: Matches bold/regular fonts using Base 14 fonts
- Dual Interface: CLI for humans, MCP server for AI agents
Installation
From PyPI
pip install pdf-modifier-mcp
From Source
git clone https://github.com/mlorentedev/pdf-modifier-mcp.git
cd pdf-modifier-mcp
make setup
Quick Start
CLI Usage
# Simple text replacement
pdf-mod modify input.pdf output.pdf -r "old text=new text"
# Multiple replacements
pdf-mod modify input.pdf output.pdf -r "$99.99=$149.99" -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"
# Analyze PDF structure
pdf-mod analyze input.pdf --json
# Inspect fonts for specific terms
pdf-mod inspect input.pdf "Invoice" "Total" "$"
MCP Server (for AI Agents)
pdf-modifier-mcp
Claude Desktop Integration
Add to your Claude Desktop configuration (~/.config/claude/claude_desktop_config.json):
{
"mcpServers": {
"pdf-modifier": {
"command": "pdf-modifier-mcp"
}
}
}
Or run directly from PyPI without installing:
{
"mcpServers": {
"pdf-modifier": {
"command": "uvx",
"args": ["pdf-modifier-mcp"]
}
}
}
Available MCP Tools
| Tool | Description |
|---|---|
read_pdf_structure |
Extract complete PDF structure with text positions and fonts |
inspect_pdf_fonts |
Search for terms and report their font properties |
modify_pdf_content |
Find and replace text with style preservation |
Architecture
┌─────────────────────────────────────────────────────┐
│ Entry Points │
├──────────────────────┬──────────────────────────────┤
│ CLI (Typer+Rich) │ MCP (FastMCP) │
│ pdf-mod command │ pdf-modifier-mcp server │
└──────────────────────┴──────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ Core Layer │
├─────────────────────────────────────────────────────┤
│ modifier.py │ analyzer.py │ models.py │
│ PDFModifier │ PDFAnalyzer │ Pydantic schemas │
└─────────────────────────────────────────────────────┘
│
▼
┌─────────────────────────────────────────────────────┐
│ PyMuPDF (fitz) │
└─────────────────────────────────────────────────────┘
Development
# Setup
make setup
# Run quality checks
make check
# Format code
make format
# Run tests
make test
Contributing
See CONTRIBUTING.md for details.
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.0.2.tar.gz.
File metadata
- Download URL: pdf_modifier_mcp-1.0.2.tar.gz
- Upload date:
- Size: 13.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba78c63ee998889f828f887734654a8de26c5725da2eed3793a93d3633056cff
|
|
| MD5 |
5b4ea0b5e930e015ca701752179a1ee3
|
|
| BLAKE2b-256 |
2a34b44ca4f5e5da86552bca2cb74bc732cccbe4ffdf8ddb87413552114a8f04
|
Provenance
The following attestation bundles were made for pdf_modifier_mcp-1.0.2.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.0.2.tar.gz -
Subject digest:
ba78c63ee998889f828f887734654a8de26c5725da2eed3793a93d3633056cff - Sigstore transparency entry: 828168426
- Sigstore integration time:
-
Permalink:
mlorentedev/pdf-modifier-mcp@81e14ebb1955c3413a2d105a0e17d5919b6976ea -
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@81e14ebb1955c3413a2d105a0e17d5919b6976ea -
Trigger Event:
push
-
Statement type:
File details
Details for the file pdf_modifier_mcp-1.0.2-py3-none-any.whl.
File metadata
- Download URL: pdf_modifier_mcp-1.0.2-py3-none-any.whl
- Upload date:
- Size: 16.0 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 |
2e21846aabac48caa2dd46dda17f36853243f7d33cc1d1da8c341a535bc0433d
|
|
| MD5 |
095bd1168cfbe4ddd9ab6080d1003dad
|
|
| BLAKE2b-256 |
b1f61ea74fec58957e6827d097d17e9ee1d7095d58c1d13856895d9d9e6a4a68
|
Provenance
The following attestation bundles were made for pdf_modifier_mcp-1.0.2-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.0.2-py3-none-any.whl -
Subject digest:
2e21846aabac48caa2dd46dda17f36853243f7d33cc1d1da8c341a535bc0433d - Sigstore transparency entry: 828168429
- Sigstore integration time:
-
Permalink:
mlorentedev/pdf-modifier-mcp@81e14ebb1955c3413a2d105a0e17d5919b6976ea -
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@81e14ebb1955c3413a2d105a0e17d5919b6976ea -
Trigger Event:
push
-
Statement type: