extract_receipt
Extract vendor, date, totals, line items, and other structured data from receipt or invoice images using AI. Returns confidence score and supports JPEG, PNG, or PDF.
Instructions
Extract structured data from a receipt or invoice image using AI.
Returns vendor, date, totals (gross/net/VAT per rate), line items, currency, payment method, SKR03/04 account, category, and confidence score.
Args: image_base64: Base64-encoded receipt image (JPEG, PNG) or PDF. filename: Original filename (helps with format detection). content_type: MIME type (default: image/jpeg). Use application/pdf for PDF receipts.
Returns: JSON with extracted receipt data.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| image_base64 | Yes | ||
| filename | No | receipt.jpg | |
| content_type | No | image/jpeg |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- mcp/src/docgen_mcp/server.py:778-796 (handler)The main handler for the extract_receipt MCP tool. Decodes the base64 image, calls dg.receipts.extract(), and returns JSON results.
@mcp.tool() def extract_receipt(image_base64: str, filename: str = "receipt.jpg", content_type: str = "image/jpeg") -> str: """Extract structured data from a receipt or invoice image using AI. Returns vendor, date, totals (gross/net/VAT per rate), line items, currency, payment method, SKR03/04 account, category, and confidence score. Args: image_base64: Base64-encoded receipt image (JPEG, PNG) or PDF. filename: Original filename (helps with format detection). content_type: MIME type (default: image/jpeg). Use application/pdf for PDF receipts. Returns: JSON with extracted receipt data. """ dg = _get_client() file_bytes = base64.b64decode(image_base64) result = dg.receipts.extract(file_bytes, filename, content_type) return json.dumps(result, default=str) - mcp/src/docgen_mcp/server.py:778-778 (registration)The @mcp.tool() decorator registers extract_receipt as an MCP tool on the FastMCP instance.
@mcp.tool()