Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

fill_forms

Fill PDF form fields with specific values using field names and page numbers. Works with online PDFs or uploaded files, ensuring accurate data entry and form completion.

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
api_keyNoPDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)
fieldsYesList of fields to fill. Each field is a dict with 'fieldName', 'pages', and 'text' properties.
httppasswordNoHTTP auth password if required to access source url. (Optional)
httpusernameNoHTTP auth user name if required to access source url. (Optional)
nameNoFile name for the generated output. (Optional)
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.

Implementation Reference

  • The MCP tool handler for 'fill_forms', registered with @mcp.tool(name='fill_forms'). Defines input schema with Pydantic Fields and calls the helper fill_pdf_form_fields.
    @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)
  • Core helper function that prepares the payload for filling PDF forms (or adding annotations) and invokes the generic PDF.co API request to the '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 )

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