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.0.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.0-py3-none-any.whl (16.0 kB view details)

Uploaded Python 3

File details

Details for the file pdf_modifier_mcp-1.0.0.tar.gz.

File metadata

  • Download URL: pdf_modifier_mcp-1.0.0.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.0.tar.gz
Algorithm Hash digest
SHA256 83f9810013620495ec9da26295b1d028952620749a20c8d72ad4ce564d55879b
MD5 75708d51d18c679e4aa3c1b59bca00f2
BLAKE2b-256 d439647149b67a3fc8ce5c80a810f93d0f6554e9660d50259b4b3be9e3d030d7

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdf_modifier_mcp-1.0.0.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.0-py3-none-any.whl.

File metadata

File hashes

Hashes for pdf_modifier_mcp-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d6ba848edff8e36d7a665fa1e04f1a3b43efa6e72ff338c057f4defcf19b7b22
MD5 c19c0bc4eefd7385df539c265ba5d8f0
BLAKE2b-256 2c8f8701d8da25f6b426a14f27c2f9e82de02a2fbc2aaedadc7b21d2af379f5b

See more details on using hashes here.

Provenance

The following attestation bundles were made for pdf_modifier_mcp-1.0.0-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