Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

pdf_add_annotations_images_fields

Add annotations, images, and fill form fields to PDF documents to customize and enhance content for specific needs.

Instructions

Add text, images, forms, other PDFs, fill forms, links to external sites and external PDF files. You can update or modify PDF and scanned PDF files.

This tool supports three main ways to add content:

1. **annotations**: Add text, links, shapes, etc.
   Properties: text, x, y, size, pages, color, link, fontName, fontItalic, fontBold, fontStrikeout, fontUnderline

2. **images**: Add images or other PDF content
   Properties: url, x, y, width, height, pages

3. **fields**: Fill existing form fields
   Properties: fieldName, pages, text, fontName, size, fontBold, fontItalic, fontStrikeout, fontUnderline

Example annotations:
[{"text": "Sample Text - Click here to test link", "x": 250, "y": 240, "size": 24, "pages": "0-", "color": "CCBBAA", "link": "https://pdf.co/", "fontName": "Comic Sans MS", "fontItalic": true, "fontBold": true, "fontStrikeout": false, "fontUnderline": true}]

Example images:
[{"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-edit/logo.png", "x": 270, "y": 150, "width": 159, "height": 43, "pages": "0"}]

Example fields:
[{"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_05[0]", "pages": "1", "text": "Joan B.", "fontName": "Arial", "size": 6, "fontBold": true, "fontItalic": true, "fontStrikeout": true, "fontUnderline": true}]

Ref: https://developer.pdf.co/api-reference/pdf-add.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.
httpusernameNoHTTP auth user name if required to access source url. (Optional)
httppasswordNoHTTP auth password if required to access source url. (Optional)
passwordNoPassword for the PDF file. (Optional)
nameNoFile name for the generated output. (Optional)
annotationsNoArray of annotation objects to add text, links, shapes, etc. Each object can have: 'text' (string), 'x' (number), 'y' (number), 'size' (number), 'pages' (string), 'color' (string hex), 'link' (string URL), 'fontName' (string), 'fontItalic' (boolean), 'fontBold' (boolean), 'fontStrikeout' (boolean), 'fontUnderline' (boolean). (Optional)
imagesNoArray of image objects to add images to PDF. Each object can have: 'url' (string), 'x' (number), 'y' (number), 'width' (number), 'height' (number), 'pages' (string). (Optional)
fieldsNoArray of form field objects to fill PDF form fields. Each object can have: 'fieldName' (string), 'pages' (string), 'text' (string), 'fontName' (string), 'size' (number), 'fontBold' (boolean), 'fontItalic' (boolean), 'fontStrikeout' (boolean), 'fontUnderline' (boolean). (Optional)
expirationNoSet the expiration time for the output link in minutes. After this specified duration, any generated output file(s) will be automatically deleted. (Optional)
encryptNoEncrypt output file. (Optional)
flattenNoFlatten filled form fields and annotations into PDF content. Set to true to disable editing of filled form fields in the output PDF. (Optional)
api_keyNoPDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)

Implementation Reference

  • The handler function for the tool 'pdf_add_annotations_images_fields'. It is decorated with @mcp.tool() for registration and defines the input schema using Pydantic Field descriptions. The logic prepares parameters and calls the pdf_add helper to perform the PDF editing via API.
    @mcp.tool()
    async def pdf_add_annotations_images_fields(
        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."
        ),
        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="",
        ),
        password: str = Field(
            description="Password for the PDF file. (Optional)", default=""
        ),
        name: str = Field(
            description="File name for the generated output. (Optional)", default=""
        ),
        annotations: List[Any] = Field(
            description="Array of annotation objects to add text, links, shapes, etc. Each object can have: 'text' (string), 'x' (number), 'y' (number), 'size' (number), 'pages' (string), 'color' (string hex), 'link' (string URL), 'fontName' (string), 'fontItalic' (boolean), 'fontBold' (boolean), 'fontStrikeout' (boolean), 'fontUnderline' (boolean). (Optional)",
            default=[],
        ),
        images: List[Any] = Field(
            description="Array of image objects to add images to PDF. Each object can have: 'url' (string), 'x' (number), 'y' (number), 'width' (number), 'height' (number), 'pages' (string). (Optional)",
            default=[],
        ),
        fields: List[Any] = Field(
            description="Array of form field objects to fill PDF form fields. Each object can have: 'fieldName' (string), 'pages' (string), 'text' (string), 'fontName' (string), 'size' (number), 'fontBold' (boolean), 'fontItalic' (boolean), 'fontStrikeout' (boolean), 'fontUnderline' (boolean). (Optional)",
            default=[],
        ),
        expiration: int = Field(
            description="Set the expiration time for the output link in minutes. After this specified duration, any generated output file(s) will be automatically deleted. (Optional)",
            default=60,
        ),
        encrypt: bool = Field(description="Encrypt output file. (Optional)", default=False),
        flatten: bool = Field(
            description="Flatten filled form fields and annotations into PDF content. Set to true to disable editing of filled form fields in the output PDF. (Optional)",
            default=False,
        ),
        api_key: str = Field(
            description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
            default="",
        ),
    ) -> BaseResponse:
        """
        Add text, images, forms, other PDFs, fill forms, links to external sites and external PDF files. You can update or modify PDF and scanned PDF files.
    
        This tool supports three main ways to add content:
    
        1. **annotations**: Add text, links, shapes, etc.
           Properties: text, x, y, size, pages, color, link, fontName, fontItalic, fontBold, fontStrikeout, fontUnderline
    
        2. **images**: Add images or other PDF content
           Properties: url, x, y, width, height, pages
    
        3. **fields**: Fill existing form fields
           Properties: fieldName, pages, text, fontName, size, fontBold, fontItalic, fontStrikeout, fontUnderline
    
        Example annotations:
        [{"text": "Sample Text - Click here to test link", "x": 250, "y": 240, "size": 24, "pages": "0-", "color": "CCBBAA", "link": "https://pdf.co/", "fontName": "Comic Sans MS", "fontItalic": true, "fontBold": true, "fontStrikeout": false, "fontUnderline": true}]
    
        Example images:
        [{"url": "https://pdfco-test-files.s3.us-west-2.amazonaws.com/pdf-edit/logo.png", "x": 270, "y": 150, "width": 159, "height": 43, "pages": "0"}]
    
        Example fields:
        [{"fieldName": "topmostSubform[0].Page1[0].YourSocial_ReadOrderControl[0].f1_05[0]", "pages": "1", "text": "Joan B.", "fontName": "Arial", "size": 6, "fontBold": true, "fontItalic": true, "fontStrikeout": true, "fontUnderline": true}]
    
        Ref: https://developer.pdf.co/api-reference/pdf-add.md
        """
        params = ConversionParams(
            url=url,
            httpusername=httpusername,
            httppassword=httppassword,
            password=password,
            name=name,
            expiration=expiration,
        )
    
        # Prepare additional parameters
        add_params = {}
    
        if annotations:
            add_params["annotations"] = annotations
        if images:
            add_params["images"] = images
        if fields:
            add_params["fields"] = fields
        if encrypt:
            add_params["encrypt"] = encrypt
        if flatten:
            add_params["flatten"] = flatten
    
        return await pdf_add(params, **add_params, api_key=api_key)
  • Supporting helper function pdf_add that constructs the API request to 'pdf/edit/add' endpoint, passing annotations, images, fields etc. as custom payload to the PDF.co API.
    async def pdf_add(
        params: ConversionParams, api_key: str | None = None, **kwargs
    ) -> BaseResponse:
        """General PDF Add function that supports all PDF Add API parameters"""
        custom_payload = {}
    
        # Add all supported parameters
        for key, value in kwargs.items():
            if value is not None and value != "":
                custom_payload[key] = value
    
        return await request(
            "pdf/edit/add", params, custom_payload=custom_payload, api_key=api_key
        )
Behavior4/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It effectively describes the tool's capabilities (adding content, updating/modifying PDFs) and provides detailed examples of input structures. It mentions support for scanned PDFs and external links, which adds useful context. However, it lacks information on permissions, rate limits, or error handling, which are important for a mutation tool.

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

Conciseness4/5

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

The description is well-structured with a clear overview, categorized use cases, and detailed examples. It is appropriately sized for a complex tool but includes a reference link that could be considered extraneous. Most sentences earn their place by explaining functionality or providing examples, though the examples are lengthy but necessary for clarity.

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?

Given the tool's complexity (12 parameters, mutation operation) and lack of annotations or output schema, the description does a good job of covering key aspects: purpose, usage, parameter semantics, and examples. It compensates well for the missing structured data. However, it could improve by mentioning output behavior (e.g., what is returned) or error cases, which would enhance completeness.

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

Parameters3/5

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

The schema description coverage is 100%, so the schema already documents all 12 parameters thoroughly. The description adds value by grouping parameters into three categories (annotations, images, fields) and providing example structures with property details, which helps clarify usage beyond the schema. However, it does not explain parameter interactions or dependencies, keeping it at a baseline level.

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's purpose with specific verbs ('Add text, images, forms, other PDFs, fill forms, links') and resources ('PDF and scanned PDF files'). It distinguishes itself from sibling tools like 'fill_forms' by covering broader content addition beyond just form filling, and from 'pdf_merge' by focusing on modification rather than combining files.

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 provides clear context for when to use this tool ('update or modify PDF and scanned PDF files') and outlines three main use cases (annotations, images, fields). However, it does not explicitly state when not to use it or name specific alternatives among the sibling tools, such as 'pdf_merge' for combining PDFs or 'fill_forms' for simpler form filling.

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