Skip to main content
Glama

inspect_pdf_form

Retrieve names, types, and current values of form fields from a base64-encoded PDF. Returns a JSON array of field definitions.

Instructions

Inspect form fields in a PDF and return their names, types, and current values.

Args: pdf_base64: Base64-encoded PDF file with form fields.

Returns: JSON array of form field definitions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_base64Yes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The MCP tool handler for 'inspect_pdf_form'. Decodes the base64 PDF, delegates to dg.pdf_forms.inspect_fields(), and returns a JSON array of form field definitions.
    @mcp.tool()
    def inspect_pdf_form(pdf_base64: str) -> str:
        """Inspect form fields in a PDF and return their names, types, and current values.
    
        Args:
            pdf_base64: Base64-encoded PDF file with form fields.
    
        Returns:
            JSON array of form field definitions.
        """
        dg = _get_client()
        fields = dg.pdf_forms.inspect_fields(base64.b64decode(pdf_base64))
        from docgen._serialization import to_dict
        return json.dumps([to_dict(f) for f in fields])
  • The PdfFormsClient.inspect_fields() method called by the handler. Sends a POST request to /api/pdf-forms/fields/base64 and deserializes the response into PdfFormField instances.
    def inspect_fields(self, pdf: FileInput) -> list[PdfFormField]:
        """Inspect form fields in a PDF.
    
        Args:
            pdf: PDF file (path, bytes, or base64).
    
        Returns:
            List of form fields found in the PDF.
        """
        data = self._transport.request_json(
            "POST", "/api/pdf-forms/fields/base64",
            json={"pdfBase64": to_base64(pdf)},
        )
        # API returns a list directly
        if isinstance(data, list):
            return [from_dict(PdfFormField, item) for item in data]
        return [from_dict(PdfFormField, item) for item in data.get("fields", [])]
  • The PdfFormField dataclass schema defining the structure of a form field returned by inspect_fields.
    @dataclass
    class PdfFormField:
        """A field found in a PDF AcroForm.
    
        Args:
            name: Field name.
            type: Field type (TEXT, CHECKBOX, RADIO, DROPDOWN, LISTBOX, SIGNATURE, BUTTON).
            value: Current field value.
            required: Whether the field is required.
            read_only: Whether the field is read-only.
            max_length: Maximum character length (for text fields).
            options: Available options (for dropdown/listbox/radio).
        """
    
        name: str
        type: str
        value: str | None = None
        required: bool = False
        read_only: bool = False
        max_length: int | None = None
        options: list[str] | None = None
  • The TypeScript interface definition for PdfFormField, mirroring the Python schema.
    /** A form field detected in a PDF. */
    export interface PdfFormField {
      name: string;
      type: string;
      value?: string;
      options?: string[];
      required?: boolean;
      readOnly?: boolean;
    }
  • The @mcp.tool() decorator on the inspect_pdf_form function registers it as an MCP tool with the FastMCP server.
    @mcp.tool()
    def inspect_pdf_form(pdf_base64: str) -> str:
        """Inspect form fields in a PDF and return their names, types, and current values.
    
        Args:
            pdf_base64: Base64-encoded PDF file with form fields.
    
        Returns:
            JSON array of form field definitions.
        """
        dg = _get_client()
        fields = dg.pdf_forms.inspect_fields(base64.b64decode(pdf_base64))
        from docgen._serialization import to_dict
        return json.dumps([to_dict(f) for f in fields])
Behavior3/5

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

With no annotations, the description carries the full burden. It discloses the output format (JSON array of form field definitions) but does not mention side effects, permissions, error conditions (e.g., PDF without form fields), or performance constraints. The term 'inspect' implies read-only, but this is not explicit.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise: two sentences for purpose plus a neat Args/Returns section. Every line adds value, and the main action is front-loaded. No wasted words.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers input format, output structure, and core behavior. With an output schema present, it doesn't need to detail return values further. However, it omits behavior for edge cases like PDFs with no form fields, which could be clarified.

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

Parameters4/5

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

The description adds meaning beyond the input schema by specifying that pdf_base64 should be a 'Base64-encoded PDF file with form fields,' which clarifies both the encoding and the requirement for form fields. The schema only provides a title.

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?

The description clearly states the tool inspects form fields in a PDF and returns their names, types, and values. It uses a specific verb ('inspect') and resource ('form fields in a PDF'), distinguishing it from sibling tools like fill_pdf_form or extract_text_from_pdf.

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

Usage Guidelines3/5

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

The description implies usage when needing to examine form fields, but provides no explicit guidance on when to use versus alternatives (e.g., fill_pdf_form, extract_text_from_pdf) or when not to use it.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dokmatiq/docgen-sdks'

If you have feedback or need assistance with the MCP directory API, please join our Discord server