fill_forms
Fill existing form fields in PDF documents using field names and values. Use after reading form information to populate text in specified fields.
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
| Name | Required | Description | Default |
|---|---|---|---|
| url | Yes | 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 | Yes | List of fields to fill. Each field is a dict with 'fieldName', 'pages', and 'text' properties. | |
| name | No | File name for the generated output. (Optional) | |
| httpusername | No | HTTP auth user name if required to access source url. (Optional) | |
| httppassword | No | HTTP auth password if required to access source url. (Optional) | |
| api_key | No | PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional) |
Implementation Reference
- pdfco/mcp/tools/apis/form.py:41-89 (handler)Handler function decorated with @mcp.tool(name="fill_forms"). Defines input schema via Pydantic Fields and calls the helper to fill PDF forms.@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)
- pdfco/mcp/services/pdf.py:32-46 (helper)Core implementation that prepares the payload with form fields and invokes the PDF.co API via the 'request' function to fill the forms.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 )
- pdfco/mcp/tools/apis/form.py:43-89 (schema)Input schema defined in the handler function parameters using Pydantic Fields, including url, fields list, name, auth params, and api_key.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)
- pdfco/mcp/tools/apis/form.py:41-41 (registration)MCP tool registration decorator specifying the tool name 'fill_forms'.@mcp.tool(name="fill_forms")