Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

fill_forms

Fill existing form fields in a PDF document by providing field names, page numbers, and text values. Use 'read_pdf_forms_info' to retrieve field names first.

Instructions

Fill existing form fields in a PDF document.

Example fields format:
[
    {
        "fieldName": "field_name_from_form_info",
        "pages": "1",
        "text": "Value to fill"
    }
]

Use 'read_pdf_forms_info' first to get the fieldName values of the form.

Ref: https://developer.pdf.co/api-reference/pdf-add#create-fillable-pdf-forms.md

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files.
fieldsYesList of fields to fill. Each field is a dict with 'fieldName', 'pages', and 'text' properties.
nameNoFile name for the generated output. (Optional)
httpusernameNoHTTP auth user name if required to access source url. (Optional)
httppasswordNoHTTP auth password if required to access source url. (Optional)
api_keyNoPDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)

Implementation Reference

  • The tool handler function 'fill_pdf_forms' registered as 'fill_forms'. It receives a URL, a list of fields with fieldName/pages/text, and optional parameters, then calls fill_pdf_form_fields service function.
    @mcp.tool(name="fill_forms")
    async def fill_pdf_forms(
        url: str = Field(
            description="URL to the source PDF file. Supports publicly accessible links including Google Drive, Dropbox, PDF.co Built-In Files Storage. Use 'upload_file' tool to upload local files."
        ),
        fields: list = Field(
            description="List of fields to fill. Each field is a dict with 'fieldName', 'pages', and 'text' properties."
        ),
        name: str = Field(
            description="File name for the generated output. (Optional)", default=""
        ),
        httpusername: str = Field(
            description="HTTP auth user name if required to access source url. (Optional)",
            default="",
        ),
        httppassword: str = Field(
            description="HTTP auth password if required to access source url. (Optional)",
            default="",
        ),
        api_key: str = Field(
            description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
            default="",
        ),
    ) -> BaseResponse:
        """
        Fill existing form fields in a PDF document.
    
        Example fields format:
        [
            {
                "fieldName": "field_name_from_form_info",
                "pages": "1",
                "text": "Value to fill"
            }
        ]
    
        Use 'read_pdf_forms_info' first to get the fieldName values of the form.
    
        Ref: https://developer.pdf.co/api-reference/pdf-add#create-fillable-pdf-forms.md
        """
        params = ConversionParams(
            url=url,
            httpusername=httpusername,
            httppassword=httppassword,
            name=name,
        )
    
        return await fill_pdf_form_fields(params, fields=fields, api_key=api_key)
  • Input parameters for fill_forms tool: url (str), fields (list of dicts with fieldName/pages/text), name (str, optional), httpusername/httppassword (str, optional), api_key (str, optional). All defined via pydantic Field descriptors.
        return await get_pdf_form_fields_info(params, api_key=api_key)
    
    
    @mcp.tool(name="fill_forms")
  • Tool registration via @mcp.tool(name='fill_forms') decorator on the fill_pdf_forms async function.
    @mcp.tool(name="fill_forms")
  • The service function 'fill_pdf_form_fields' which constructs the payload with fields and annotations and sends a POST request to 'pdf/edit/add' endpoint.
    async def fill_pdf_form_fields(
        params: ConversionParams,
        fields: list | None = None,
        annotations: list | None = None,
        api_key: str | None = None,
    ) -> BaseResponse:
        custom_payload = {}
        if fields:
            custom_payload["fields"] = fields
        if annotations:
            custom_payload["annotations"] = annotations
        return await request(
            "pdf/edit/add", params, custom_payload=custom_payload, api_key=api_key
        )
Behavior2/5

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

With no annotations, the description carries full burden for behavioral disclosure. It fails to mention whether the tool modifies the original file, handles missing fields, or requires specific authentication beyond HTTP params. The behavior is implied but not transparent.

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 concise (three sentences plus example and reference). It front-loads the primary purpose and uses structure (example, reference) efficiently. Every element serves a clear purpose without unnecessary text.

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

Completeness3/5

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

Given 6 parameters, no output schema, and no annotations, the description covers core usage well but lacks details on return values, error handling, and behavioral intricacies. The prerequisite hint (read_pdf_forms_info) aids completeness but does not fully compensate for the missing output schema and behavioral transparency.

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?

Schema coverage is 100% with descriptions for all 6 parameters. The description adds valuable context by showing the exact JSON format for the 'fields' array and specifying that fieldName comes from read_pdf_forms_info. This enhances understanding beyond schema alone.

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 fills existing form fields in a PDF document (verb+resource). It differentiates from siblings like 'create_fillable_forms' and 'read_pdf_forms_info' by instructing to use the latter first to obtain field names.

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

Usage Guidelines4/5

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

The description explicitly tells agents to use 'read_pdf_forms_info' first to get field names, providing a clear prerequisite. It does not specify when not to use this tool, but the sibling context implies alternatives exist. The example format further guides usage.

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/pdfdotco/pdfco-mcp'

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