Skip to main content
Glama

Detect fillable fields in a flat PDF

pdf_detect_fields
Read-onlyIdempotent

Detects drawn blanks like lines, boxes, underscores, and checkboxes in flat PDFs, returning named form fields with confidence scores for review and later filling.

Instructions

Detect fillable form fields in a flat PDF (one with no form fields; pdf_inspect lists none): finds blanks drawn on the page as lines, boxes, underscores and checkboxes and returns a text or checkbox field for each, named from the nearest printed label, with a confidence from 0 to 1. Each entry has type, name, page, x, y, width, height in PDF points from the bottom-left of the page as the viewer sees it, the frame pdf_add_fields and pdf_edit use. The entries can be reviewed (wrong ones dropped, others renamed or adjusted) and passed to pdf_add_fields as fields (label and confidence are ignored there), and pdf_fill then fills the result; pdf_add_fields with detect true does detection and adding in one call. Only drawn blanks are found: not a blank area with no line or box, a scanned image, or shaded cells with no outline. Results are suggestions: confidence scores are estimates, low-confidence entries can be wrong, and some detections are table cells or rules that are not blanks. Pages are read with min_confidence (default 0.4; 0.6 gives fewer but surer fields) and max_pages (default 40, at most 100). Zero fields is a normal answer with a note. At most 200 fields per call; the pages argument describes continuing a large form. Read-only: the source is never modified.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "pdf_path": "<pdf_path>"
    },
    "name": "pdf_detect_fields"
  }
}

Input Schema

NameRequiredDescriptionDefault
pagesNoPages to analyse, 1-based: "1-3,5,8-". Default: all pages (up to max_pages). Large forms: a call stops at its time and work limit, so while truncated is true the returned fields can be added with pdf_add_fields, after which pdf_detect_fields run on the resulting PDF with pages set to next_pages (exactly the pages not done, including a page cut at 200 fields; a sparse selection stays sparse) continues until truncated is false. Sending the original PDF again repeats the same names and is not supported. pages_skipped lists pages not analysed: reason too_complex (more drawn shapes or text than the per-page limits; sending them again gives the same answer) or deadline (the call stopped first; they are in next_pages).
passwordNoPassword to open the input, only needed for a user-password PDF (owner-locked files with an empty user password open without it).
pdf_pathYesPDF source: a path to a .pdf file inside the allowed directories (PDFOPS_ROOT, default the working directory), an https:// URL, or a data:application/pdf;base64,… URI. A URL or data URI works when this server runs remotely (Smithery, hosted gateways), where local paths do not exist.
max_pagesNoAnalyse at most this many pages. Default 40. At most 100.
min_confidenceNoDrop fields below this confidence. Default 0.4 (drops only the weakest candidates, such as unlabelled shapes); 0.6 gives slightly higher precision and about a quarter fewer checkboxes.

Output Schema

NameRequiredDescriptionDefault
noteNoPresent when no fields were found or pages were skipped
countYesFields returned
pagesYes
fieldsYes
next_pageYesFirst page not returned, or null when finished
truncatedYesThe answer is incomplete (more pages than max_pages, more than 200 fields, or the call stopped at its limit): a further call on the PDF with the returned fields added and pages set to next_pages continues from there, and each call again covers at most max_pages pages. False means no page is left to continue; a page listed in pages_skipped as too_complex was not analysed and is never continued
next_pagesYesPage spec of exactly the pages not done (including a page cut at 200 fields), or null when finished
pages_skippedNoPages not analysed: too_complex (more drawn shapes or text than the per-page limits; sending them again gives the same answer) or deadline (the call stopped first; they are in next_pages)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv0.6.0

TDQS

A4.6/5.0
Behavior5/5

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

Annotations already declare readOnlyHint, idempotentHint, and destructiveHint=false, and the description reinforces this with 'the source is never modified'. Beyond that it discloses real behavior: coordinate system (PDF points from bottom-left as the viewer sees it, the frame pdf_add_fields and pdf_edit use), that results are suggestions with unreliable low-confidence entries and false positives from table cells and rules, the 200-field-per-call cap, page/time truncation with next_pages continuation, and that zero fields is a normal answer.

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?

Front-loaded with purpose and definition, then limitations, then result semantics, then parameters — a logical order with no filler sentences. It is long and repeats some defaults already present in the schema (0.4, 40, 100), which keeps it from a 5, but nearly every clause carries operational information.

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?

For a heuristic detection tool with a rich output schema, this covers everything an agent needs: what is detected and what is missed, coordinate frame, confidence caveats, per-call and per-page limits, truncation/continuation protocol, and the downstream chain to pdf_add_fields and pdf_fill. Return-value details are backed by the output schema, so no gaps remain.

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

Parameters3/5

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

Schema coverage is 100% and the schema descriptions are already extremely detailed about pages, password, pdf_path, max_pages, and min_confidence, so the schema does the heavy lifting. The description only restates the defaults (min_confidence 0.4, 0.6 for fewer but surer fields; max_pages 40, at most 100) and gestures at pages for continuing large forms, adding little syntax or meaning the schema lacks. Baseline 3 is appropriate.

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?

States a specific verb and resource ('Detect fillable form fields in a flat PDF') and immediately disambiguates the resource by defining a flat PDF as one where 'pdf_inspect lists none'. It also specifies the output shape (text or checkbox field per drawn blank, named from the nearest label, with confidence). An agent can distinguish this from pdf_inspect, pdf_add_fields, and pdf_fill without opening any schema.

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

Usage Guidelines5/5

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

Gives explicit when-to-use and when-to-use-something-else guidance: use this on flat PDFs with no form fields, use pdf_add_fields with detect=true to do detection and adding in one call, and pass results to pdf_add_fields (which ignores label and confidence) then pdf_fill. It also names the exclusion cases clearly — a blank area with no line or box, a scanned image, or shaded cells with no outline are not detected.

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