
Mcp Ksef Pl
io.github.cmendezs由 GitHub 帳號 cmendezs 發布v0.10.1更新於 Oct 24, 2026
Polish e-invoicing MCP: KSeF API v2, FA(3)/FA(2) XML, Peppol BIS 3.0, NIP/REGON validation.
概覽
針對波蘭電子發票的在地 MCP 伺服器,讓助理產生、驗證並提交 KSeF FA(3)/FA(2) 發票,並處理 Peppol BIS 3.0 文件。
- 可以做什麼
- 產生並驗證 KSeF 的 FA(3) 與 FA(2) XML 發票,並將 FA(2) XML 解析為結構化資料。向 KSeF 提交 FA(3) 發票、查詢處理狀態,並依日期範圍與買賣方方向搜尋發票。以檢查碼驗證波蘭 NIP 與 REGON 稅籍編號。產生並驗證 Peppol BIS Billing 3.0 / EN 16931 的 UBL 發票。查詢 Peppol 參與者、服務端點與 Peppol 目錄,執行 DNS 診斷,透過 AS4 傳送發票,並查詢 OpenPeppol 與 EN 16931 代碼表。驗證 EUSR、TSR 與 MLS 報告文件並建立 MLS 回應。
- 適用情境
- 適合需要準備、檢查或申報波蘭 KSeF 電子發票,或處理 Peppol/EN 16931 發票與波蘭稅籍編號的情境。最適合已具備 KSeF 與 Peppol 存取權限的開發者或財務團隊。
- 執行需求
- 以 Python 套件形式在地執行(pip 或 uvx)。需要 KSEF_NIP,以及另行透過 KSeF 挑戰/簽章/兌換流程取得的 KSEF_SESSION_TOKEN,此流程伺服器無法自動完成;權杖約 2 小時後過期。KSEF_ENVIRONMENT 選擇 test(預設)或 production。Peppol 代碼表工具需要 EINVOICING_PEPPOL_CODELIST_DIR 與 EINVOICING_EN16931_CODELIST_DIR;EUSR/TSR/MLS 驗證需要 xslt2 附加元件。需要連線至 KSeF 與 Peppol 服務的網路。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Mcp Ksef Pl,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
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.
來源:README.md,提交 c89cf73
工具
0版本歷史
1- v0.10.1最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分