Skip to main content

PDF File Context Protocol — semantic PDF operations for LLMs

Project description

fcp-pdf

MCP server for semantic PDF operations.

What It Does

fcp-pdf lets LLMs read, edit, and generate PDF files by describing document intent -- pages, text, annotations, bookmarks, watermarks, redactions -- instead of driving a low-level PDF library call by call. It exposes 13 verbs (page, text, insert-text, annotate, bookmark, merge, split, meta, watermark, image, redact, link, plus compose) and renders them into standard .pdf files. Built on the FCP framework, powered by PyMuPDF (fitz) for serialization.

The compose verb is a small document-generation sub-DSL: it accumulates structured content (headings, paragraphs, tables, lists, callouts, cover pages, columns) into a buffer, then compose render paginates it with text reflow, page breaks, headers/footers, and auto-generated bookmarks, using one of five built-in themes (corporate, modern, minimal, executive, ocean).

Quick Example

pdf_session('new "Invoice"')

pdf([
    'page add',
    'insert-text "INVOICE" x:72 y:72 size:24 font:helv-bold',
    'insert-text "Date: 2026-01-15" x:72 y:110 size:12',
    'annotate rect on:1 x:60 y:60 w:475 h:70 color:#1a1a2e',
    'bookmark add "Invoice" page:1',
])

pdf_session('save as:./invoice.pdf')

Or generate a themed multi-page report with compose:

pdf_session('new "Q4 Report"')

pdf([
    'compose config paper:letter theme:modern footer:"Page {page} of {pages}"',
    'compose heading "Q4 Revenue Report" level:1',
    'compose paragraph "Revenue grew 38% YoY driven by **enterprise expansion**."',
    'compose table "Metric" "Q3" "Q4" "Delta"',
    'compose row "Revenue" "$1.3M" "$1.8M" "+38%"',
    'compose list "Enterprise ARR crossed $1M" "Launched APAC region"',
    'compose render',
])

pdf_session('save as:./q4_report.pdf')

Available MCP Tools

Tool Purpose
pdf(ops) Batch mutations -- pages, text, annotations, bookmarks, merges, watermarks, images, redaction, links, compose
pdf_query(q) Inspect the document -- structure (plan/status), page detail (describe), full-text search (find), toc, fonts, annots
pdf_session(action) Lifecycle -- new, open, save, checkpoint, undo, redo
pdf_help() Full reference card

Installation

Requires Python >= 3.11.

pip install fcp-pdf

MCP Client Configuration

{
  "mcpServers": {
    "pdf": {
      "command": "uv",
      "args": ["run", "python", "-m", "fcp_pdf"]
    }
  }
}

Architecture

3-layer architecture:

MCP Server (Intent Layer)
  Parses op strings, dispatches to verb handlers
        |
Semantic Model
  PdfModel wraps a fitz.Document, byte-snapshot undo/redo
        |
Serialization (PyMuPDF / fitz)
  Semantic model -> .pdf binary output

Key features:

  • Pages -- add, remove, move, rotate, copy, activate
  • Text -- extraction (plain/blocks/dict) and free-form insertion
  • Annotations -- highlight, underline, strikeout, sticky notes, shapes
  • Bookmarks -- table of contents management
  • Merge / split -- combine or extract page ranges across documents
  • Metadata -- title, author, subject, keywords, creator, producer
  • Watermarks -- rotated, opacity-controlled text overlays
  • Images -- insert, extract, list
  • Redaction -- permanently remove text from pages
  • Links -- hyperlinks and internal page links
  • Compose -- themed document layout engine with automatic pagination and bookmarks
  • Undo/redo -- full document snapshots with event sourcing

Development

uv sync --dev        # install deps
uv run pytest        # run tests
uv run fcp-pdf        # start MCP server

License

MIT

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

fcp_pdf-0.2.0.tar.gz (39.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fcp_pdf-0.2.0-py3-none-any.whl (41.8 kB view details)

Uploaded Python 3

File details

Details for the file fcp_pdf-0.2.0.tar.gz.

File metadata

  • Download URL: fcp_pdf-0.2.0.tar.gz
  • Upload date:
  • Size: 39.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fcp_pdf-0.2.0.tar.gz
Algorithm Hash digest
SHA256 26c4139f8ec729f10408bd599847ef6b56191bb25959ea77cfd1dfd01ea2731f
MD5 8389528f50198fc27c0d1f3dbebaf62f
BLAKE2b-256 bc777f5dfe5b7621dc974152bd944f0f8ae215cdad2fb4c1a7572ecc4f8b6881

See more details on using hashes here.

Provenance

The following attestation bundles were made for fcp_pdf-0.2.0.tar.gz:

Publisher: release.yml on os-tack/fcp-pdf

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fcp_pdf-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: fcp_pdf-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 41.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for fcp_pdf-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4d7338ee8cc7737d0b3ef0db4ff4ff0726d5e7d27a9ecace4d5663adaea9b903
MD5 d89eeeb46d0f9396d0f6727603ac909e
BLAKE2b-256 267bb82331df60ce5a1d24053fbda525b7b7890f8ee334acdd38d8e5df123cf2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fcp_pdf-0.2.0-py3-none-any.whl:

Publisher: release.yml on os-tack/fcp-pdf

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