pdform-mcp

v0.2.0
pdform-mcp Checked 4 days ago Published 1 month ago

Tools for LLMs to inspect and understand PDFs on a deep structural level

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

list_acroform_fields

List all terminal fields in the AcroForm, with some basic information about each.

ParameterTypeDescription
path *stringThe PDF to read.

list_acroform_fields_on_page

List all terminal fields on a specific page, with some basic information about each.

ParameterTypeDescription
page *integerThe page number to select fields from.
path *stringThe PDF to read.

get_acroform_field_details

Get more detailed information about a specific acroform field.

ParameterTypeDescription
fully_qualified_name *stringThe name of the field to inspect.
path *stringThe PDF to read.

fill_acroform_fields

Fill a PDF form with the given data.

ParameterTypeDescription
data *objectA mapping of fully-qualified form name to value. For text widgets and choice fields, this should be a string representing the value. For checkboxes, it may be a boolean, or it may be a string represen…
input_path *stringPath to the source PDF file.
flattenbooleanIf the form should be flattened after filling.
output_pathPath for the output PDF. If omitted, overwrites the input file.

add_acroform_widget

Add an acroform widget. Parent/child relationships will automatically be computed from the widget name.

ParameterTypeDescription
input_path *stringPath to the source PDF file.
page *integerThe page to add the annotation to.
widget *The widget to add.
output_pathPath for the output PDF. If omitted, overwrites the input file.

delete_acroform_widget

Remove an acroform widget.

ParameterTypeDescription
input_path *stringPath to the source PDF file.
xref *integerThe xref of the widget to delete.
output_pathPath for the output PDF. If omitted, overwrites the input file.

low_level_read_object

Read one specific indirect object from the PDF by xref. The object will be returned in native PDF syntax.

ParameterTypeDescription
path *stringThe PDF to read.
xref *The xref of the object to read. Set to null to use the PDF root, or -1 for the trailer.

low_level_read_stream

Read the decompressed stream of one specific indirect object from the PDF by xref.

ParameterTypeDescription
path *stringThe PDF to read.
xref *integerThe xref of the object to read from.

low_level_read_object_value

Read a value one specific indirect object from the PDF by xref and key. The value will be returned as `[type, value]` where `type` is a string indicating the detected PDF type, and `value` is a string containing the value in native PDF syntax.

ParameterTypeDescription
key *stringThe key for the value to get (without leading "/"). You may use a path-like notation ("/" separated) to access a value of a nested dictionary.
path *stringThe PDF to read.
xref *The xref of the object to read from. Set to null to use the PDF root, or -1 for the trailer.

low_level_write_object

Overwrite one specific indirect object in the PDF by xref.

ParameterTypeDescription
object *stringThe object dictionary value to write, in native PDF syntax.
path *stringThe PDF to modify.
xref *The xref of the object to write to. Set to null to use the PDF root, or -1 for the trailer.

low_level_write_object_as_json

An alternative to `low_level_write_object` that converts to PDF syntax on your behalf, rather than requiring you to do so. * JSON objects translate to PDF dictionaries * JSON arrays translate to PDF arrays * Numbers, booleans, and `null` also directly translate to the PDF equivalent * Unicode string are represented as JSON strings beginning with "u:" followed by the remaining string content, which will be encoded in PDF format for you. * Binary strings are represented as JSON strings beginning with "b:" and followed by a string of hexadecimal digits. * PDF names are represented as JSON strin…

ParameterTypeDescription
object *objectThe object dictionary to write, in JSON syntax.
path *stringThe PDF to modify.
xref *The xref of the object to write to. Set to null to use the PDF root, or -1 for the trailer.

low_level_set_object_value

Set a value of one specific indirect object in the PDF by xref and key.

ParameterTypeDescription
key *stringThe key for the value to set (without leading "/"). You may use a path-like notation ("/" separated) to modify a value of a nested dictionary. Intermediate paths will be created.
path *stringThe PDF to modify.
value *stringThe value to set, in native PDF syntax.
xref *The xref of the object to write to. Set to null to use the PDF root, or -1 for the trailer.

low_level_set_object_value_as_json

Variant of `low_level_set_object_value` that allows specifying the value in the same convenient JSON format as `low_level_write_object_as_json`.

ParameterTypeDescription
key *stringThe key for the value to set (without leading "/"). You may use a path-like notation ("/" separated) to modify a value of a nested dictionary.
path *stringThe PDF to modify.
value *The value to set.
xref *The xref of the object to write to. Set to null to use the PDF root, or -1 for the trailer.

low_level_create_indirect_object

Create a new indirect object in the PDF, returning the new object's xref

ParameterTypeDescription
path *stringThe PDF to modify.
streamThe raw bytes to set as the stream, if the new object should be stream..
valuestringThe value to set, in PDF syntax.

low_level_create_indirect_object_as_json

Variant of `low_level_create_indirect_object` that allows specifying the object in the same convenient JSON format as `low_level_write_object_as_json`.

ParameterTypeDescription
object *objectThe object dictionary to write, in JSON syntax.
path *stringThe PDF to modify.
streamThe raw bytes to set as the stream, if the new object should be stream..

low_level_write_stream

Write an object's stream by xref. This will overwrite any existing stream, or create a new stream if one does not exist on the specified object. The object must already exist; use `low_level_create_indirect_object` instead to create a new object.

ParameterTypeDescription
path *stringThe PDF to modify.
stream *stringThe raw bytes to set as the stream.
xref *integerThe xref of the object to write to.

extract_pages_from_pdf

Extract specific pages from a PDF file and create a new PDF with only those pages.

ParameterTypeDescription
input_path *stringPath to the source PDF file.
output_pathPath for the output PDF. If omitted, overwrites the input file.
page_rangePage range: '1-5' (range), '1,3,5' (specific), 'z' (last), 'r1' (last), 'r2' (second-to-last), '7-3' (reversed), '1-20:even' (even positions), '1-10,x3-4' (exclude 3-4). Omit for all pages.

merge_pdfs

Merge pages from multiple PDF files into a single PDF. Pages are combined in the order specified. Each source can specify a QPDF-style page range. See extract_pages_from_pdf documentation for complete page range syntax.

ParameterTypeDescription
output_path *stringPath for the merged output PDF.
sources *arrayList of PDF sources with optional QPDF page ranges to merge.

get_page_details

Get basic information about a specific page.

ParameterTypeDescription
page *integerThe page number to inspect (1-indexed).
path *stringPath to the PDF file to read.

render

Read one specific indirect object from the PDF by xref. The object will be returned in native PDF syntax.

ParameterTypeDescription
page *integerThe page number to render, indexed from 1.
path *stringThe PDF to read.
clipAn optional area to clip rendering to.

get_document_details

Get general information about a PDF document, such as page count, version, and metadata.

ParameterTypeDescription
path *stringPath to the PDF file to read.

flatten

Flatten the PDF.

ParameterTypeDescription
input_path *stringPath to the source PDF file.
flatten_annotsbooleanIf other (non-widget) annotations should be flattened.
flatten_widgetsbooleanIf form widgets should be flattened, resulting in a PDF without form elements.
output_pathPath for the output PDF. If omitted, overwrites the input file.

read_table_of_contents

Read the table of contents for a document

ParameterTypeDescription
path *stringPath to the PDF file to read.

draw_image

Add an overlay or underlay image.

ParameterTypeDescription
image_path *stringPath to the image to add.
input_path *stringPath to the source PDF file.
rect *arrayThe location on the page to paste the image.
output_pathPath for the output PDF. If omitted, overwrites the input file.
overlaybooleanIf true, this is an overlay. If false, an underlay.
page_rangePage range, e.g. '1-5' or '1,3,5'. Omit for all pages.
rotateintegerThe rotation to apply, if desired.

read_layout_as_xml

Show the layout of the PDF content (text, images, lines, figures) in a bespoke XML format. This is useful for understanding the positions of text or other objects on the page, and understanding the document hierarchy.

ParameterTypeDescription
path *stringThe PDF to read.
include_graphicsbooleanIf true, include figure objects, lines, curves, and rectangles in the output.
include_imagesbooleanIf true, include image objects in the output.
include_textbooleanIf true, include text objects in the output
include_text_stylebooleanIf true, includes graphical information about text, such as font and size, on each text span. This is only relevant if `text_granularity` >= 2
page_rangeThe page range or pages to extract, e.g. '1-4' or '3,5,8'. Omit for all pages.
text_granularityintegerThe level of granularity at which to show text. Use 0 for large text blocks, 1 for individual lines, 2 for spans (runs of characters sharing a font and style within a line), and 3 for individual chara…

locate_text_on_page

Search a page for a specific string and return the rectangles of where it was found on the page.

ParameterTypeDescription
page *integerThe page to locate text on, indexed from 1.
path *stringThe PDF to read.
text *stringThe text to search for.

locate_text_on_page_as_quads

Like `locate_text_on_page`, but returns the full (x,y) for each of the four corners of the rectangle (i.e. a quad) rather than a basic rect. This allows better capture of rotated text.

ParameterTypeDescription
page *integerThe page to locate text on, indexed from 1.
path *stringThe PDF to read.
text *stringThe text to search for.

read_text

Extract the plain text content of a PDF.

ParameterTypeDescription
path *stringThe PDF to read.
page_rangeThe page range or pages to extract, e.g. '1-4' or '3,5,8'. Omit for all pages.