Skip to main content
Glama
mlorentedev

pdf-modifier-mcp

modify_pdf_content

Replace text in PDF documents with optional regex matching and hyperlink support, preserving original font styling.

Instructions

Find and replace text in a PDF while preserving font styles.

This tool performs text replacement by:

  1. Locating all occurrences of the search text

  2. Redacting the original text (white fill)

  3. Inserting the replacement text with matched styling

IMPORTANT BEHAVIORS:

  • Text is matched within individual text spans

  • Font style is approximated using Base 14 fonts (Helvetica, Times, Courier)

  • Replacement text should be similar length to avoid overlap

  • Multiple replacements can be specified in a single call

HYPERLINK SUPPORT:

  • Append "|URL" to create a clickable link: "Click Here|https://example.com"

  • Use "|void(0)" to neutralize existing links: "Product|void(0)"

REGEX SUPPORT:

  • Set use_regex=true to treat keys as regex patterns

  • Useful for matching dates, IDs, or variable content

  • Example: {"Order #\d+": "Order #REDACTED"}

Args: input_path: Absolute path to the source PDF file. output_path: Absolute path where the modified PDF will be saved. Parent directory must exist. replacements: Dictionary mapping old text to new text. Keys are search strings (or regex if use_regex=true). Values are replacement strings (optionally with |URL). use_regex: If true, treat replacement keys as regex patterns. Default is false for literal string matching. password: Optional password if the source PDF is encrypted.

Returns: JSON string with modification results including: - success: boolean indicating if operation completed - replacements_made: count of text spans modified - pages_modified: count of pages with changes - warnings: any non-fatal issues encountered

Examples: # Simple text replacement modify_pdf_content( "/path/input.pdf", "/path/output.pdf", {"$99.99": "$149.99", "Draft": "Final"} )

# Regex replacement for dates
modify_pdf_content(
    "/path/input.pdf",
    "/path/output.pdf",
    {"\d{2}/\d{2}/\d{4}": "01/01/2025"},
    use_regex=True
)

# Create hyperlink
modify_pdf_content(
    "/path/input.pdf",
    "/path/output.pdf",
    {"Learn More": "Visit Website|https://example.com"}
)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
input_pathYes
output_pathYes
replacementsYes
use_regexNo
passwordNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description fully discloses the replacement process (locate, redact, insert font-style approximation), hyperlink and regex behaviors, and output details (success, counts, warnings). This exceeds the burden.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-organized with sections, bullet points, and examples. While comprehensive, it is slightly lengthy but not wasteful; front-loading the purpose aids quick understanding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (5 params, nested objects, output schema), the description covers all aspects: purpose, behaviors, parameter details, return values, and edge cases (hyperlinks, regex). It is fully complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, but the description thoroughly explains each parameter: input_path and output_path as absolute paths, replacements as dictionary, use_regex as boolean, and password as optional. Examples further clarify syntax.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Find and replace text in a PDF while preserving font styles,' using a specific verb and resource. It distinguishes from sibling tools like 'batch_modify_pdf_content' by implying single-file operation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use the tool, including text matching within spans, length recommendations, and support for multiple replacements, hyperlinks, and regex. However, it does not explicitly contrast with batch or inspection alternatives.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mlorentedev/pdf-modifier-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server