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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pdf_modifier_mcp-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 0ca3160b048b6a59b615e68039a81322e75cc7ffe3ae5866179ef2400967d677
MD5 658165cde427d88bfcccb86609b0bc1f
BLAKE2b-256 0a95c65106bd56b3cd0fadeb53f41fc22d524180face426cce2a6c577aee532a

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pdf_modifier_mcp-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 87d8c7ebd60a947073875a45ae0b406a0ed4b78c2b9cfeed9d0719e96bfba185
MD5 48a402ed2aba5612e5db7a3497b75543
BLAKE2b-256 4d0e7125e80a58522dd54444a24382a0de45a5abb622dfb6db58e24864b441dd

See more details on using hashes here.

Provenance

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