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

Uploaded Python 3

File details

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

File metadata

  • Download URL: pdf_modifier_mcp-1.0.1.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.1.tar.gz
Algorithm Hash digest
SHA256 689fa3f260dc380d1cd37b7e2394568cee1d75a01f5afb39b537a434503f0c47
MD5 deffa3ebb6d6501d28fe15b5a5d6d19d
BLAKE2b-256 cf06cea8166e0e4f488f34f108a17d970ec20ad08bdf1bdbf84ae4cba96afa46

See more details on using hashes here.

Provenance

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

File metadata

File hashes

Hashes for pdf_modifier_mcp-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 509911314dafb921b563955db70b967c0af41aff0ea64ddb296581a2938d7630
MD5 d130fc33c1520a4c822889806a19ce49
BLAKE2b-256 f382478418ad150eb7165ae012dd659271b251a009bbe6e5d9bc650c74578bf4

See more details on using hashes here.

Provenance

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