Skip to main content
Glama
mcp-ksef-pl

mcp-ksef-pl

Generate Fa3 Invoice

generate_fa3_invoice

Create a KSeF-compliant FA(3) XML invoice from structured invoice data, ready for submission through KSeF API v2.

Instructions

Generate a KSeF-compliant FA(3) XML invoice from structured invoice data.

FA(3) is required for all new invoice submissions via KSeF API v2. Use this tool — not generate_fa2_invoice — before calling submit_invoice_to_ksef.

The seller's tax_id must be a Polish NIP (10 digits). The buyer's tax_id may be a Polish NIP, a EU VAT number (set alt_tax_id), or absent (leave tax_id.identifier empty to emit ).

Returns the FA(3) XML string ready for submit_invoice_to_ksef.

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": {
      "invoice": "<invoice>"
    },
    "name": "generate_fa3_invoice"
  }
}

Input Schema

NameRequiredDescriptionDefault
invoiceYesCountry-agnostic invoice document envelope. Country adapters read/write this model via BaseDocumentGenerator.generate() and BaseDocumentParser.to_invoice_document(). document_type: Country-specific code (IT: TD01–TD28, UBL: 380/381/384, DE: RE/GU…). transmission_format: Platform routing hint (IT: FPA12/FPR12, FR: B2B/B2BInt/B2C).

Output Schema

NameRequiredDescriptionDefault
resultYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed8 schema fields changedv0.10.2
    • changedInput schema / properties / invoice / properties / lines / items / properties / quantity / anyOf
      Previous value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      -    "type": "string"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "type": "number"
      +  },
      +  {
      +    "type": "string"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / properties / invoice / properties / lines / items / properties / total_price / anyOf
      Previous value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "type": "number"
      +  },
      +  {
      +    "type": "string"
      +  }
      +]
    • changedInput schema / properties / invoice / properties / lines / items / properties / unit_price / anyOf
      Previous value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "type": "number"
      +  },
      +  {
      +    "type": "string"
      +  }
      +]
    • changedInput schema / properties / invoice / properties / lines / items / properties / vat_rate / anyOf
      Previous value: -[
      -  {
      -    "maximum": 100,
      -    "minimum": 0,
      -    "type": "number"
      -  },
      -  {
      -    "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "maximum": 100,
      +    "minimum": 0,
      +    "type": "number"
      +  },
      +  {
      +    "type": "string"
      +  }
      +]
    • changedInput schema / properties / invoice / properties / payment / anyOf
      Previous value: -[
      -  {
      -    "description": "Payment terms and method.\n\nMaps to IT DatiPagamento, UBL PaymentMeans, ZUGFeRD ram:SpecifiedTradePaymentTerms.\n\n[AMBIGUITY: IT uses structured codes (TP01/02/03 + MP01-23). UBL and ZUGFeRD use\n free-text terms + UNCL4461 payment means codes. The base model uses free-form\n strings to remain format-neutral; country validators enforce their own code sets.]\nOption A: Store raw country codes → simpler, no translation layer needed.\nOption B: Use enums mapped per country → more type-safe but requires maintenance.\nChosen: Option A (raw strings). Rationale: code sets vary significantly (IT has 23\npayment methods, UBL UNCL4461 has 70+).",
      -    "properties": {
      -      "amount": {
      -        "anyOf": [
      -          {
      -            "type": "number"
      -          },
      -          {
      -            "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      -            "type": "string"
      -          }
      -        ],
      -        "description": "Payment amount"
      -      },
      -      "bank_name": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Financial institution name"
      -      },
      -      "bic": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "BIC/SWIFT code for international transfers"
      -      },
      -      "due_date": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Payment due date (YYYY-MM-DD)"
      -      },
      -      "iban": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "IBAN for bank transfers (validated by xml_utils.validate_iban)"
      -      },
      -      "payment_method_code": {
      -        "description": "Country-specific payment method code (IT: MP01-23, UBL: UNCL4461)",
      -        "type": "string"
      -      },
      -      "payment_terms_code": {
      -        "anyOf": [
      -          {
      -            "type": "string"
      -          },
      -          {
      -            "type": "null"
      -          }
      -        ],
      -        "default": null,
      -        "description": "Country-specific payment terms code (IT: TP01/02/03, ES: contado/plazo)"
      -      }
      -    },
      -    "required": [
      -      "payment_method_code",
      -      "amount"
      -    ],
      -    "type": "object"
      -  },
      -  {
      -    "type": "null"
      -  }
      -]New value: +[
      +  {
      +    "description": "Payment terms and method.\n\nMaps to IT DatiPagamento, UBL PaymentMeans, ZUGFeRD ram:SpecifiedTradePaymentTerms.\n\n[AMBIGUITY: IT uses structured codes (TP01/02/03 + MP01-23). UBL and ZUGFeRD use\n free-text terms + UNCL4461 payment means codes. The base model uses free-form\n strings to remain format-neutral; country validators enforce their own code sets.]\nOption A: Store raw country codes → simpler, no translation layer needed.\nOption B: Use enums mapped per country → more type-safe but requires maintenance.\nChosen: Option A (raw strings). Rationale: code sets vary significantly (IT has 23\npayment methods, UBL UNCL4461 has 70+).",
      +    "properties": {
      +      "amount": {
      +        "anyOf": [
      +          {
      +            "type": "number"
      +          },
      +          {
      +            "type": "string"
      +          }
      +        ],
      +        "description": "Payment amount"
      +      },
      +      "bank_name": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Financial institution name"
      +      },
      +      "bic": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "BIC/SWIFT code for international transfers"
      +      },
      +      "due_date": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Payment due date (YYYY-MM-DD)"
      +      },
      +      "iban": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "IBAN for bank transfers (validated by xml_utils.validate_iban)"
      +      },
      +      "payment_method_code": {
      +        "description": "Country-specific payment method code (IT: MP01-23, UBL: UNCL4461)",
      +        "type": "string"
      +      },
      +      "payment_terms_code": {
      +        "anyOf": [
      +          {
      +            "type": "string"
      +          },
      +          {
      +            "type": "null"
      +          }
      +        ],
      +        "default": null,
      +        "description": "Country-specific payment terms code (IT: TP01/02/03, ES: contado/plazo)"
      +      }
      +    },
      +    "required": [
      +      "payment_method_code",
      +      "amount"
      +    ],
      +    "type": "object"
      +  },
      +  {
      +    "type": "null"
      +  }
      +]
    • changedInput schema / properties / invoice / properties / vat_summary / items / properties / taxable_base / anyOf
      Previous value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "type": "number"
      +  },
      +  {
      +    "type": "string"
      +  }
      +]
    • changedInput schema / properties / invoice / properties / vat_summary / items / properties / vat_amount / anyOf
      Previous value: -[
      -  {
      -    "type": "number"
      -  },
      -  {
      -    "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "type": "number"
      +  },
      +  {
      +    "type": "string"
      +  }
      +]
    • changedInput schema / properties / invoice / properties / vat_summary / items / properties / vat_rate / anyOf
      Previous value: -[
      -  {
      -    "maximum": 100,
      -    "minimum": 0,
      -    "type": "number"
      -  },
      -  {
      -    "pattern": "^(?!^[-+.]*$)[+-]?0*\\d*\\.?\\d*$",
      -    "type": "string"
      -  }
      -]New value: +[
      +  {
      +    "maximum": 100,
      +    "minimum": 0,
      +    "type": "number"
      +  },
      +  {
      +    "type": "string"
      +  }
      +]
  2. First observedv0.0.1

TDQS

A4.5/5.0
Behavior4/5

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

With no annotations, the description carries the full burden and does well: it discloses that the tool only produces an XML string and does not submit anything (submission is delegated to submit_invoice_to_ksef), and it spells out validation rules the agent must satisfy before calling (seller NIP must be 10 Polish digits; buyer identifier variants including emitting <BrakID>). It stops short of describing failure behavior or what happens if the NIP check fails, which keeps it from a 5.

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?

Five short lines, front-loaded with the purpose, then workflow routing, then identifier rules. Every sentence carries information, though submit_invoice_to_ksef is referenced twice and the final "Returns the FA(3) XML string" line partly repeats the opening sentence, a small redundancy in an otherwise tight definition.

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

Completeness4/5

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

For a complex nested payload with an output schema, the description covers the routing decision, the key party-identifier rules, and the return artifact, which is enough to call it correctly. It omits error/validation-failure behavior and any note on line/VAT-summary consistency, minor gaps given the schema and output schema already exist.

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 description coverage is 100%, so the schema already documents the nested invoice model; the baseline would be 3. The description earns above baseline by adding business constraints absent from the schema: the seller tax_id must be a Polish NIP of exactly 10 digits, the buyer may carry a Polish NIP, an EU VAT number via alt_tax_id, or an empty identifier to emit <BrakID>. That is real semantic guidance beyond the field descriptions.

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?

The first sentence gives a specific verb (Generate), resource (FA(3) XML invoice), input (structured invoice data) and standard (KSeF-compliant). It explicitly names the sibling it replaces (generate_fa2_invoice), so the agent can separate this from the FA(2) generator without opening either 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?

It states an explicit exclusion ("not generate_fa2_invoice"), a mandatory workflow ordering (call before submit_invoice_to_ksef), and the regulatory condition that drives selection (FA(3) required for all new submissions via KSeF API v2). Nothing about when to pick this tool is left to inference.

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