# PDF Modifier MCP server

> Allows AI agents to modify PDF text using regex while preserving font styles, managing hyperlinks, and analyzing document structure.

- Repository: https://github.com/mlorentedev/pdf-modifier
- Page: https://hostedmcp.org/servers/mlorentedev/pdf-modifier
- Transport: stdio
- Stars: 3
- License: MIT
- Latest version: 1.10.1

## Install

### Claude Code

```sh
claude mcp add pdf-modifier -- uvx pdf-modifier
```

### Cursor (`~/.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "pdf-modifier": {
      "command": "uvx",
      "args": [
        "pdf-modifier"
      ]
    }
  }
}
```

### VS Code (`.vscode/mcp.json`)

```json
{
  "servers": {
    "pdf-modifier": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "pdf-modifier"
      ]
    }
  }
}
```

### VS Code CLI

```sh
code --add-mcp '{"name":"pdf-modifier","type":"stdio","command":"uvx","args":["pdf-modifier"]}'
```

### Claude Desktop (`claude_desktop_config.json`)

```json
{
  "mcpServers": {
    "pdf-modifier": {
      "command": "uvx",
      "args": [
        "pdf-modifier"
      ]
    }
  }
}
```

### Codex

```sh
codex mcp add pdf-modifier -- uvx pdf-modifier
```

### Codex config.toml (`~/.codex/config.toml`)

```toml
[mcp_servers.pdf-modifier]
command = "uvx"
args = ["pdf-modifier"]
```

### Gemini CLI

```sh
gemini mcp add -s user pdf-modifier uvx -- pdf-modifier
```

### Gemini settings.json (`~/.gemini/settings.json`)

```json
{
  "mcpServers": {
    "pdf-modifier": {
      "command": "uvx",
      "args": [
        "pdf-modifier"
      ]
    }
  }
}
```

## Tools (6)

- `read_pdf_structure`: Extract the complete structural content of a PDF document. Returns detailed information about each page including: - Page dimensions (width, height) - All text elements with their: - Exact text content - Bounding box coordinates (x0, y0, x1, y1) - Origin point for text insertion - Font name and size - Color value Use this tool FIRST to understand the document layout before making any modifications. The output helps identify exact text to target for replacements.
- `inspect_pdf_fonts`: Search for specific text terms and report their font properties. Use this tool to understand the exact font styling of text you want to replace. This ensures replacements will match the surrounding document style as closely as possible. The tool searches through all pages and returns matches with: - Page number where the term was found - The search term that matched - Surrounding context (first 100 characters) - Font name (e.g., "Helvetica-Bold", "Times-Roman") - Font size in points - Origin coordinates for precise positioning
- `modify_pdf_content`: 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"} PAGE RANGE: - Use pages="1-3" to process only pages 1 through 3 (1-indexed, inclusive) - Use pages="5" to process only page 5 - Omit to process all pages
- `list_pdf_hyperlinks`: Extract all existing hyperlinks and clickable URIs from a PDF. Use this tool to inventory the links in a document before or after making modifications. It reports the target URI, its location (bbox), and the text covered by the link if detectable.
- `extract_embedded_fonts`: Extract metadata and buffers of all embedded fonts in a PDF. Use this tool to inspect which fonts are actually embedded in a document. Custom fonts (TrueType, OpenType) appear as Type0 with their binary buffer. Base 14 system fonts (Helvetica, Times, Courier) are NOT embedded and will not appear in the results.
- `batch_modify_pdf_content`: Apply the same text replacements to multiple PDF files at once. Each file is processed independently -- a failure in one file does not stop the rest of the batch. Output files are written to ``output_dir`` using the same filename as the input.

## FAQ

### What tools are available via the MCP server?

The MCP server provides tools to read PDF structure, inspect fonts, list hyperlinks, and modify PDF content.

### Can I replace text using patterns?

Yes, the server supports regex for pattern-based bulk replacements.

### Does it change the font when I replace text?

No, it performs text replacement while preserving the font family, weight, size, and color.
