Kontor MCP

io.github.DashankaNadeeshanDeSilva由 GitHub 账号 DashankaNadeeshanDeSilva 发布v1.0.4更新于 Oct 27, 2026

Offline e-invoice tools for AI agents: validate, audit, convert and generate XRechnung/ZUGFeRD.

已验证STDIO仅桌面金融商业与电商

概览

AI 生成的概览

离线 MCP 服务器,让助手解析、校验、审核、生成并转换德国/欧盟电子发票(XRechnung、ZUGFeRD/Factur-X)。

可以做什么
  • 解析与查看发票:识别 UBL/CII、XRechnung 版本与 ZUGFeRD 配置文件,返回 EN 16931 语义模型
  • 校验与审核:XSD 加官方 EN 16931/XRechnung Schematron 规则,给出解释性发现与接受/复核/拒绝建议
  • 生成与转换:生成 XRechnung 3.0 UBL 或 ZUGFeRD PDF/A-3,将 PDF 转为 XML、UBL 与 CII 互转并附损失报告
  • 解释规则与义务:查询 BR-* 规则原文与修复提示,德国电子发票强制规定决策树
  • 列出能力信息,浏览内置样例、规则与代码表资源,并使用审核、拒收草稿、创建发票等提示模板
适用场景
适合需要检查供应商进项电子发票、解释校验错误、生成合规的 XRechnung 或 ZUGFeRD 文件,或解答德国电子发票合规义务问题,同时希望发票数据留在本机的场景。
运行要求
以 stdio 方式在本机运行,通常通过 npx 启动,需要 Node 20 或更高版本。另提供 Docker 镜像用于 Streamable HTTP 模式,该模式必须提供至少 16 个字符的 KONTOR_AUTH_TOKEN 令牌。可选设置:KONTOR_LANG_DEFAULT(de 或 en)与 KONTOR_MAX_FILE_MB。运行时无需 API 密钥或网络访问。
安装前请注意
发票包含个人与银行数据;服务器声明为无状态且默认不记录载荷,但会读取你提供的本地路径文件。HTTP 模式仅由 KONTOR_AUTH_TOKEN 保护,TLS 需自行通过反向代理实现。生成的发票与审核结论属于形式与技术检查,不构成法律或税务建议。可选的 kontor-agent 聊天客户端需要 ANTHROPIC_API_KEY。

安装

在 SourceWeft 中

  1. 打开 控制台中的 Kontor MCP,将其添加到工作区。
  2. 为需要使用其工具的对话启用该服务。

Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。

其他 MCP 客户端

参照 仓库 中的启动说明。

README

Kontor MCP

The sovereign e-invoice toolkit for AI agents. Official XRechnung / EN 16931 validation, ZUGFeRD in and out, 100 % offline, zero API keys.

[CI] [Conformance] [PDF/A-3] [License] [npm] [MCP Registry] [Website]

Kontor MCP is a local, offline toolbox that lets AI assistants (Claude Desktop, Claude Code, any MCP client) handle German/EU e-invoices: XRechnung and ZUGFeRD/Factur-X under EN 16931. It can read an invoice (bare XML or XML embedded in a PDF), check it against the official KoSIT / EN 16931 rulebooks, explain cryptic errors in German or English, create valid new invoices (XML or ZUGFeRD PDF/A-3), convert between formats, and tell a business which legal obligations apply. The key promise is sovereignty: no cloud, no API keys, no network calls, no Java at runtime — proven by tests.

Why it matters: since 2025 every German business must be able to receive e-invoices, and from 2027/2028 must issue them. An e-invoice is validated XML, not a PDF, and a failed rule can cost the input-VAT deduction. Invoices carry personal and bank data, so they should be checked where they live — on your machine — with the same rule sets the public-sector receivers use.

[Kontor MCP in Claude Desktop: validate a broken XRechnung, parse a ZUGFeRD PDF, explain BR-DE-18]

Claude Desktop with the kontor server: validate → BR-DE-15 (missing Leitweg-ID) with fix hint · parse a ZUGFeRD PDF · explain BR-DE-18. MP4

v1.0 — 8 tools · 4 resource families · 3 prompts · KoSIT conformance 89/89 enforced as a CI gate · ZUGFeRD PDF/A-3 output verified by veraPDF and Mustang · stdio and Streamable HTTP (bearer auth) · Docker image (amd64/arm64) · kontor-agent reference client · listed in the Official MCP Registry. Install with npx, Docker, or from source.

Why

  • Official rules, not approximations. The KoSIT XRechnung Schematron and the CEN EN 16931 rules run unmodified (compiled to XSLT/SEF, executed with Saxon-JS) with the KoSIT scenario model — the same verdicts the public-sector receivers produce, proven file-by-file against the official validator.
  • Sovereign by construction. Pure TypeScript/WASM, no Java at runtime, no network calls, nothing stored, nothing logged. Runs where the invoices are.
  • Agent-native. Every tool returns structured content and a readable summary; findings carry DE/EN explanations, affected business terms and fix hints; generation is fail-honest (valid is the real verdict, never assumed).
  • ZUGFeRD both ways. Read the embedded XML out of any ZUGFeRD/Factur-X PDF; write PDF/A-3 invoices with factur-x.xml that pass veraPDF and Mustang.

Five-minute quickstart

Requires Node ≥ 20. Everything — rules, schemas, code lists, fonts — ships inside the npm package; no downloads at runtime, no Java.

Install pathCommand
npx (zero-config stdio)npx -y @kontor-mcp/server
Docker (Streamable HTTP, token required)docker run -d -p 127.0.0.1:3333:3333 -e KONTOR_AUTH_TOKEN=… ghcr.io/dashankanadeeshandesilva/kontor-mcp
Reference clientnpx -y -p @kontor-mcp/client kontor-agent audit invoice.xml
From sourcegit clone … && pnpm install && pnpm build → node packages/server/dist/bin.js

Claude Desktop — Settings → Developer → Edit Config, then quit (⌘Q) and reopen:

json
{  "mcpServers": {    "kontor": {      "command": "npx",      "args": ["-y", "@kontor-mcp/server"]    }  }}

(From a source checkout use "command": "node", "args": ["/absolute/path/to/kontor-mcp/packages/server/dist/bin.js"] instead.)


**Claude Code:**
```shclaude mcp add kontor -- npx -y @kontor-mcp/server

Now audit a sample invoice. Ask Claude:

Audit /absolute/path/to/kontor-mcp/packages/server/samples/broken-missing-buyer-reference.xml — is it valid?

You get a verdict (invalid), the finding BR-DE-15 (missing buyer reference / Leitweg-ID) with an explanation and fix hint, the recomputed totals and VAT breakdown, and a reject recommendation with its rationale. Then try a ZUGFeRD PDF:

What is in /absolute/path/to/kontor-mcp/packages/server/samples/generated-zugferd-en16931.pdf?

(Attach XML files directly if you prefer; PDFs must be referenced by local path — Claude Desktop does not hand PDF bytes to MCP servers.)

Without a chat client, the MCP Inspector works headless:

sh
npx @modelcontextprotocol/inspector@latest --cli node packages/server/dist/bin.js \  --method tools/call --tool-name audit_invoice \  --tool-arg file_path=$PWD/packages/server/samples/broken-missing-buyer-reference.xml --tool-arg lang=en

kontor-agent CLI — the reference client; audit needs no LLM and returns 0/1/2 for accept/review/reject, chat is an Anthropic agent loop that prints every tool call (needs ANTHROPIC_API_KEY):

sh
node packages/client/dist/bin.js audit packages/server/samples/broken-missing-buyer-reference.xml --lang ennode packages/client/dist/bin.js chat -m "Prüfe $PWD/packages/server/samples/valid-zugferd-en16931.pdf"node packages/client/dist/bin.js --url http://127.0.0.1:3333/mcp --token "$KONTOR_AUTH_TOKEN" tools   # against Docker / HTTP

Docker / Streamable HTTP — the same server over HTTP for remote agents and containers (token required, loopback-published port, TLS is your reverse proxy's job):

sh
docker build -t kontor-mcp .              # multi-stage, non-root, ~70 MB, amd64 + arm64docker run -d -p 127.0.0.1:3333:3333 -e KONTOR_AUTH_TOKEN="$(openssl rand -hex 24)" kontor-mcpcurl -s http://127.0.0.1:3333/healthz     # {"ok":true,"name":"kontor-mcp",...}

Or cp .env.example .env && docker compose up -d (read-only root FS, ./invoices mounted at /data). Config surface and the security posture: packages/server/README.md, SECURITY.md.

Tools

ToolWhat it does
parse_invoiceDetect the format (UBL / CII · EN 16931 · XRechnung version & variant · ZUGFeRD profile) and return the EN 16931 semantic model
validate_invoiceXSD + official EN 16931 / XRechnung Schematron (KoSIT scenarios) + Kontor plausibility → valid / valid_with_warnings / invalid with explained findings
audit_invoiceOne call for accounts payable: header facts, VAT breakdown, verdict, grouped findings, accept / review / reject with rationale; stateless duplicate detection via known_invoice_numbers
generate_invoiceStructured data → XRechnung 3.0 (UBL) or ZUGFeRD 2.3 / Factur-X PDF/A-3 (target: zugferd-pdf, profiles EN16931 / BASIC / EXTENDED); decimal-safe amounts, internal validation, deterministic auto-fixes reported
convert_invoiceZUGFeRD PDF → XML, UBL ↔ CII via the semantic model (post-validated, honest loss report), self-contained HTML preview
check_obligationsGerman e-invoicing mandate decision tree (B2B/B2G/B2C, 2025 → 2028 transition, exemptions) with primary legal sources
explain_ruleOfficial text, explanation, affected business terms and fix hint for any BR-* / BR-DE-* / KONTOR-* rule id
list_capabilitiesFormats, bundled standard versions, KB stats, legal lastVerified, inventory, sovereignty statement

Resources: kontor://samples/{name}, kontor://reference/rules, kontor://reference/codelists/{list}, kontor://reference/cheatsheet. Prompts: audit-incoming-invoice, draft-supplier-rejection, create-invoice-interview. Full reference with inputs and conventions: packages/server/README.md.

Sovereignty — and how we prove it

ClaimProof
No network at runtimeEvery rule set, schema, code list and legal fact is bundled in @kontor-mcp/rules with provenance and checksums. Proven by sovereignty.test.ts: all outbound paths (sockets, DNS, TLS, http/https, fetch) are blocked and recorded while every tool, resource and prompt runs — zero attempts; a static scan allows a network import only in the inbound HTTP host; CI also runs a full audit in a --network none container. See SECURITY.md.
No Java, no native codeSchematron is compiled at build time and executed with Saxon-JS; XSD via xmllint-wasm; PDF via pdf-lib. Java is used only by the development-time oracles (KoSIT validator, veraPDF, Mustang) in CI.
Nothing stored, nothing loggedThe server is stateless; invoice contents never reach a log (KONTOR_LOG_PAYLOADS defaults to off).
The verdicts are the official onesdocs/CONFORMANCE.md: 89/89 files of the official XRechnung test suite with identical verdicts and identical findings vs the KoSIT validator, replayed on every CI run.
The PDFs are real PDF/A-3Every generated sample is regenerated in CI and checked by veraPDF (PDF/A-3b, zero violations) and Mustang CLI (PDF/A + XMP + profile XSD + EN 16931 rules).

Architecture

mermaid
flowchart LR  subgraph client [MCP client]    A[Claude Desktop / Claude Code / kontor-agent]  end  A -- stdio / Streamable HTTP --> S
  subgraph server ["@kontor-mcp/server"]    S[tools · resources · prompts<br/>Zod schemas, structuredContent + text]  end
  subgraph core ["@kontor-mcp/core (MCP-free library)"]    D[detect] --> P[parse → EN 16931 model]    P --> V[validate: XSD → Schematron → plausibility]    P --> G[generate / convert / preview]    G --> Z[ZUGFeRD PDF/A-3 assembly]    V --> AU[audit → verdict + recommendation]    O[obligations decision tree]  end
  subgraph rules ["@kontor-mcp/rules (bundled, checksummed)"]    R1[XSDs UBL 2.1 / CII D16B]    R2[EN 16931 + XRechnung Schematron as SEF]    R3[rule knowledge base DE/EN]    R4[code lists · legal timeline · fonts + ICC]  end
  S --> core  core --> rules

The validation pipeline: Layer 1 XSD (xmllint-wasm) → Layer 2 official Schematron (Saxon-JS, KoSIT scenario selection and severity overrides) → Layer 3 Kontor plausibility (KONTOR-PLAUS-*: decimal recomputation, VAT rates, IBAN/BIC, Leitweg-ID check digits, dates, duplicates — never changes the official verdict). Money math is decimal.js only; every XML parse has DTD/external entities disabled.

Conformance

WhatReferenceResult (2026-08-25)
Validation verdicts and findingsKoSIT validator 1.6.3, XRechnung 3.0.2 test suite (86 files) + Kontor fixtures (3)89/89 verdict and finding parity
Generated ZUGFeRD PDFsveraPDF 1.30.2 (PDF/A-3b)6/6 PASS, zero violations
Generated ZUGFeRD PDFsMustang CLI 2.26.0 (PDF/A + XMP + Factur-X profile XSD + EN 16931)6/6 valid (EN 16931, BASIC, EXTENDED × DE/EN)
Generated XRechnungown pipeline (identical to the oracle above), 50 random inputs50/50 valid and plausible

Details, commands and recorded reports: docs/CONFORMANCE.md.

Packages

PackagePurpose
@kontor-mcp/coreMCP-free library: detect, parse, validate, audit, generate, convert, ZUGFeRD PDF
@kontor-mcp/rulesBundled standards artefacts (XSDs, compiled Schematron, code lists, legal timeline, PDF assets) + rule knowledge base
@kontor-mcp/serverMCP server (stdio and Streamable HTTP with bearer auth; Docker image) exposing tools, resources, prompts
@kontor-mcp/clientkontor-agent — reference MCP client CLI: tools introspection, scriptable audit <file> (no LLM, exit codes), chat Anthropic agent loop with tool-call trace; stdio or HTTP

FAQ

Is this legal or tax advice? No. Kontor reports formal and technical checks against the published standards and the legal timeline with its sources; decisions remain yours. Every answer carries that disclaimer.

Does it support XRechnung 3.0.2 / the 2025 rules? Yes: XRechnung 3.0.2, Schematron 2.5.0, validator configuration 2026-01-31, EN 16931 1.3.16. Versions are pinned and listed by list_capabilities.

Which ZUGFeRD profiles can it read and write? Read: MINIMUM, BASIC WL, BASIC, EN 16931, EXTENDED, XRECHNUNG (profile from the XMP). Write: EN 16931 (default), BASIC, EXTENDED — see D-042 for what BASIC drops.

Can I send it a PDF from Claude Desktop? Reference it by local path. Desktop does not pass attached PDF bytes to MCP servers; XML attachments work either way.

Why no Java when KoSIT's validator is Java? Sovereignty and installability: Schematron is compiled once at build time and executed in TypeScript (Saxon-JS). The Java tools are used only as oracles in CI to prove parity.

Windows? Yes — CI runs the full test suite on Ubuntu, macOS and Windows with Node 20 and 22.

Development

sh
pnpm installpnpm buildpnpm -r testpnpm lintpnpm artifacts        # fetch pinned third-party artefacts for the oracles (dev only)pnpm oracle --diff …  # KoSIT parity (Java 17+)pnpm check:zugferd    # regenerate samples, veraPDF + Mustang (Java + veraPDF)

Read CONTRIBUTING.md before opening a PR; security issues go through SECURITY.md.

Docs

License

Apache-2.0 — see LICENSE and NOTICE for bundled third-party components (KoSIT artefacts Apache-2.0, EN 16931 artefacts EUPL-1.2, Liberation Fonts OFL 1.1, ICC sRGB profile).

来源:README.md,提交 d957490

工具

0
SourceWeft 尚未在沙箱中启动过该软件包,因此其工具未知。

版本历史

1
  1. v1.0.4最新Sep 16, 2026

评分

已满足适用检查项的 50%

该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。

  • 近 30 天内可连通25 分

    请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。

  • 已声明认证方式10 分

    请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。

  • 已列出工具15 分

    请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。

  • 描述必需15 分
  • 图标10 分
  • 文档15 分
  • 许可证10 分