Skip to main content
Glama
cmendezs

mcp-ksef-pl

mcp-ksef-pl ๐Ÿ‡ต๐Ÿ‡ฑ

English | Polski

License PyPI version Python mcp-ksef-pl MCP server

A Python MCP server providing tools for Polish electronic invoicing compliant with KSeF (FA(2)) and Peppol BIS Billing 3.0 / EN 16931. It enables AI agents (Claude, IDEs) to generate, validate, and submit invoices to the Krajowy System e-Faktur (KSeF), as well as validate Polish tax identifiers (NIP and REGON).


Introduction

This package is built on mcp-einvoicing-core, the shared base library for European e-invoicing MCP servers. It provides an OAuth2 HTTP client, token cache, data models, logging utilities, and an exception hierarchy.

mcp-einvoicing-core is installed automatically as a dependency, no additional step is required.

Related MCP server: mcp-fattura-elettronica-it

Installation

pip install mcp-ksef-pl

Or without prior installation using uvx:

uvx mcp-ksef-pl

From source

git clone https://github.com/cmendezs/mcp-ksef-pl.git
cd mcp-ksef-pl
uv sync --all-extras

Configuration (environment variables)

Variable

Default

Description

KSEF_ENVIRONMENT

test

KSeF environment: production or test

KSEF_SESSION_TOKEN

โ€”

KSeF session token (obtained through the challenge-response flow with MF)

KSEF_NIP

โ€”

NIP of the entity submitting invoices

KSEF_TIMEOUT

30

HTTP request timeout in seconds

KSEF_VERIFY_MF_KEY_PINNING

false

Enforce SPKI SHA-256 pinning on the MF encryption certificate. No-op until fingerprints are populated for the active environment, even when set to true

EINVOICING_PEPPOL_CODELIST_DIR

โ€”

Local directory containing your own copy of the OpenPeppol eDEC Code Lists, required by the Peppol codelist tools (not bundled with this package; see mcp-einvoicing-core README)

EINVOICING_EN16931_CODELIST_DIR

โ€”

Local directory containing your own copy of the CEF "Digital Building Blocks" EN 16931 semantic code lists, required by the EN 16931 codelist tools (not bundled; see mcp-einvoicing-core README)

The EUSR/TSR reporting and MLS tools additionally require the [xslt2] extra (pip install "mcp-ksef-pl[xslt2]") for Schematron validation.

Claude Desktop integration

Add the following configuration to your claude_desktop_config.json file:

{
  "mcpServers": {
    "ksef-pl": {
      "command": "uvx",
      "args": ["mcp-ksef-pl"],
      "env": {
        "KSEF_ENVIRONMENT": "test",
        "KSEF_SESSION_TOKEN": "<your-ksef-session-token>",
        "KSEF_NIP": "<your-nip>"
      }
    }
  }
}

Cursor integration

Cursor supports MCP servers via stdio. Add the configuration to:

  • Globally (all projects): ~/.cursor/mcp.json

  • Per project (this repository only): .cursor/mcp.json

{
  "mcpServers": {
    "ksef-pl": {
      "command": "uvx",
      "args": ["mcp-ksef-pl"],
      "env": {
        "KSEF_ENVIRONMENT": "test",
        "KSEF_SESSION_TOKEN": "<your-ksef-session-token>",
        "KSEF_NIP": "<your-nip>"
      }
    }
  }
}

Reload the Cursor window (Ctrl+Shift+P โ†’ Reload Window) after saving changes.

Kiro integration

Kiro supports MCP servers through a dedicated configuration file:

  • Globally: ~/.kiro/settings/mcp.json

  • Workspace: .kiro/settings/mcp.json

{
  "mcpServers": {
    "ksef-pl": {
      "command": "uvx",
      "args": ["mcp-ksef-pl"],
      "env": {
        "KSEF_ENVIRONMENT": "test",
        "KSEF_SESSION_TOKEN": "<your-ksef-session-token>",
        "KSEF_NIP": "<your-nip>"
      },
      "disabled": false,
      "autoApprove": []
    }
  }
}

Security tip: instead of entering the token directly, use the syntax "KSEF_SESSION_TOKEN": "${KSEF_SESSION_TOKEN}", as Kiro resolves shell environment variables at startup.

Available tools

FA(3) / FA(2) invoice handling

Tool

Description

generate_fa3_invoice

Generates a KSeF-compliant FA(3) XML invoice (required for KSeF API v2 submissions)

generate_fa2_invoice

Generates a KSeF-compliant FA(2) XML invoice (legacy format, read-only use)

validate_fa3_invoice

Validates FA(3) XML: XSD validation and FA(3)-specific business rules

validate_fa2_invoice

Validates FA(2) XML: XSD validation (if the schema is available) and business rules

parse_fa2_invoice

Parses FA(2) XML into a structured dictionary

The official FA(2) and FA(3) XSD schemas ship inside the package (src/mcp_ksef_pl/schemas/) and are loaded automatically via importlib.resources โ€” no manual download or configuration is required. validate_fa2_invoice and validate_fa3_invoice run full XSD validation out of the box for every installation.

KSeF lifecycle

Tool

Description

submit_invoice_to_ksef

Submits an FA(3) invoice to the KSeF platform and returns a reference number

get_ksef_invoice_status

Retrieves the processing status of an invoice by its reference number

search_ksef_invoices

Searches invoices in KSeF by date range and direction (seller/buyer)

Identifier validation

Tool

Description

validate_polish_nip

Validates a NIP (10-digit tax identification number) using a checksum algorithm

validate_polish_regon

Validates a REGON (9- or 14-digit registry number) using a checksum algorithm

Peppol / EN 16931

Tool

Description

generate_peppol_invoice

Generates a UBL 2.1 invoice compliant with Peppol BIS Billing 3.0 / EN 16931

validate_peppol_invoice

Validates a UBL 2.1 Peppol invoice against the CEN EN 16931 base Schematron rules (en16931-base-only scope โ€” does not check the Peppol-specific overlay)

Peppol network tools

Peppol participant lookup, service-endpoint lookup, a DNS-only diagnostic, AS4 send, Peppol Directory search, and the OpenPeppol eDEC codelist tools are provided by the shared core Peppol tool plugin (mcp_einvoicing_core.peppol.tools.register_peppol_tools), mounted in server.py with a Poland-specific identifier adapter: a bare NIP (e.g. 1234563218) is normalized to the 9945:<digits> Peppol scheme (PL:VAT, per the OpenPeppol eDEC Participant Identifier Schemes code list); an already scheme-qualified identifier (e.g. 9945:1234563218) passes through unchanged. Use these tools to check PEF (Poland's Peppol Access Point for public-procurement B2G invoicing) registration status ahead of generate_peppol_invoice.

peppol_send signs outbound messages with a real wsse:Security signature as of mcp-einvoicing-core v1.20.0 (previously computed and discarded โ€” see CHANGELOG.md v0.8.0).

Tool

Description

peppol_lookup_participant

Check whether a business is registered on the Peppol network; returns registration status and supported document types

peppol_get_service_endpoint

Fetch the AS4 endpoint for a participant's document type

resolve_peppol_dns

DNS-only (SML) diagnostic, independent of SMP reachability

peppol_send

Transmit a UBL/CII invoice via AS4

peppol_directory_search

Search the public Peppol Directory by participant, name, country, or document type

list_participant_id_schemes, list_document_type_ids, list_process_ids, list_spis_use_case_ids

OpenPeppol eDEC codelist lookups (require EINVOICING_PEPPOL_CODELIST_DIR)

check_document_type_id_in_codelist, check_process_id_in_codelist, check_participant_id_scheme_in_codelist, get_peppol_codelist_version

OpenPeppol eDEC codelist checks and version reporting

See the mcp-einvoicing-core README for full parameter documentation on these tools.

Peppol reporting and status tools

Added in v0.8.0 via three opt-in core plugins, mounted unconditionally in server.py. Each raises a clear error at call time (not at registration) if its extra or data directory is missing.

Tool

Plugin

Description

validate_eusr_report

register_peppol_reporting_tools

Validate an End User Statistics Report (XSD, then Schematron). Requires the [xslt2] extra.

validate_tsr_report

register_peppol_reporting_tools

Validate a Transaction Statistics Report (XSD, then Schematron). Requires the [xslt2] extra.

validate_mls_message

register_peppol_mls_tools

Validate a Message Level Status document (UBL ApplicationResponse-2 subset). Requires the [xslt2] extra.

build_mls_message

register_peppol_mls_tools

Build a document-level MLS response. Requires the [xslt2] extra.

13 list_*/check_* pairs, get_en16931_codelist_version

register_en16931_codelist_tools

EN 16931 semantic code list lookups/checks (units, VAT categories, etc.). Require EINVOICING_EN16931_CODELIST_DIR.

See the mcp-einvoicing-core README for full parameter documentation on these tools.

KSeF authentication

KSeF API v2 uses a multi-step challenge/redeem flow to issue an AccessToken. This MCP server accepts an already-obtained token and cannot automate the signing step (it requires a qualified electronic signature).

Step-by-step flow

  1. Account setup. Register at the KSeF portal: https://ksef.mf.gov.pl/. Select the target environment (test or production). The test environment is at https://ksef-test.mf.gov.pl/.

  2. Request a challenge. Call the KSeF API to obtain a challenge XML envelope:

    curl -s https://ksef-test.mf.gov.pl/auth/challenge \
      -H "Accept: application/json" \
      -d '{"contextIdentifier": {"type": "onip", "identifier": "YOUR_NIP"}}' \
      -H "Content-Type: application/json"

    The response contains a challenge string and a timestamp.

  3. Sign the challenge. Build an <InitSessionTokenRequest> XML envelope containing the challenge, then sign it with your qualified e-signature. Accepted signing tools:

    • Qualified e-signature providers: KIR (Szafir), Certum, Sigillum

    • podpis.gov.pl (government signing portal)

    • Profil Zaufany (Trusted Profile): https://www.podatki.gov.pl/ksef/

    Example using xmlsec1 with a PKCS#12 certificate:

    # Build the challenge XML (template at specs/przyklad-wyzwania.xml)
    xmlsec1 --sign --pkcs12 your-cert.p12 --pwd "password" \
      --output signed-challenge.xml challenge-template.xml
  4. Submit the signed challenge. POST the signed XML to receive an authOperation reference:

    curl -s https://ksef-test.mf.gov.pl/auth/xades-signature \
      -H "Content-Type: application/octet-stream" \
      --data-binary @signed-challenge.xml
  5. Redeem the AccessToken. Exchange the authenticated operation for an AccessToken:

    curl -s https://ksef-test.mf.gov.pl/auth/token/redeem \
      -H "Content-Type: application/json" \
      -H "Authorization: Bearer <referenceNumber-or-authOperation-token-from-step-4>"

    The response contains accessToken.token and accessToken.context.referenceNumber.

  6. Set the token. Export the token for this MCP server:

    export KSEF_SESSION_TOKEN="<the AccessToken from step 5>"

    The token is valid for approximately 2 hours from issuance (per MF documentation). After expiry, repeat steps 2-5.

References

Architecture

The server acts as an intelligent communication interface between the AI agent and the KSeF platform and the Peppol network:

[ ERP System / Application ] <--> [ MCP Server ] <--> [ KSeF (MF) / Peppol Network ]
          ^                           |
          |                           v
   [ AI Agent (Claude) ] <--- (FA(2) / EN 16931)

Vendor neutrality

This server implements the standard itself: it builds, validates, and signs the document locally. It is not a client for a commercial invoicing platform, and your signing keys and credentials never leave your own infrastructure.

Invoices go directly to KSeF with your own authentication token; no intermediary is involved.

Tests

# Run unit tests
uv run pytest tests/ -v

Contributing

Contributions are welcome โ€” see CONTRIBUTING.md for guidelines.

Other e-invoicing MCP servers

Country

Server

๐ŸŒ Global

mcp-einvoicing-core

๐Ÿ‡ง๐Ÿ‡ช Belgium

mcp-einvoicing-be

๐Ÿ‡ง๐Ÿ‡ท Brazil

mcp-nfe-br

๐Ÿ‡ซ๐Ÿ‡ท France

mcp-facture-electronique-fr

๐Ÿ‡ฉ๐Ÿ‡ช Germany

mcp-einvoicing-de

๐Ÿ‡ฎ๐Ÿ‡ณ India

mcp-einvoicing-in

๐Ÿ‡ฎ๐Ÿ‡น Italy

mcp-fattura-elettronica-it

๐Ÿ‡ฒ๐Ÿ‡ฝ Mexico

mcp-cfdi-mx

๐Ÿ‡ต๐Ÿ‡ฑ Poland

mcp-ksef-pl

๐Ÿ‡ธ๐Ÿ‡ฌ Singapore

mcp-invoicenow-sg

๐Ÿ‡ช๐Ÿ‡ธ Spain

mcp-facturacion-electronica-es

๐Ÿ‡ฆ๐Ÿ‡ช United Arab Emirates

mcp-einvoicing-ae

License

This project is distributed under the Apache 2.0 license. See the LICENSE file for details. For the full version history, see CHANGELOG.md.

Available Tools

10 tools
generate_fa2_invoiceGenerate Fa2 InvoiceA

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).

ParametersJSON 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

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It adds valuable context: output is an XML string (not a submission), it is KSeF-compliant, and the seller's tax_id must be a Polish NIP (10 digits). However, it does not describe potential validation behavior, error conditions, or whether the tool performs any side-effect-free transformation beyond what is implied.

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?

The description is three concise sentences with no fluff: purpose, output, and the key country-specific constraint. It is front-loaded with the main action and output type, and every sentence earns its place.

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?

Given the highly detailed 100%-coverage schema and the existence of an output schema, the description covers the essentials: what it generates, the return type, and the Polish NIP requirement. It is adequate for an agent to call the tool correctly, though it could be improved by explicitly stating that it only generates and does not submit or validate.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description adds one meaningful constraint not in the schemaโ€”'The seller's tax_id must be a Polish NIP (10 digits)'โ€”which helps an agent populate the nested seller.tax_id correctly. Beyond that, the description defers to the already-rich inline schema descriptions.

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

Purpose4/5

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

The description clearly states a specific verb and resource: 'Generate a KSeF-compliant FA(2) XML invoice from structured invoice data.' It also specifies the output format ('FA(2) XML string ready for submission to KSeF'), which distinguishes it from submission, validation, and parsing siblings. However, it does not explicitly name generate_fa3_invoice or generate_peppol_invoice as alternatives, so differentiation relies mostly on the tool name and format.

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 description implies usage context: call this when you have structured invoice data and need an FA(2) XML string for KSeF, and the 'ready for submission' phrase implies the tool does not submit. It does not explicitly state when to prefer generate_fa3_invoice, validate_fa2_invoice, or submit_invoice_to_ksef, and no alternatives are named.

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

generate_fa3_invoiceGenerate Fa3 InvoiceA

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.

ParametersJSON 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

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior4/5

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

No annotations are provided, so the description carries the disclosure burden. It discloses the return value (FA(3) XML string ready for submit_invoice_to_ksef), the F(A)3 compliance requirement, and tax-identifier constraints including the <BrakID> edge case. It does not describe error/validation behavior, but for a pure generation tool this is reasonably transparent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is compact and front-loaded with the core action and output format, followed by workflow ordering and key constraints. Every sentence earns its place, with no filler or redundant restatement of schema details.

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?

The tool has a very rich nested schema and an output schema, so the description need not restate field details. It provides the critical workflow context (use before submit_invoice_to_ksef, not generate_fa2_invoice) and important country-specific constraints. The unresolved contradiction about representing an absent buyer tax ID is the main completeness gap.

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

Parameters2/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, and the description does add useful context such as seller NIP format and buyer tax-id alternatives. However, the instruction to leave tax_id.identifier empty for absent buyer tax IDs contradicts the schema, which requires tax_id and enforces minLength: 1 on identifier. The 'set alt_tax_id' guidance for EU VAT numbers also reads inconsistently with alt_tax_id's schema meaning, so the added value is undercut by misleading edge-case guidance.

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: generates a KSeF-compliant FA(3) XML invoice from structured invoice data. It also distinguishes itself from the sibling generate_fa2_invoice, so an agent can identify the correct tool without inspecting schemas.

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 to use this tool rather than generate_fa2_invoice and to call it before submit_invoice_to_ksef. It also explains that FA(3) is required for all new KSeF API v2 submissions, giving clear when/when-not guidance.

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

generate_peppol_invoiceGenerate Peppol InvoiceA

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_fa2_invoice instead.

ParametersJSON 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

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4/5.0
Behavior2/5

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

No annotations are provided, so the description carries the full behavioral burden. It says the tool generates an XML invoice, but does not disclose whether it validates input, returns XML directly, persists anything, or transmits to the Peppol network. The generate-versus-submit behavior is left ambiguous.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two sentences with no filler. The first sentence defines the output format, and the second provides usage routing. Every sentence earns its place.

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?

The tool is complex with deeply nested inputs, but the schema is richly documented and an output schema exists, so return-value details are not needed. The description provides the essential selection and routing context; the main remaining gap is the unstated generate-versus-submit behavior.

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

Parameters3/5

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

Schema description coverage is 100%, so the baseline is 3. The description itself adds no parameter-level guidance, but the detailed invoice object schema already documents the fields, formats, and country-specific meanings, so the agent can still construct the parameter correctly.

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 description states a specific verb and resource: 'Generate a Peppol BIS Billing 3.0 / EN 16931 UBL 2.1 XML invoice.' It also distinguishes the tool from siblings by explicitly framing it as cross-border B2B via Peppol, which separates it from the Polish FA invoice tools.

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?

The description explicitly says when to use this tool ('Use this for cross-border B2B invoicing via the Peppol network') and names a concrete alternative with its own condition ('For domestic Polish invoicing, use generate_fa2_invoice instead'). This is clear routing guidance.

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

get_ksef_invoice_statusGet Ksef Invoice StatusA

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

ParametersJSON Schema
NameRequiredDescriptionDefault
reference_numberYes ("{sessionRef}:{invoiceRef}"). Pass just the sessionRef to retrieve the overall session status instead.

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.6/5.0
Behavior3/5

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

No annotations are provided, so the description carries the behavioral disclosure burden. 'Retrieve' and 'processing status' strongly imply a read-only operation, but the description does not mention potential error cases, polling semantics, or confirmation that no state changes occur. The read-only implication compensates partly for the missing annotations.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no filler or redundant wording. It states the operation, the target resource, and the relevant API version efficiently.

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 tool with one required parameter and an output schema, the description is mostly sufficient for an agent to invoke it correctly. The only notable gap is the lack of explicit guidance about when to use this versus the search-related sibling or how to handle unresolved statuses, but the output schema likely covers response details.

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

Parameters3/5

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

The schema description coverage is 100%, and the parameter schema already explains the '{sessionRef}:{invoiceRef}' format and the option to pass only the sessionRef for session status. The tool description adds no additional parameter-level meaning beyond that, so the baseline score of 3 is appropriate.

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

Purpose4/5

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

The description clearly identifies the operation as retrieving the processing status of a KSeF invoice, with an explicit version qualifier ('API v2'). It is specific about verb and resource, though it does not explicitly distinguish itself from siblings like search_ksef_invoices.

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 word 'submitted' implies the tool should be used after invoice submission, and the sibling submit_invoice_to_ksef provides contextual contrast. However, there is no explicit statement about when to use this tool instead of alternatives like search_ksef_invoices or when it is not appropriate.

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

parse_fa2_invoiceParse Fa2 InvoiceA

Parse a KSeF FA(2) XML invoice into a structured dictionary.

Returns a nested dict with 'header', 'seller', 'buyer', 'invoice', and 'lines' keys.

ParametersJSON Schema
NameRequiredDescriptionDefault
xml_contentYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.7/5.0
Behavior3/5

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

With no annotations, the description carries the full burden, and it does disclose the primary behavior: converting XML into a nested dictionary with named keys. However, it does not mention error behavior on malformed XML, format assumptions, or whether parsing is strict or lenient, leaving notable gaps for a parsing tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two tight sentences with no filler. The main action and resource are front-loaded, and the second sentence economically summarizes the return structure.

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

Completeness3/5

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

For a single-parameter parser with an output schema, the description covers the essential call pattern: pass FA(2) XML content and receive a dict with named sections. It is less complete about error conditions, supported KSeF versions, and edge cases such as empty or invalid XML, which an agent would need for robust handling.

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

Parameters3/5

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

The input schema only defines xml_content as a string with no description, while the tool description adds that it should contain a KSeF FA(2) XML invoice. This provides useful meaning beyond the raw schema, but it does not cover encoding details, XML structure expectations, or how malformed content is handled.

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 description uses a specific verb ('Parse') and a precise resource ('a KSeF FA(2) XML invoice'), and it states the output is a structured dictionary with clear top-level keys. This clearly separates it from siblings like generate_fa2_invoice and validate_fa2_invoice, which perform different operations on the same document type.

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 intended use is implied by the verb 'Parse' and the reference to FA(2) XML invoices, but there is no explicit guidance about when to choose this tool over validate_fa2_invoice or generate_fa2_invoice. No exclusions, prerequisites, or alternative-use conditions are stated.

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

search_ksef_invoicesSearch Ksef InvoicesC

Query invoices stored in KSeF for a date range.

ParametersJSON Schema
NameRequiredDescriptionDefault
date_toYes
date_fromYes
subject_typeNosubject1

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

C2.9/5.0
Behavior2/5

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

No annotations are provided, so the description carries the burden of behavioral disclosure. It states a read-style query operation but does not mention pagination, result limits, KSeF environment specifics, or whether the query has any filtering side effects. The phrase 'Query invoices stored in KSeF' is clear but minimal.

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?

The description is a single efficient sentence with no filler. It front-loads the action and resource, making it easy to scan, though it does sacrifice some useful detail for brevity.

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

Completeness2/5

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

With three parameters, no annotations, and no schema descriptions, the description leaves critical input semantics unexplained. The output schema exists but does not help an agent provide correct inputs, especially for subject_type and date formatting. The tool description is not sufficient for a confident first call.

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

Parameters2/5

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

Schema descriptions are entirely empty (0% coverage), so the description must compensate. It clarifies that date_from and date_to define the date range, but it does not explain their expected format or the meaning of subject_type, which remains completely undocumented.

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 description uses a specific verb ('Query') with a clear resource ('invoices stored in KSeF') and a defined scope ('for a date range'). This clearly separates it from siblings like submit_invoice_to_ksef, generate_fa2_invoice, and validate_polish_nip.

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

Usage Guidelines2/5

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

No guidance is provided about when to use this tool versus alternatives such as get_ksef_invoice_status. The agent is left to infer the intended use from the tool name and description rather than being told which sibling handles status checks or individual invoice retrieval.

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

submit_invoice_to_ksefSubmit Invoice To KsefA

Submit a FA(3) XML invoice to the KSeF platform (API v2).

KSeF API v2 requires FA(3) format for submission. Use generate_fa2_invoice only for validation or parsing; it produces FA(2) XML which KSeF v2 does not accept. FA(3) generation is tracked in roadmap-2026.md.

ParametersJSON Schema
NameRequiredDescriptionDefault
xml_contentYes
session_tokenNo Obtain via the challenge โ†’ authenticate โ†’ redeem flow: https://github.com/CIRFMF/ksef-docs/blob/main/uwierzytelnianie.md

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A3.6/5.0
Behavior2/5

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

No annotations are provided, so the description must carry the behavioral burden. It discloses the FA(3) format requirement but does not mention side effects of submission, authentication prerequisites, reversibility, or potential status/error behavior. For a mutation tool, this leaves important operational behavior undisclosed.

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?

The core purpose is front-loaded in the first sentence, and the following sentences give relevant format guidance. The roadmap note is slightly extraneous and could confuse, but overall the description is compact and structured well.

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

Completeness3/5

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

An output schema exists, so return-value documentation is not the description's burden. However, with no annotations, the description should cover prerequisites such as session_token acquisition and submission side effects; it only covers the format constraint. This is sufficient for the basic input but incomplete for confident invocation.

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

Parameters3/5

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

Schema coverage is only 50%; xml_content has no schema description, while session_token has an auth flow link. The description adds meaning to xml_content by requiring FA(3) XML, but it does not specify encoding, structure, or how the content must be embedded, so it only partially compensates for the schema gap.

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, resource, and version: 'Submit a FA(3) XML invoice to the KSeF platform (API v2).' It also distinguishes itself from generate_fa2_invoice by clarifying the target format, so an agent can tell this is the submission tool, not a generator or validator.

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

Usage Guidelines4/5

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

Explicitly warns that generate_fa2_invoice produces FA(2) XML that KSeF v2 does not accept and should only be used for validation or parsing. However, it does not point to generate_fa3_invoice as the correct companion generator, and the roadmap note muddies whether FA(3) generation is actually available.

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

validate_fa2_invoiceValidate Fa2 InvoiceA

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.

ParametersJSON Schema
NameRequiredDescriptionDefault
xml_contentYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
validYes
errorsNo
metadataNo
warningsNo

TDQS

A3.8/5.0
Behavior4/5

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

With no annotations provided, the description carries the behavioral burden. It discloses the conditional XSD validation ('when the official schema is present') and explains the return type as a DocumentValidationResult with errors and warnings, giving useful behavioral context beyond the tool name.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is two sentences with no filler. It front-loads the core action and then adds the key behavioral details about validation steps and output, every sentence earning its place.

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 single-parameter validation tool with an output schema, the description is largely sufficient. It covers the validation logic, the conditional schema dependency, and the result type, though it could add a sentence about when validation is appropriate relative to submission.

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

Parameters3/5

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

Schema description coverage is 0%, so the description must compensate. It identifies the input as a KSeF FA(2) XML invoice, which makes the xml_content parameter largely inferable, but it does not explicitly define the parameter as the raw XML string or specify any constraints such as encoding or size.

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 description clearly states the tool validates a KSeF FA(2) XML invoice, naming both the specific resource and the action. It further distinguishes the scope by mentioning XSD validation and Polish business-rule checks, which separates it from sibling validation and generation tools.

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

Usage Guidelines2/5

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

The description explains what the tool does but offers no guidance on when to use it versus alternatives such as parse_fa2_invoice, generate_fa2_invoice, or submit_invoice_to_ksef. There is no mention of pre-submission validation, exclusion conditions, or recommended workflow context.

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

validate_polish_nipValidate Polish NipA

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}.

ParametersJSON Schema
NameRequiredDescriptionDefault
nipYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.3/5.0
Behavior4/5

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

There are no annotations, so the description carries the burden. It discloses the algorithm, accepted formatting, and return shape, which is solid for a simple validation tool, though it does not cover malformed-input edge cases.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Three short, front-loaded sentences with no filler. Each sentence adds distinct value: purpose, algorithm/format, and return contract.

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?

For a single-parameter validator, the description covers what the tool does, how it validates, what formats are accepted, and what it returns. With an output schema already present, no critical information is missing for correct invocation.

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?

The schema only says 'string', so the description adds important meaning: the NIP should be 10 digits and may include dashes or spaces. It stops short of giving examples or exact normalization rules.

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 description uses a specific verb ('Validate'), names the exact resource ('Polish NIP'), and states the checksum algorithm, so an agent can distinguish it from validate_polish_regon and the invoice tools without opening the schema.

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?

It states what input is accepted and implies when to use it, but it never describes when to prefer this over validate_polish_regon or when not to use it. The usage context is clear but not made explicit.

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

validate_polish_regonValidate Polish RegonA

Validate a Polish REGON (business registry number โ€” 9 or 14 digits).

Returns {'valid': bool, 'regon': str, 'length': int}.

ParametersJSON Schema
NameRequiredDescriptionDefault
regonYes

Output Schema

ParametersJSON Schema
NameRequiredDescription

No output parameters

TDQS

A4.4/5.0
Behavior4/5

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

With no annotations provided, the description carries the full burden. It discloses the return shape ('valid', 'regon', 'length'), signals a safe read-only validation operation, and specifies the accepted 9 or 14 digit format. It does not mention checksum behavior or error handling for malformed input, but for a simple validator this is a minor gap.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

Two short sentences with no filler. The action and target are front-loaded, and the return format is stated compactly. Every phrase earns its place.

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 simple single-parameter validation tool with an output schema, the description is nearly complete. It covers what is validated, the accepted length, and the return keys. Missing details like checksum validation or behavior on invalid formats are useful but not critical for invoking the tool correctly.

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 0%, so the description must compensate for the bare string parameter. It does so by explaining REGON is a 9 or 14 digit business registry number, which gives the agent concrete format expectations beyond the schema. It does not discuss normalization or edge cases, but the single parameter is adequately clarified.

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 description names a specific verb ('Validate') and resource ('Polish REGON โ€” 9 or 14 digits'), clearly distinguishing it from siblings like validate_polish_nip. The parenthetical format detail makes the tool's exact purpose immediately recognizable.

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

Usage Guidelines4/5

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

It clearly implies when to use this tool: whenever a Polish REGON number needs validation. It does not explicitly name alternatives or exclusions, but the resource-specific wording provides sufficient context for an agent to select it over NIP or invoice validation tools.

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

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 10 tool updatesv0.0.1
    • First observedgenerate_fa2_invoice
    • First observedgenerate_fa3_invoice
    • First observedgenerate_peppol_invoice
    • First observedget_ksef_invoice_status
    • First observedparse_fa2_invoice
    • First observedsearch_ksef_invoices
    • First observedsubmit_invoice_to_ksef
    • First observedvalidate_fa2_invoice
    • First observedvalidate_polish_nip
    • First observedvalidate_polish_regon

TDQS

A3.8/5.0

Scored across 10 tools

Disambiguation5/5

Each tool targets a specific action (generate, validate, parse, submit, status, search, validate) on a specific resource (FA2, FA3, invoice, NIP, REGON, Peppol). The two generation tools are clearly differentiated by descriptions that explicitly note FA(3) is for submission and FA(2) is for validation/parsing.

Naming Consistency5/5

All tools follow a consistent snake_case verb_noun pattern (e.g., generate_fa2_invoice, validate_polish_nip, get_ksef_invoice_status). Verbs are descriptive and the object structure is uniform across the set.

Tool Count5/5

10 tools is well-scoped for the KSeF domain, covering generation, validation, parsing, submission, status checking, and search, plus necessary Polish identifier validators and a cross-border Peppol generator. No tool feels redundant or missing.

Completeness4/5

The core invoicing lifecycle (create, validate, parse, submit, track, search) is fully covered. Minor gaps exist such as no FA(3) validation and no invoice cancellation/update operations, but these are not critical for typical submission workflows.

Maintenance

ActivityActive
ResponsivenessResponsive

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    A
    maintenance
    Model Context Protocol (MCP) server for French Electronic Invoicing (NF XP Z12-013). Provide tools to validate, generate, and explore API specifications for PDP/OD interoperability.
    2
    34
    Apache 2.0
  • A
    license
    A
    quality
    A
    maintenance
    Model Context Protocol (MCP) server for Italian Electronic Invoicing (FatturaPA / SDI). Provide tools to validate, generate, and explore API specifications for Sistema di Interscambio (SDI) interoperability.
    43
    355 PyPI
    1
    Apache 2.0
  • A
    license
    A
    quality
    A
    maintenance
    Model Context Protocol (MCP) server for Spanish Electronic Invoicing. Provides tools to generate, validate, and submit invoices across VERI\*FACTU, Facturae/FACe, SII, TicketBAI, and Crea y Crece B2B.
    20
    321 PyPI
    2
    Apache 2.0
  • A
    license
    A
    quality
    A
    maintenance
    Model Context Protocol (MCP) server for Singapore Electronic Invoicing (InvoiceNow / PINT-SG / Peppol 5-Corner Model). Provides tools to validate, generate, and explore API specifications for IRAS / Peppol interoperability.
    17
    Apache 2.0