
Mcp Ksef Pl
io.github.cmendezsPublished by GitHub account cmendezsv0.10.1Updated Oct 24, 2026
Polish e-invoicing MCP: KSeF API v2, FA(3)/FA(2) XML, Peppol BIS 3.0, NIP/REGON validation.
Overview
A local MCP server for Polish e-invoicing that lets an assistant generate, validate and submit KSeF FA(3)/FA(2) invoices and work with Peppol BIS 3.0 documents.
- What you can do
- Generate and validate FA(3) and FA(2) KSeF XML invoices, and parse FA(2) XML into structured data. Submit FA(3) invoices to KSeF, check their processing status, and search invoices by date range and seller/buyer direction. Validate Polish NIP and REGON tax identifiers by checksum. Generate and validate Peppol BIS Billing 3.0 / EN 16931 UBL invoices. Look up Peppol participants, service endpoints and the Peppol Directory, run DNS diagnostics, send invoices via AS4, and check OpenPeppol and EN 16931 code lists. Validate EUSR, TSR and MLS reporting documents and build MLS responses.
- When to use it
- Useful when an assistant has to prepare, check or file Polish e-invoices with KSeF, or to work with Peppol/EN 16931 invoices and Polish tax identifiers. Best suited to developers or finance teams already set up with KSeF and Peppol access.
- Requirements
- Runs locally as a Python package (pip or uvx). Needs KSEF_NIP and a KSEF_SESSION_TOKEN obtained separately through the KSeF challenge/signature/redeem flow, which the server cannot automate; the token expires after roughly 2 hours. KSEF_ENVIRONMENT selects test (default) or production. Peppol code list tools need EINVOICING_PEPPOL_CODELIST_DIR and EINVOICING_EN16931_CODELIST_DIR; EUSR/TSR/MLS validation needs the xslt2 extra. Network access to KSeF and Peppol services.
Installation
In SourceWeft
- Open Mcp Ksef Pl in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
mcp-ksef-pl 🇵🇱
[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.
Installation
Via PyPI (recommended)
Or without prior installation using uvx:
From source
Configuration (environment variables)
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:
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
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
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
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
Identifier validation
Peppol / EN 16931
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).
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.
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
-
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/. -
Request a challenge. Call the KSeF API to obtain a challenge XML envelope:
The response contains a
challengestring and atimestamp. -
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
xmlsec1with a PKCS#12 certificate: -
Submit the signed challenge. POST the signed XML to receive an
authOperationreference: -
Redeem the AccessToken. Exchange the authenticated operation for an AccessToken:
The response contains
accessToken.tokenandaccessToken.context.referenceNumber. -
Set the token. Export the token for this MCP server:
The token is valid for approximately 2 hours from issuance (per MF documentation). After expiry, repeat steps 2-5.
References
- KSeF technical documentation: https://www.podatki.gov.pl/ksef/dokumentacja-techniczna-ksef/
- Authentication spec (CIRFMF): https://github.com/CIRFMF/ksef-docs/blob/main/uwierzytelnianie.md
- Interactive session spec (CIRFMF): https://github.com/CIRFMF/ksef-docs/blob/main/sesja-interaktywna.md
- FA(3) migration announcement:
specs/ksef-v2-fa3-migration-announcement-20250630.pdf
Architecture
The server acts as an intelligent communication interface between the AI agent and the KSeF platform and the Peppol network:
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
Contributing
Contributions are welcome — see CONTRIBUTING.md for guidelines.
Other e-invoicing MCP servers
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.
Source: README.md at commit c89cf73
Tools
0Version history
1- v0.10.1LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts