Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

extract_attachments

Extract embedded files from PDF documents to access attachments like images, spreadsheets, or documents stored within PDF files.

Instructions

Extracts attachments from a source PDF file.
Ref: https://developer.pdf.co/api-reference/pdf-extract-attachments.md

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
urlYesURL to the source PDF file.
httpusernameNoHTTP auth user name if required to access source url. (Optional)
httppasswordNoHTTP auth password if required to access source url. (Optional)
passwordNoPassword of PDF file. (Optional)
api_keyNoPDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)

Implementation Reference

  • The MCP tool handler for 'extract_attachments'. It defines the input schema using Pydantic Field, registers the tool via @mcp.tool(), and delegates to the service helper function extract_pdf_attachments.
    @mcp.tool()
    async def extract_attachments(
        url: str = Field(description="URL to the source PDF file."),
        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 of PDF file. (Optional)", default=""),
        api_key: str = Field(
            description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
            default="",
        ),
    ) -> BaseResponse:
        """
        Extracts attachments from a source PDF file.
        Ref: https://developer.pdf.co/api-reference/pdf-extract-attachments.md
        """
        params = ConversionParams(
            url=url,
            httpusername=httpusername if httpusername else None,
            httppassword=httppassword if httppassword else None,
            password=password if password else None,
        )
        return await extract_pdf_attachments(params, api_key=api_key)
  • Service helper function that invokes the PDF.co API endpoint for extracting attachments from PDF.
    async def extract_pdf_attachments(
        params: ConversionParams, api_key: str | None = None
    ) -> BaseResponse:
        return await request("pdf/attachments/extract", params, api_key=api_key)
  • Core request helper function used by extract_pdf_attachments to make the async HTTP POST request to the PDF.co API.
    async def request(
        endpoint: str,
        params: ConversionParams,
        custom_payload: dict | None = None,
        api_key: str | None = None,
    ) -> BaseResponse:
        payload = params.parse_payload(async_mode=True)
        if custom_payload:
            payload.update(custom_payload)
    
        try:
            async with PDFCoClient(api_key=api_key) as client:
                url = f"/v1/{endpoint}"
                print(f"Requesting {url} with payload {payload}", file=sys.stderr)
                response = await client.post(url, json=payload)
                print(f"response: {response}", file=sys.stderr)
                json_data = response.json()
                return BaseResponse(
                    status="working",
                    content=json_data,
                    credits_used=json_data.get("credits"),
                    credits_remaining=json_data.get("remainingCredits"),
                    tips=f"You **should** use the 'wait_job_completion' tool to wait for the job [{json_data.get('jobId')}] to complete if a jobId is present.",
                )
        except Exception as e:
            return BaseResponse(
                status="error",
                content=f"{type(e)}: {[arg for arg in e.args if arg]}",
            )
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic function without behavioral details. It doesn't disclose traits like whether it's read-only, destructive (e.g., modifies the PDF), authentication needs beyond parameters, rate limits, or output format (e.g., returns file paths or data). This is inadequate for a tool with multiple parameters and no output schema.

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 brief and front-loaded with the core purpose in the first sentence. The second sentence provides a reference link, which is useful but could be considered extraneous. Overall, it's efficient with minimal waste, though slightly under-specified in context.

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 tool's complexity (5 parameters, no output schema, and no annotations), the description is incomplete. It fails to explain behavioral aspects, usage context, or what the output entails (e.g., extracted file data or references), leaving significant gaps for an agent to operate effectively without additional inference.

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?

Schema description coverage is 100%, so parameters are well-documented in the schema itself. The description adds no additional meaning beyond implying extraction from a PDF, which is already clear from the tool name and schema. This meets the baseline for high schema coverage but doesn't enhance understanding.

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 ('extracts') and resource ('attachments from a source PDF file'), providing a specific purpose. However, it doesn't differentiate from sibling tools like 'pdf_info_reader' or 'read_pdf_forms_info' which might also handle PDF content extraction, leaving room for ambiguity in tool selection.

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?

No guidance is provided on when to use this tool versus alternatives. The description lacks context such as prerequisites (e.g., needing a PDF with attachments), exclusions (e.g., not for encrypted files without password), or comparisons to siblings like 'pdf_to_csv' for different extraction types, leaving the agent without usage direction.

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