Skip to main content
Glama

Read invoice

read_invoice
Read-onlyIdempotent

Parse one European or UAE (PINT AE) e-invoice into canonical EN 16931 JSON and validate it against the official rule sets in the same call. Use it when you need the invoice content (seller, buyer, lines, totals, payment) together with the verdict; use validate_invoice for a verdict-only answer, invoice_to_html / invoice_to_csv / invoice_to_datev for renderings. Input: XML (UBL, CII, XRechnung, Peppol BIS 3, UAE PINT AE, FatturaPA, KSeF FA(2)/FA(3)) or a ZUGFeRD/Factur-X hybrid PDF up to 25 MB; plain or scanned PDFs without embedded XML are rejected (no OCR). Returns the parsed invoice, the validation report with fix hints in lang, and timings; an unreadable file returns ok=false with error.code/message/hint instead of raising. A FatturaPA lot returns only its first invoice, with a note. For a Polish KSeF invoice, pass the KSeF number in ksef: it is checked against the invoice and returned on payment.ksef_number. Costs one invoice credit per call; without an API key the anonymous quota is 5 invoices per day per IP (a free key gives 100: https://invoicein.peculiar.systems/#get). Nothing is stored.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "file_base64": "<file_base64>"
    },
    "name": "read_invoice"
  }
}

Input Schema

NameRequiredDescriptionDefault
ksefNoPoland only: the KSeF number the National e-Invoice System gave this invoice — 35 characters, NNNNNNNNNN-RRRRMMDD-FFFFFFFFFFFF-FF — or the collective identifier covering it (NNNNNNNNNN-IZRRRRMM-FFFFFFFFFFFF-FF). KSeF assigns it on acceptance, so it is never inside the FA(2)/FA(3) XML: it arrives beside the invoice in the KSeF API response, the UPO or the QR code on a visualisation. Pass it and it is checked against the invoice and returned on payment.ksef_number, the reference a Polish buyer must quote in the bank transfer title from 2027-01-01. Leave empty for invoices from any other country.
langNoLanguage of the fix hints in the validation report and of the labels in HTML output. Default en.en
file_base64YesInvoice file content, base64-encoded (standard alphabet). Accepted content: XML in UBL 2.1, CII D16B, XRechnung, Peppol BIS Billing 3, FatturaPA 1.2 or KSeF FA(2)/FA(3) syntax, or a ZUGFeRD 1.0/2.x or Factur-X hybrid PDF (the embedded XML is used). Max 25 MB decoded. The hosted server cannot open files on your machine: read the file and send its bytes here.

Output Schema

NameRequiredDescriptionDefault
okYesFalse when the file could not be read; then only `error` is set
noteNoSet when the file is a lot of several invoices: only the first is returned
errorNoPresent when ok is false: code, message, hint
sourceNoDetected syntax, format, profile and container
creditsNoWhat this call cost on the hosted server: mode (key or demo) and remaining; without an API key also the daily limit and a note saying where the free key is. Absent when the server runs locally.
invoiceNoCanonical EN 16931 JSON: document, seller, buyer, lines, tax_breakdown, totals, payment, attachments, extensions; field names carry BT/BG numbers in /v1/schema
timings_msNoProcessing time per stage: detect, map, validate, total
validationNo

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed5 schema fields changed
    • removedInput schema / properties / file_base64 / default
      Removed value: -""
    • changedInput schema / properties / file_base64 / description
      Previous value: -"Invoice file content, base64-encoded (standard alphabet). Accepted content: XML in UBL 2.1, CII D16B, XRechnung, Peppol BIS Billing 3, FatturaPA 1.2 or KSeF FA(2)/FA(3) syntax, or a ZUGFeRD 1.0/2.x or Factur-X hybrid PDF (the embedded XML is used). Max 25 MB decoded. Required unless `path` is given."New value: +"Invoice file content, base64-encoded (standard alphabet). Accepted content: XML in UBL 2.1, CII D16B, XRechnung, Peppol BIS Billing 3, FatturaPA 1.2 or KSeF FA(2)/FA(3) syntax, or a ZUGFeRD 1.0/2.x or Factur-X hybrid PDF (the embedded XML is used). Max 25 MB decoded. The hosted server cannot open files on your machine: read the file and send its bytes here."
    • removedInput schema / properties / path
      Removed value: -{
      -  "default": "",
      -  "description": "Absolute path of the invoice file on the machine running the server, used instead of file_base64. Only honoured over stdio (`python -m invoicein.mcp_server`); the hosted server at invoicein-api.peculiar.systems ignores it and answers with an error asking for file_base64.",
      -  "title": "Path",
      -  "type": "string"
      -}
    • addedInput schema / required
      Added value: +[
      +  "file_base64"
      +]
    • addedOutput schema / properties / credits
      Added value: +{
      +  "anyOf": [
      +    {
      +      "additionalProperties": true,
      +      "type": "object"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "What this call cost on the hosted server: mode (key or demo) and remaining; without an API key also the daily limit and a note saying where the free key is. Absent when the server runs locally.",
      +  "title": "Credits"
      +}
  2. Changed1 schema field changed
    • addedOutput schema / $defs / Validation / properties / coverage
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": "rules",
      +  "description": "'rules' when the business-rule sets ran and `valid` is a verdict; 'schema' when only XSD and arithmetic could run (profile below EN 16931, ZUGFeRD 1.0, FatturaPA, KSeF, unsupported PINT jurisdiction, or Schematron skipped for size) — then valid=true means 'nothing we could check failed', not 'conforms'",
      +  "title": "Coverage"
      +}
  3. Changed1 schema field changed
    • addedInput schema / properties / ksef
      Added value: +{
      +  "default": "",
      +  "description": "Poland only: the KSeF number the National e-Invoice System gave this invoice — 35 characters, NNNNNNNNNN-RRRRMMDD-FFFFFFFFFFFF-FF — or the collective identifier covering it (NNNNNNNNNN-IZRRRRMM-FFFFFFFFFFFF-FF). KSeF assigns it on acceptance, so it is never inside the FA(2)/FA(3) XML: it arrives beside the invoice in the KSeF API response, the UPO or the QR code on a visualisation. Pass it and it is checked against the invoice and returned on payment.ksef_number, the reference a Polish buyer must quote in the bank transfer title from 2027-01-01. Leave empty for invoices from any other country.",
      +  "title": "Ksef",
      +  "type": "string"
      +}
  4. Changed22 schema fields changed
    • removedInput schema / properties / file_base64 / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • changedInput schema / properties / file_base64 / default
      Previous value: -nullNew value: +""
    • changedInput schema / properties / file_base64 / description
      Previous value: -"The invoice file, base64-encoded: XML (UBL, CII, XRechnung, Peppol, FatturaPA, KSeF FA(3)) or a ZUGFeRD/Factur-X hybrid PDF. Up to 25 MB decoded."New value: +"Invoice file content, base64-encoded (standard alphabet). Accepted content: XML in UBL 2.1, CII D16B, XRechnung, Peppol BIS Billing 3, FatturaPA 1.2 or KSeF FA(2)/FA(3) syntax, or a ZUGFeRD 1.0/2.x or Factur-X hybrid PDF (the embedded XML is used). Max 25 MB decoded. Required unless `path` is given."
    • addedInput schema / properties / file_base64 / type
      Added value: +"string"
    • changedInput schema / properties / lang / description
      Previous value: -"Language of the fix hints and rendering labels: en, de, pl, it or fr."New value: +"Language of the fix hints in the validation report and of the labels in HTML output. Default en."
    • addedInput schema / properties / lang / enum
      Added value: +[
      +  "en",
      +  "de",
      +  "pl",
      +  "it",
      +  "fr"
      +]
    • removedInput schema / properties / lang / pattern
      Removed value: -"^(en|de|pl|it|fr)$"
    • removedInput schema / properties / path / anyOf
      Removed value: -[
      -  {
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]
    • changedInput schema / properties / path / default
      Previous value: -nullNew value: +""
    • changedInput schema / properties / path / description
      Previous value: -"Local file path instead of file_base64; only honoured when the server runs over stdio on the same machine."New value: +"Absolute path of the invoice file on the machine running the server, used instead of file_base64. Only honoured over stdio (`python -m invoicein.mcp_server`); the hosted server at invoicein-api.peculiar.systems ignores it and answers with an error asking for file_base64."
    • addedInput schema / properties / path / type
      Added value: +"string"
    • addedOutput schema / $defs / Validation / properties / errors / description
      Added value: +"Number of failed rules with severity error"
    • addedOutput schema / $defs / Validation / properties / issues / description
      Added value: +"Failed rules, each with a fix hint"
    • addedOutput schema / $defs / Validation / properties / notes / description
      Added value: +"Informational notes about the validation run"
    • changedOutput schema / $defs / Validation / properties / rule_sets / description
      Previous value: -"Rule sets applied, with versions"New value: +"Rule sets applied, with versions (XSD, EN 16931, XRechnung, Peppol, FatturaPA, KSeF, arithmetic)"
    • addedOutput schema / $defs / Validation / properties / valid / description
      Added value: +"True when no rule of severity error failed"
    • addedOutput schema / $defs / Validation / properties / warnings / description
      Added value: +"Number of failed rules with severity warning"
    • changedOutput schema / properties / invoice / description
      Previous value: -"Canonical EN 16931 JSON: document, seller, buyer, lines, tax_breakdown, totals, payment, attachments, extensions"New value: +"Canonical EN 16931 JSON: document, seller, buyer, lines, tax_breakdown, totals, payment, attachments, extensions; field names carry BT/BG numbers in /v1/schema"
    • addedOutput schema / properties / note
      Added value: +{
      +  "anyOf": [
      +    {
      +      "type": "string"
      +    },
      +    {
      +      "type": "null"
      +    }
      +  ],
      +  "default": null,
      +  "description": "Set when the file is a lot of several invoices: only the first is returned",
      +  "title": "Note"
      +}
    • addedOutput schema / properties / ok / description
      Added value: +"False when the file could not be read; then only `error` is set"
    • addedOutput schema / properties / source / description
      Added value: +"Detected syntax, format, profile and container"
    • addedOutput schema / properties / timings_ms / description
      Added value: +"Processing time per stage: detect, map, validate, total"
  5. First observed

TDQS

A4.8/5.0
Behavior5/5

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

Goes well beyond the readOnly/idempotent/destructive annotations: 25 MB decoded limit, no OCR fallback, unreadable files returning ok=false with error.code/message/hint instead of raising, FatturaPA lots yielding only the first invoice with a note, and a KSeF cross-check. It even discloses cost and quota mechanics (one invoice credit per call, 5/day anonymous per IP, 100 with a free key) and that nothing is stored — exactly the operational context an agent cannot get from structured fields.

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?

Front-loaded with the core verb and the sibling routing before the input/return/cost details, and each sentence carries distinct information. It is dense — the pricing, quota and URL detail sits close to essential parsing constraints — but no sentence is filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Even though an output schema exists, the description still sketches the return shape (parsed invoice, validation report with localized fix hints, timings, ok=false error path). Combined with accepted-format coverage and the KSeF nuances, nothing an agent needs to call this correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the baseline is 3, but the description adds routing meaning: it tells the agent to pass the KSeF number in `ksef` for Polish invoices and that `lang` governs fix-hint language and HTML labels. It stops short of restating formats or edge cases for those parameters, which the schema already handles well.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb and resource — parse one European/UAE e-invoice into canonical EN 16931 JSON and validate it in the same call — and immediately distinguishes itself from verdict-only and rendering siblings. An agent can tell exactly what this does versus validate_invoice or invoice_to_html without opening any schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly says when to use it (need invoice content plus the verdict) and names the alternatives with their selecting conditions: validate_invoice for verdict-only, invoice_to_html/csv/datev for renderings. It also states the rejection condition (plain or scanned PDFs without embedded XML, no OCR), so the agent knows when not to call it.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.