
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 分