Skip to main content
Glama
mcp-ksef-pl

mcp-ksef-pl

Generate Fa2 Invoice

generate_fa2_invoice

Generates a KSeF-compliant FA(2) XML invoice from structured invoice data and returns the XML string ready for submission to KSeF.

Instructions

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

Returns the FA(2) XML string ready for submission to KSeF. The seller's tax_id must be a Polish NIP (10 digits).

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_fa2_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.0
Behavior3/5

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

No annotations are supplied, so the description carries the full burden. It does disclose the return artifact (FA(2) XML string ready for submission) and the hard constraint that the seller tax_id must be a Polish NIP (10 digits), which is genuinely non-obvious behavior. It omits whether the tool cross-validates totals/VAT or is purely a serializer, and whether any state is written – gaps that matter for a generation tool with no annotation coverage.

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?

Three short sentences, front-loaded with the action and followed by the return value and the key constraint. The return-value sentence mildly overlaps the output schema, but it is a single clause and does not bloat the definition.

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?

Given an output schema exists and the deeply nested input schema is fully documented, the description only needs to pin down output form and the Poland-specific constraint – and it does both. Nothing an agent needs in order to call it 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% and the nested invoice model is thoroughly self-documented, so the baseline is 3. The description adds real meaning beyond the schema by narrowing the otherwise country-agnostic tax_id to a 10-digit Polish NIP for the seller, a constraint the schema does not express.

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 (generate) and a specific resource (FA(2) XML invoice), plus the compliance target (KSeF). The FA(2)/KSeF framing distinguishes it from the sibling generators for FA(3) and Peppol without needing to name them.

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

Usage Guidelines3/5

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

The Polish-NIP requirement implicitly signals this is the KSeF/Poland path, which is useful routing context. However, it never explicitly says when to choose this over generate_fa3_invoice or generate_peppol_invoice, nor does it state prerequisites like authentication or required pre-validation.

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