Skip to main content
Glama
andr3medeiros

PDF Manipulation MCP Server

pdf_add_form_field

Add interactive form fields like text boxes or checkboxes to PDF documents at specified positions and pages to create fillable forms.

Instructions

Add a form field to a PDF.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pdf_pathYes
page_numberYes
field_typeYes
field_nameYes
xYes
yYes
widthYes
heightYes
optionsNo

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes

Implementation Reference

  • The core handler function for the 'pdf_add_form_field' tool. Decorated with @mcp.tool() for automatic registration in FastMCP. Adds interactive form fields (text, checkbox, radio button, or combobox) to a specified position on a PDF page using PyMuPDF. Validates input, creates the widget, updates it, saves to a new timestamped file, and returns the output path.
    async def pdf_add_form_field(
        pdf_path: str,
        page_number: int,
        field_type: str,
        field_name: str,
        x: float,
        y: float,
        width: float,
        height: float,
        options: List[str] = None
    ) -> str:
        """Add a form field to a PDF."""
        if options is None:
            options = []
        
        if not os.path.exists(pdf_path):
            return f"Error: PDF file not found: {pdf_path}"
        
        if not validate_pdf_file(pdf_path):
            return f"Error: Invalid PDF file: {pdf_path}"
        
        try:
            # Open PDF document
            doc = fitz.open(pdf_path)
            
            # Validate page number
            if not validate_page_number(doc, page_number):
                doc.close()
                return f"Error: Invalid page number {page_number}. Document has {len(doc)} pages."
            
            # Get the page
            page = doc[page_number]
            
            # Create rectangle for form field
            rect = fitz.Rect(x, y, x + width, y + height)
            
            # Add form field based on type
            if field_type == "text":
                widget = page.add_textfield(rect, field_name)
            elif field_type == "checkbox":
                widget = page.add_checkbox(rect, field_name)
            elif field_type == "radio":
                widget = page.add_radio_button(rect, field_name)
            elif field_type == "combobox":
                widget = page.add_combobox(rect, field_name, options)
            else:
                doc.close()
                return f"Error: Invalid field type: {field_type}"
            
            # Update widget appearance
            widget.update()
            
            # Generate output filename
            output_path = generate_output_filename(pdf_path)
            
            # Save the modified PDF
            doc.save(output_path)
            doc.close()
            
            return f"Successfully added {field_type} form field '{field_name}' to PDF. Output saved to: {output_path}"
            
        except Exception as e:
            return f"Error adding form field to PDF: {str(e)}"
Behavior1/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states the basic action without revealing any behavioral traits: it doesn't mention whether this modifies the original PDF or creates a new one, what permissions are needed, whether the operation is reversible, error conditions, or rate limits. For a mutation tool with zero annotation coverage, this is a critical gap.

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 a single, efficient sentence with zero wasted words. It's front-loaded with the core action and resource, making it immediately understandable. Every word earns its place, though this conciseness comes at the cost of completeness.

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

Completeness2/5

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

Given the complexity (9 parameters, mutation operation), absence of annotations, and 0% schema description coverage, the description is incomplete. While an output schema exists (which reduces the need to describe return values), the description doesn't address critical context: behavioral traits, parameter meanings, usage guidelines, or error handling. For a PDF manipulation tool with many parameters, this leaves significant gaps for the agent.

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

Parameters1/5

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

Schema description coverage is 0%, meaning none of the 9 parameters have descriptions in the schema. The description adds no parameter semantics beyond the tool name—it doesn't explain what 'field_type' accepts, what 'options' array contains, coordinate systems for x/y/width/height, or format expectations for 'pdf_path'. With 9 undocumented parameters, the description fails to compensate for the schema gap.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the action ('Add a form field') and resource ('to a PDF'), providing a specific verb+resource combination. It distinguishes this tool from siblings like pdf_fill_form (which fills existing fields) and pdf_add_annotation (which adds annotations rather than form fields). However, it doesn't explicitly mention what types of form fields can be added or the scope of the operation.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites (e.g., needing an existing PDF), when not to use it (e.g., for non-form annotations), or direct alternatives among the sibling tools. The agent must infer usage from the tool name and sibling context alone.

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/andr3medeiros/pdf-manipulation-mcp-server'

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