Skip to main content

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.

CI PyPI version Python 3.10+ License: MIT

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pdf_modifier_mcp-1.0.2.tar.gz (13.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pdf_modifier_mcp-1.0.2-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

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

Hashes for pdf_modifier_mcp-1.0.2.tar.gz
Algorithm Hash digest
SHA256 ba78c63ee998889f828f887734654a8de26c5725da2eed3793a93d3633056cff
MD5 5b4ea0b5e930e015ca701752179a1ee3
BLAKE2b-256 2a34b44ca4f5e5da86552bca2cb74bc732cccbe4ffdf8ddb87413552114a8f04

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdf_modifier_mcp-1.0.2.tar.gz:

Publisher: release.yml on mlorentedev/pdf-modifier-mcp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pdf_modifier_mcp-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_modifier_mcp-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2e21846aabac48caa2dd46dda17f36853243f7d33cc1d1da8c341a535bc0433d
MD5 095bd1168cfbe4ddd9ab6080d1003dad
BLAKE2b-256 b1f61ea74fec58957e6827d097d17e9ee1d7095d58c1d13856895d9d9e6a4a68

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page