Skip to main content
Glama
pdfdotco

PDF.co MCP Server

Official
by pdfdotco

ai_invoice_parser

Extract structured data from invoices using AI to automate data entry and processing tasks.

Instructions

AI Invoice Parser: Extracts data from invoices using AI.
Ref: https://developer.pdf.co/api-reference/ai-invoice-parser.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.
api_keyNoPDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)

Implementation Reference

  • The core handler function for the 'ai_invoice_parser' tool, registered via @mcp.tool() decorator. Defines input schema (url and optional api_key) using Pydantic Field for descriptions and validation. Prepares ConversionParams and delegates to parse_invoice helper for API execution.
    @mcp.tool()
    async def ai_invoice_parser(
        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."
        ),
        api_key: str = Field(
            description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)",
            default="",
        ),
    ) -> BaseResponse:
        """
        AI Invoice Parser: Extracts data from invoices using AI.
        Ref: https://developer.pdf.co/api-reference/ai-invoice-parser.md
        """
    
        # Pass arguments directly; ConversionParams now handles str with default=None
        params = ConversionParams(
            url=url,
        )
    
        return await parse_invoice(params, api_key=api_key)
  • Helper function that performs the specific HTTP request to the PDF.co 'ai-invoice-parser' API endpoint using the general request function.
    async def parse_invoice(params: ConversionParams, api_key: str | None = None) -> BaseResponse:
        return await request("ai-invoice-parser", params, api_key=api_key)
  • General-purpose HTTP request helper used by parse_invoice (and other tools) to call PDF.co API endpoints asynchronously, handling payload preparation, client usage, response parsing, and error handling.
    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?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool extracts data using AI but doesn't mention any behavioral traits such as rate limits, authentication needs (beyond the optional API key in schema), error handling, or what the extracted data looks like. This is a significant gap for a tool with no annotation coverage.

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 concise 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 slightly extraneous. Overall, it's efficient with minimal waste, though it lacks structural elements like bullet points or examples.

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 complexity of an AI-based extraction tool with no annotations and no output schema, the description is incomplete. It doesn't explain what data is extracted (e.g., fields like invoice number, date, amount), the format of the output, or any limitations (e.g., supported invoice formats, accuracy). This leaves significant gaps for an agent to understand the tool's behavior fully.

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 the schema already documents both parameters (url and api_key) with good descriptions. The tool description adds no additional parameter semantics beyond what's in the schema. According to the rules, with high schema coverage, the baseline is 3 even with no param info in the description.

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 tool's purpose: 'Extracts data from invoices using AI.' It specifies the verb ('extracts'), resource ('data from invoices'), and method ('using AI'), which is more specific than just the tool name. However, it doesn't explicitly differentiate from sibling tools like 'pdf_to_csv' or 'pdf_to_json' that might also extract data from PDFs, though the AI focus provides some distinction.

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?

The description provides no guidance on when to use this tool versus alternatives. It mentions a reference link but doesn't specify scenarios, prerequisites, or exclusions. For example, it doesn't clarify if this is for structured invoice data versus general PDF extraction tools in the sibling list, leaving usage context unclear.

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