pdform-mcp
v0.2.0Tools 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.
| Parameter | Type | Description |
|---|---|---|
path * | string | The PDF to read. |
list_acroform_fields_on_page
List all terminal fields on a specific page, with some basic information about each.
| Parameter | Type | Description |
|---|---|---|
page * | integer | The page number to select fields from. |
path * | string | The PDF to read. |
get_acroform_field_details
Get more detailed information about a specific acroform field.
| Parameter | Type | Description |
|---|---|---|
fully_qualified_name * | string | The name of the field to inspect. |
path * | string | The PDF to read. |
fill_acroform_fields
Fill a PDF form with the given data.
| Parameter | Type | Description |
|---|---|---|
data * | object | A 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 * | string | Path to the source PDF file. |
flatten | boolean | If the form should be flattened after filling. |
output_path | Path 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.
| Parameter | Type | Description |
|---|---|---|
input_path * | string | Path to the source PDF file. |
page * | integer | The page to add the annotation to. |
widget * | The widget to add. | |
output_path | Path for the output PDF. If omitted, overwrites the input file. |
delete_acroform_widget
Remove an acroform widget.
| Parameter | Type | Description |
|---|---|---|
input_path * | string | Path to the source PDF file. |
xref * | integer | The xref of the widget to delete. |
output_path | Path 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.
| Parameter | Type | Description |
|---|---|---|
path * | string | The 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.
| Parameter | Type | Description |
|---|---|---|
path * | string | The PDF to read. |
xref * | integer | The 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.
| Parameter | Type | Description |
|---|---|---|
key * | string | The 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 * | string | The 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.
| Parameter | Type | Description |
|---|---|---|
object * | string | The object dictionary value to write, in native PDF syntax. |
path * | string | The 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…
| Parameter | Type | Description |
|---|---|---|
object * | object | The object dictionary to write, in JSON syntax. |
path * | string | The 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.
| Parameter | Type | Description |
|---|---|---|
key * | string | The 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 * | string | The PDF to modify. |
value * | string | The 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`.
| Parameter | Type | Description |
|---|---|---|
key * | string | The 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 * | string | The 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
| Parameter | Type | Description |
|---|---|---|
path * | string | The PDF to modify. |
stream | The raw bytes to set as the stream, if the new object should be stream.. | |
value | string | The 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`.
| Parameter | Type | Description |
|---|---|---|
object * | object | The object dictionary to write, in JSON syntax. |
path * | string | The PDF to modify. |
stream | The 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.
| Parameter | Type | Description |
|---|---|---|
path * | string | The PDF to modify. |
stream * | string | The raw bytes to set as the stream. |
xref * | integer | The 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.
| Parameter | Type | Description |
|---|---|---|
input_path * | string | Path to the source PDF file. |
output_path | Path for the output PDF. If omitted, overwrites the input file. | |
page_range | Page 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.
| Parameter | Type | Description |
|---|---|---|
output_path * | string | Path for the merged output PDF. |
sources * | array | List of PDF sources with optional QPDF page ranges to merge. |
get_page_details
Get basic information about a specific page.
| Parameter | Type | Description |
|---|---|---|
page * | integer | The page number to inspect (1-indexed). |
path * | string | Path 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.
| Parameter | Type | Description |
|---|---|---|
page * | integer | The page number to render, indexed from 1. |
path * | string | The PDF to read. |
clip | An optional area to clip rendering to. |
get_document_details
Get general information about a PDF document, such as page count, version, and metadata.
| Parameter | Type | Description |
|---|---|---|
path * | string | Path to the PDF file to read. |
flatten
Flatten the PDF.
| Parameter | Type | Description |
|---|---|---|
input_path * | string | Path to the source PDF file. |
flatten_annots | boolean | If other (non-widget) annotations should be flattened. |
flatten_widgets | boolean | If form widgets should be flattened, resulting in a PDF without form elements. |
output_path | Path for the output PDF. If omitted, overwrites the input file. |
read_table_of_contents
Read the table of contents for a document
| Parameter | Type | Description |
|---|---|---|
path * | string | Path to the PDF file to read. |
draw_image
Add an overlay or underlay image.
| Parameter | Type | Description |
|---|---|---|
image_path * | string | Path to the image to add. |
input_path * | string | Path to the source PDF file. |
rect * | array | The location on the page to paste the image. |
output_path | Path for the output PDF. If omitted, overwrites the input file. | |
overlay | boolean | If true, this is an overlay. If false, an underlay. |
page_range | Page range, e.g. '1-5' or '1,3,5'. Omit for all pages. | |
rotate | integer | The 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.
| Parameter | Type | Description |
|---|---|---|
path * | string | The PDF to read. |
include_graphics | boolean | If true, include figure objects, lines, curves, and rectangles in the output. |
include_images | boolean | If true, include image objects in the output. |
include_text | boolean | If true, include text objects in the output |
include_text_style | boolean | If true, includes graphical information about text, such as font and size, on each text span. This is only relevant if `text_granularity` >= 2 |
page_range | The page range or pages to extract, e.g. '1-4' or '3,5,8'. Omit for all pages. | |
text_granularity | integer | The 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.
| Parameter | Type | Description |
|---|---|---|
page * | integer | The page to locate text on, indexed from 1. |
path * | string | The PDF to read. |
text * | string | The 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.
| Parameter | Type | Description |
|---|---|---|
page * | integer | The page to locate text on, indexed from 1. |
path * | string | The PDF to read. |
text * | string | The text to search for. |
read_text
Extract the plain text content of a PDF.
| Parameter | Type | Description |
|---|---|---|
path * | string | The PDF to read. |
page_range | The page range or pages to extract, e.g. '1-4' or '3,5,8'. Omit for all pages. |