Skip to main content
Glama
Invoice Parser MCP

Invoice Parser MCP

by knportal

Invoice Parser MCP

从您的 AI 智能体中将发票、收据和财务文档解析为结构化 JSON。

License: MIT Version MCP

收录于: Glama · Smithery · mcp.so

专为 Model Context Protocol 构建。由 Claude Vision 提供支持。

功能说明

从 PDF 发票、扫描收据和图像文件中提取结构化数据。无需模板,无需 OCR 配置 —— Claude Vision 读取文档并返回整洁的 JSON。


Related MCP server: kelnix-receipt-mcp-api

工具

工具

描述

价格

parse_invoice

完整发票解析(供应商、行项目、总计、到期日)

$0.05/次

parse_receipt

零售收据解析(商户、项目、税费、支付方式)

$0.05/次

extract_line_items

仅提取明细列表,不包含其他内容

$0.01/次

extract_totals

仅提取小计、税费、总计、到期日

$0.01/次

validate_invoice

数学验证 —— 检查行项目总和是否正确

$0.01/次

export_to_csv

批量解析多个文件 → 汇总 CSV(最多 20 个)

$0.10/次


工具参考

parse_invoice

完整发票解析。从供应商发票中提取所有结构化字段。

参数

参数

类型

必需

描述

file_path

string

是

发票 PDF 或图像(PNG, JPG, WEBP)的绝对路径。

api_key

string

否*

您的 InvoiceParser API 密钥。请在 plenitudo.ai 获取。

payment_proof

string

否*

x402 支付证明(Base USDC 交易哈希)。api_key 的替代方案。

*必须提供 api_key 或 payment_proof 其中之一。

输入示例

{
  "file_path": "/Users/me/documents/invoice_acme_jan2025.pdf",
  "api_key": "ip_free_abc123"
}

输出示例

{
  "ok": true,
  "document_type": "invoice",
  "vendor": {
    "name": "Acme Corp",
    "address": "123 Industrial Way, Austin TX 78701",
    "email": "billing@acme.com",
    "phone": "512-555-0100",
    "tax_id": "12-3456789"
  },
  "bill_to": {
    "name": "Jane Smith",
    "address": "456 Oak Ave, Boston MA 02101",
    "email": "jane@example.com"
  },
  "invoice_number": "INV-2025-0142",
  "invoice_date": "2025-01-15",
  "due_date": "2025-02-15",
  "payment_terms": "Net 30",
  "currency": "USD",
  "line_items": [
    {
      "description": "Software consulting — January",
      "quantity": 40,
      "unit_price": 175.0,
      "total": 7000.0,
      "tax_rate": 0.0
    }
  ],
  "subtotal": 7000.0,
  "discount": 0.0,
  "tax_amount": 560.0,
  "shipping": 0.0,
  "total": 7560.0,
  "amount_due": 7560.0,
  "notes": "Wire transfer preferred. See banking details on page 2.",
  "po_number": "PO-98765"
}

parse_receipt

解析零售或费用收据。专为销售点收据、餐厅账单和费用报销单据设计。

参数

参数

类型

必需

描述

file_path

string

是

收据 PDF 或图像(PNG, JPG, WEBP)的绝对路径。

api_key

string

否*

您的 InvoiceParser API 密钥。

payment_proof

string

否*

x402 支付证明(Base USDC 交易哈希)。

输入示例

{
  "file_path": "/Users/me/receipts/coffee_shop_march1.jpg",
  "api_key": "ip_free_abc123"
}

输出示例

{
  "ok": true,
  "document_type": "receipt",
  "merchant": {
    "name": "Blue Bottle Coffee",
    "address": "300 Webster St, Oakland CA 94609",
    "phone": "510-555-0200",
    "website": "bluebottlecoffee.com"
  },
  "date": "2025-03-01",
  "time": "09:14",
  "receipt_number": "5541",
  "cashier": "Maria",
  "items": [
    { "name": "Latte (large)", "quantity": 1, "unit_price": 6.50, "total": 6.50, "sku": "", "category": "beverage" },
    { "name": "Croissant", "quantity": 1, "unit_price": 4.00, "total": 4.00, "sku": "", "category": "pastry" }
  ],
  "subtotal": 10.50,
  "discounts": 0.0,
  "tax": 0.84,
  "tip": 2.00,
  "total": 13.34,
  "currency": "USD",
  "payment_method": "Visa",
  "card_last_four": "4242",
  "transaction_id": "TXN-88821",
  "loyalty_points": null,
  "notes": ""
}

extract_line_items

轻量级提取,仅返回明细列表。当您只需要行项目时,比 parse_invoice 更快且更便宜。

参数

参数

类型

必需

描述

file_path

string

是

发票或收据 PDF 或图像的绝对路径。

api_key

string

否*

您的 InvoiceParser API 密钥。

payment_proof

string

否*

x402 支付证明(Base USDC 交易哈希)。

输出示例

{
  "ok": true,
  "line_items": [
    { "description": "Widget A (x10)", "quantity": 10, "unit_price": 12.00, "total": 120.00 },
    { "description": "Widget B (x5)",  "quantity": 5,  "unit_price": 24.00, "total": 120.00 }
  ],
  "item_count": 2
}

extract_totals

仅提取财务摘要(小计、税费、总计、到期日),不解析行项目或供应商详细信息。

参数

参数

类型

必需

描述

file_path

string

是

发票或收据 PDF 或图像的绝对路径。

api_key

string

否*

您的 InvoiceParser API 密钥。

payment_proof

string

否*

x402 支付证明(Base USDC 交易哈希)。

输出示例

{
  "ok": true,
  "currency": "USD",
  "subtotal": 240.00,
  "discount": 0.0,
  "tax_amount": 19.20,
  "tax_rate": 8.0,
  "shipping": 0.0,
  "tip": 0.0,
  "total": 259.20,
  "amount_due": 259.20,
  "invoice_date": "2025-01-15",
  "due_date": "2025-02-15"
}

validate_invoice

数学验证工具。验证行项目总计是否等于 quantity × unit_price,小计是否与行项目总和匹配,税费计算是否一致,以及最终总计是否核对无误。允许 ±$0.02 的舍入误差。

参数

参数

类型

必需

描述

file_path

string

是

发票 PDF 或图像的绝对路径。

api_key

string

否*

您的 InvoiceParser API 密钥。

payment_proof

string

否*

x402 支付证明(Base USDC 交易哈希)。

输出示例 — 有效发票

{
  "ok": true,
  "valid": true,
  "issues": [],
  "summary": {
    "line_items_checked": 3,
    "subtotal": 450.00,
    "tax": 36.00,
    "total": 486.00,
    "currency": "USD"
  }
}

输出示例 — 无效发票

{
  "ok": true,
  "valid": false,
  "issues": [
    {
      "field": "line_item_2_total",
      "expected": 120.00,
      "found": 100.00,
      "description": "quantity (10) × unit_price (12.00) = 120.00, but stated total is 100.00"
    }
  ],
  "summary": {
    "line_items_checked": 3,
    "subtotal": 340.00,
    "tax": 27.20,
    "total": 367.20,
    "currency": "USD"
  }
}

export_to_csv

批量解析最多 20 张发票或收据并导出为汇总 CSV。每一行包含:文件名、文档类型、供应商/商户、日期、编号、小计、税费、总计、货币、到期日、支付方式。

参数

参数

类型

必需

描述

file_paths

字符串数组

是

发票/收据 PDF 或图像的绝对路径列表。最多 20 个。

output_path

string

是

保存输出 CSV 文件的绝对路径。

api_key

string

否*

您的 InvoiceParser API 密钥。

payment_proof

string

否*

x402 支付证明(Base USDC 交易哈希)。

输入示例

{
  "file_paths": [
    "/Users/me/invoices/jan2025.pdf",
    "/Users/me/invoices/feb2025.pdf",
    "/Users/me/receipts/expense_march.jpg"
  ],
  "output_path": "/Users/me/exports/q1_summary.csv",
  "api_key": "ip_free_abc123"
}

输出示例 (JSON 响应)

{
  "ok": true,
  "output_path": "/Users/me/exports/q1_summary.csv",
  "rows_written": 3,
  "errors": []
}

CSV 列: filename, document_type, vendor_merchant, date, number, subtotal, tax, total, currency, due_date, payment_method


支持的格式

  • PDF(发票、扫描文档)

  • PNG, JPG, WEBP(收据照片、截图)


身份验证

免费层级: 每月 20 次解析(需 API 密钥,请在 plenitudo.ai 获取)

按需付费 (x402): 无需账户。向钱包地址发送 Base 链上的 USDC,并将交易哈希作为 payment_proof 传入。

{
  "error": "Payment required",
  "x402": {
    "network": "base",
    "token": "USDC",
    "recipient": "0x9053FeDC90c1BCB4a8Cf708DdB426aB02430d6ad",
    "amount_usdc": 0.05
  }
}

使用方法 (Claude Desktop / MCP 客户端)

{
  "mcpServers": {
    "invoice-parser": {
      "url": "https://invoice-parser.plenitudo.ai/mcp?ref=readme"
    }
  }
}

架构

server.py          — MCP server (6 tools: parse_invoice, parse_receipt,
                     extract_line_items, extract_totals, validate_invoice,
                     export_to_csv)
auth.py            — API key validation + usage tracking (SQLite)
x402.py            — x402 micropayment verification (USDC on Base)
config.py          — Environment variable loading
worker.js          — Cloudflare Worker (remote proxy for MCP traffic)
data/keys.db       — API key store (created at runtime)
data/usage.db      — Monthly usage counters (created at runtime)
logs/              — Structured log files
tests/             — Unit tests (mock Vision API, no real documents needed)

请求流程

AI agent (Claude Desktop, Cursor, etc.)
    │
    │  MCP tool call (JSON-RPC over HTTP)
    ▼
Cloudflare Worker (worker.js)        ← optional remote proxy
    │
    │  Forwards to Railway deployment
    ▼
server.py (FastMCP, streamable HTTP)
    │
    ├── auth.py              validates API key / x402 proof
    ├── x402.py              verifies USDC transaction on Base
    └── Anthropic API        Claude Vision reads the document
            │
            ▼
        structured JSON → returned to agent

环境变量

变量

必需

描述

ANTHROPIC_API_KEY

是

用于 Claude Vision 的 Anthropic API 密钥。设置为 maxproxy 以进行本地代理路由。

ANTHROPIC_BASE_URL

否

覆盖 Anthropic 基础 URL。在本地使用 maxproxy 时设置为 http://localhost:3456。云部署中请留空。

CLAUDE_MODEL

否

Claude 模型 ID。默认为 claude-3-5-sonnet-20241022。

INVOICEPARSER_DATA_DIR

否

SQLite 数据库目录。默认为 ./data。

PORT

否

HTTP 端口。默认为 8000。Railway 会自动设置此项。


部署 (Railway)

  1. Fork 此仓库

  2. 连接到 Railway → 新建项目 → 从 GitHub 部署

  3. 添加环境变量:

    • ANTHROPIC_API_KEY — 您的 Anthropic API 密钥

    • INVOICEPARSER_DATA_DIR — /data

    • STRIPE_WEBHOOK_SECRET — 从 Stripe 控制面板获取

    • STRIPE_PRO_PRICE_ID — 从 Stripe 控制面板获取

  4. 在 /data 处添加持久化卷

  5. 部署


本地运行 (可选 maxproxy 路由)

如果您在与 maxproxy 实例相同的机器上运行服务器(端口 3456),则可以通过它路由 Claude Vision 调用,而不是直接访问 Anthropic API:

ANTHROPIC_API_KEY=maxproxy
ANTHROPIC_BASE_URL=http://localhost:3456

在任何云/Railway 部署中,请保持 ANTHROPIC_BASE_URL 未设置(或为空)—— 这些环境无法访问本地代理。


贡献与安全

许可证

MIT — 版权所有 © 2025 Kenneth Nygren / Plenitudo AI

Related MCP Connectors

Related MCP Servers

Appeared in Searches