ai_invoice_parser
Extract structured data from invoices using AI. Input a PDF file URL to process and retrieve key details automatically. Designed for PDF.co MCP Server integration.
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
| Name | Required | Description | Default |
|---|---|---|---|
| api_key | No | PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional) | |
| 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. |
Implementation Reference
- pdfco/mcp/tools/apis/extraction.py:8-29 (handler)The primary handler function for the 'ai_invoice_parser' tool. Registered via @mcp.tool(), defines input schema using Pydantic Field descriptions, and implements the logic by constructing params and delegating to the parse_invoice helper.@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)
- pdfco/mcp/services/pdf.py:115-116 (helper)Supporting helper function that wraps the generic API request to the PDF.co 'ai-invoice-parser' endpoint.async def parse_invoice(params: ConversionParams, api_key: str | None = None) -> BaseResponse: return await request("ai-invoice-parser", params, api_key=api_key)
- pdfco/mcp/tools/apis/extraction.py:8-8 (registration)The @mcp.tool() decorator registers the ai_invoice_parser as an MCP tool.@mcp.tool()
- Input schema defined using Pydantic Field for the tool parameters: url and optional 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." ), api_key: str = Field( description="PDF.co API key. If not provided, will use X_API_KEY environment variable. (Optional)", default="", ), ) -> BaseResponse: