mcp-ksef-pl

v0.10.2
io.github.cmendezs/mcp-ksef-pl Checked 3 days ago Published 17 days ago

Polish e-invoicing MCP: KSeF API v2, FA(3)/FA(2) XML, Peppol BIS 3.0, NIP/REGON validation.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

generate_fa2_invoice Generate Fa2 Invoice

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 nip must be a Polish NIP (10 digits).

generate_fa3_invoice Generate Fa3 Invoice

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 nip must be a Polish NIP (10 digits). The buyer's nip may be a Polish NIP, eu_vat_country/eu_vat_id for EU cross-border, or neither (emits <BrakID>). Use the optional `options` parameter to supply: - IPKSeF / LinkDoPlatnosci payment identifiers (PL-2.2) - Correction invoice reference (rodzaj_faktury=KOR + correction block) (PL-4.1) - Supporting document a…

validate_fa2_invoice Validate Fa2 Invoice

Validate a KSeF FA(2) XML invoice. Runs XSD validation (when the official schema is present) and Polish business-rule checks. Returns a DocumentValidationResult with errors and warnings.

ParameterTypeDescription
xml_content *string

validate_fa3_invoice Validate Fa3 Invoice

Validate a KSeF FA(3) XML invoice before submission to KSeF API v2 (PL-6.2). Runs XSD validation against specs/schemat_FA(3)_v1-0E.xsd (requires lxml) and FA(3)-specific business-rule checks including namespace, mandatory Adnotacje sub-elements, JST/GV flags, and the absence of the FA(2) <FaWiersze> wrapper. Call this after generate_fa3_invoice and before submit_invoice_to_ksef. Returns a DocumentValidationResult with errors and warnings.

ParameterTypeDescription
xml_content *string

parse_fa2_invoice Parse Fa2 Invoice

Parse a KSeF FA(2) XML invoice into a structured dictionary. Returns a nested dict with 'header', 'seller', 'buyer', 'invoice', and 'lines' keys.

ParameterTypeDescription
xml_content *string

submit_invoice_to_ksef Submit Invoice To Ksef

Submit a FA(3) XML invoice to the KSeF platform (API v2). KSeF API v2 requires FA(3) format for submission. Use generate_fa3_invoice to produce FA(3) XML before calling this tool. HUMAN-IN-THE-LOOP: Call without confirmation_token first to receive a confirmation summary and token. Show the summary to the user, then call again with confirmation_token set to execute the actual submission.

ParameterTypeDescription
xml_content *string
confirmation_tokenstring
session_tokenstring Obtain via the challenge → authenticate → redeem flow: https://github.com/CIRFMF/ksef-docs/blob/main/uwierzytelnianie.md
session_token_expires_atstring A warning is logged if fewer than 60 seconds remain; submission is blocked if the token is already expired.

get_ksef_invoice_status Get Ksef Invoice Status

Retrieve the processing status of a submitted KSeF invoice (API v2).

ParameterTypeDescription
reference_number *string ("{sessionRef}:{invoiceRef}"). Pass just the sessionRef to retrieve the overall session status instead.

search_ksef_invoices Search Ksef Invoices

Query invoices stored in KSeF for a date range.

ParameterTypeDescription
date_from *string
date_to *string
subject_typestring or 'SubjectAuthorized' (authorised representative). Case-insensitive; normalized to the KSeF v2 PascalCase enum before submission.

validate_polish_nip Validate Polish Nip

Validate a Polish NIP (tax identification number). Applies the official 10-digit checksum algorithm. Accepts NIP with or without dashes/spaces. Returns {'valid': bool, 'nip': str, 'normalized': str}.

ParameterTypeDescription
nip *string

validate_polish_regon Validate Polish Regon

Validate a Polish REGON (business registry number — 9 or 14 digits). Returns {'valid': bool, 'regon': str, 'length': int}.

ParameterTypeDescription
regon *string

generate_peppol_invoice Generate Peppol Invoice

Generate a Peppol BIS Billing 3.0 / EN 16931 UBL 2.1 XML invoice. Use this for cross-border B2B invoicing via the Peppol network. For domestic Polish invoicing, use generate_fa3_invoice instead.

validate_peppol_invoice Validate Peppol Invoice

Validate a Peppol BIS 3.0 / EN 16931 UBL 2.1 XML invoice. Checks the CEN EN16931 base rules only (structural + arithmetic/totals, ~50 BR-* rules) via mcp-einvoicing-core's bundled Schematron validator. Does NOT check the Peppol-specific overlay (profile/process ID registration, EndpointID scheme, narrowed code lists) — the result's metadata.scope is "en16931-base-only", and a warning is included. This is not a full Peppol BIS3 conformance check; a document that passes may still be rejected by a real Peppol Access Point (no confirmed OpenPeppol redistribution rights for the overlay rules).…

ParameterTypeDescription
xml_content *string

peppol_lookup_participant Peppol Lookup Participant

Check whether a business is registered on the Peppol network. Performs a DNS-over-HTTPS U-NAPTR lookup followed by an SMP service-group request to determine registration status and the list of supported document type identifiers.

ParameterTypeDescription
identifier *stringPeppol participant ID ("<scheme>:<value>") or a bare national identifier this server knows how to adapt (e.g. a VAT number, if a national identifier adapter is configured).
environmentstring"production" or "test".

peppol_get_service_endpoint Peppol Get Service Endpoint

Fetch the AS4 endpoint for a Peppol participant's document type. Resolves the SMP hostname via DNS, then fetches service metadata for *document_type_id*. If the SMP returns a redirect, the result's `redirect_url` is set and `endpoint_url` is None; callers must not follow more than one redirect hop (SMP 1.4.0 §3.2).

ParameterTypeDescription
identifier *stringPeppol participant ID or adaptable national identifier.
document_type_idstringPeppol document type identifier URN (default: BIS Billing 3.0 invoice).
environmentstring"production" or "test".

resolve_peppol_dns Resolve Peppol Dns

Resolve the SMP hostname for a Peppol participant via DNS only. Performs the raw U-NAPTR (SML) lookup without fetching the SMP service group, useful for diagnosing whether a participant is registered in the SML independently of SMP reachability.

ParameterTypeDescription
identifier *stringPeppol participant ID or adaptable national identifier.
environmentstring"production" or "test".

peppol_send Peppol Send

Send a UBL/CII invoice to a Peppol participant via AS4. Looks up the recipient's AS4 endpoint (SMP), builds the ebMS3/AS4 envelope, and transmits it using the supplied signing credentials.

ParameterTypeDescription
certificate_path *stringPath to the PEM-encoded signing certificate.
invoice_xml_base64 *stringBase64-encoded UBL or CII invoice XML.
private_key_path *stringPath to the PEM-encoded private key.
recipient_identifier *stringPeppol participant ID or adaptable national identifier of the receiver.
sender_id *stringPeppol AP identifier of the sender.
document_type_idstringPeppol document type identifier URN (default: BIS Billing 3.0 invoice).
environmentstring"production" or "test".
private_key_passwordstringOptional password for the private key.

list_participant_id_schemes List Participant Id Schemes

List Peppol participant identifier (ICD) schemes from the OpenPeppol eDEC code list. Requires EINVOICING_PEPPOL_CODELIST_DIR to point at a local copy of the eDEC "Participant Identifier Schemes" GeneriCode export (not bundled with this package, no confirmed redistribution rights, see `mcp_einvoicing_core.peppol.codelists` module docstring).

ParameterTypeDescription
active_onlybooleanWhen True (default), omit deprecated/removed entries.

list_document_type_ids List Document Type Ids

List Peppol document type identifiers from the OpenPeppol eDEC code list. Requires EINVOICING_PEPPOL_CODELIST_DIR (see `list_participant_id_schemes`).

ParameterTypeDescription
active_onlybooleanWhen True (default), omit deprecated/removed entries.

list_process_ids List Process Ids

List Peppol process identifiers from the OpenPeppol eDEC code list. Requires EINVOICING_PEPPOL_CODELIST_DIR (see `list_participant_id_schemes`).

ParameterTypeDescription
active_onlybooleanWhen True (default), omit deprecated/removed entries.

list_spis_use_case_ids List Spis Use Case Ids

List Peppol SPIS use case identifiers from the OpenPeppol eDEC code list. Requires EINVOICING_PEPPOL_CODELIST_DIR (see `list_participant_id_schemes`).

ParameterTypeDescription
active_onlybooleanWhen True (default), omit deprecated/removed entries.

check_document_type_id_in_codelist Check Document Type Id In Codelist

Check whether a (scheme, value) pair is a recognized Peppol document type identifier. Requires EINVOICING_PEPPOL_CODELIST_DIR (see `list_participant_id_schemes`). Searches all entries regardless of state, so a historical (deprecated or removed) document type is still reported as found.

ParameterTypeDescription
scheme *string
value *string

check_process_id_in_codelist Check Process Id In Codelist

Check whether a (scheme, value) pair is a recognized Peppol process identifier. Requires EINVOICING_PEPPOL_CODELIST_DIR (see `list_participant_id_schemes`).

ParameterTypeDescription
scheme *string
value *string

check_participant_id_scheme_in_codelist Check Participant Id Scheme In Codelist

Check whether a 4-digit ISO 6523 ICD code (e.g. "0208") is a recognized Peppol scheme. Requires EINVOICING_PEPPOL_CODELIST_DIR (see `list_participant_id_schemes`).

ParameterTypeDescription
icd *string

get_peppol_codelist_version Get Peppol Codelist Version

Report the OpenPeppol eDEC code list release version(s) currently configured locally.

validate_eusr_report Validate Eusr Report

Validate a Peppol End User Statistics Report (EUSR) document. Runs XSD structural validation, then Schematron business rules (requires the ``[xslt2]`` optional extra).

ParameterTypeDescription
report_xml_base64 *stringBase64-encoded EUSR XML document.

validate_tsr_report Validate Tsr Report

Validate a Peppol Transaction Statistics Report (TSR) document. Runs XSD structural validation, then Schematron business rules (requires the ``[xslt2]`` optional extra).

ParameterTypeDescription
report_xml_base64 *stringBase64-encoded TSR XML document.

validate_mls_message Validate Mls Message

Validate a Peppol Message Level Status (MLS) document. Runs the bundled MLS Schematron rules (requires the ``[xslt2]`` optional extra). No bespoke MLS XSD exists — full UBL 2.1 XSD validation is out of scope.

ParameterTypeDescription
mls_xml_base64 *stringBase64-encoded MLS (UBL ApplicationResponse-2) XML.

build_mls_message Build Mls Message

Build a document-level MLS response and return it base64-encoded. For per-line responses, build the document directly with `mcp_einvoicing_core.peppol.mls.build_mls`.

ParameterTypeDescription
document_reference_id *stringThe SBDH ``InstanceIdentifier`` of the source message this MLS reports on.
issue_date *stringISO date string, e.g. "2026-08-23".
mls_id *stringThe ``cbc:ID`` of this MLS document.
receiver_scheme_id *stringICD scheme of the receiving endpoint (normally the original message's SBDH ``MLS_TO`` scheme).
receiver_value *stringReceiving endpoint value.
response_code *string"AB" (Acknowledged), "AP" (Accepted), or "RE" (Rejected).
sender_scheme_id *stringICD scheme of the sending Access Point's endpoint.
sender_value *stringSending Access Point's endpoint value.
descriptionstringOptional human-readable response text.
issue_timestringOptional ISO time string, e.g. "12:00:00Z".
status_reason_codestringOptional: "SV", "BV", "BW", or "FD" (required by the Schematron when response_code is "RE").

list_country_codes List Country Codes

List ISO 3166-1 alpha-2 country codes from the CEF EN 16931 code list.

check_country_code Check Country Code

Check whether *code* is a recognized ISO 3166-1 alpha-2 country code.

ParameterTypeDescription
code *string

list_currency_codes List Currency Codes

List ISO 4217 currency codes from the CEF EN 16931 code list.

check_currency_code Check Currency Code

Check whether *code* is a recognized ISO 4217 currency code.

ParameterTypeDescription
code *string

list_icd_codes List Icd Codes

List ISO 6523 ICD codes from the CEF EN 16931 code list.

check_icd_code Check Icd Code

Check whether *code* is a recognized ISO 6523 ICD code.

ParameterTypeDescription
code *string

list_document_name_codes List Document Name Codes

List UNCL1001 document name codes from the CEF EN 16931 code list.

check_document_name_code Check Document Name Code

Check whether *code* is a recognized UNCL1001 document name code.

ParameterTypeDescription
code *string

list_reference_qualifier_codes List Reference Qualifier Codes

List UNCL1153 reference qualifier codes from the CEF EN 16931 code list.

check_reference_qualifier_code Check Reference Qualifier Code

Check whether *code* is a recognized UNCL1153 reference qualifier code.

ParameterTypeDescription
code *string

list_payment_means_codes List Payment Means Codes

List UNCL4461 payment means codes from the CEF EN 16931 code list.

check_payment_means_code Check Payment Means Code

Check whether *code* is a recognized UNCL4461 payment means code.

ParameterTypeDescription
code *string

list_vat_category_codes List Vat Category Codes

List UNCL5305 VAT category codes from the CEF EN 16931 code list.

check_vat_category_code Check Vat Category Code

Check whether *code* is a recognized UNCL5305 VAT category code.

ParameterTypeDescription
code *string

list_allowance_reason_codes List Allowance Reason Codes

List allowance reason codes from the CEF EN 16931 code list.

check_allowance_reason_code Check Allowance Reason Code

Check whether *code* is a recognized allowance reason code.

ParameterTypeDescription
code *string

list_item_type_codes List Item Type Codes

List item type identification codes from the CEF EN 16931 code list.

check_item_type_code Check Item Type Code

Check whether *code* is a recognized item type identification code.

ParameterTypeDescription
code *string

list_charge_reason_codes List Charge Reason Codes

List charge reason codes from the CEF EN 16931 code list.

check_charge_reason_code Check Charge Reason Code

Check whether *code* is a recognized charge reason code.

ParameterTypeDescription
code *string

list_mime_codes List Mime Codes

List recognized MIME types for embedded attachments.

check_mime_code Check Mime Code

Check whether *code* is a recognized MIME type for embedded attachments.

ParameterTypeDescription
code *string

list_eas_codes List Eas Codes

List Electronic Address Scheme (EAS) codes from the CEF EN 16931 code list.

check_eas_code Check Eas Code

Check whether *code* is a recognized Electronic Address Scheme code.

ParameterTypeDescription
code *string

list_vatex_codes List Vatex Codes

List VATEX (VAT exemption reason) codes from the CEF EN 16931 code list.

check_vatex_code Check Vatex Code

Check whether *code* is a recognized VATEX VAT exemption reason code.

ParameterTypeDescription
code *string

get_en16931_codelist_version Get En16931 Codelist Version

Report the CEF EN 16931 code-list release version(s) currently configured locally.