Skip to content

feat(mcp): saveDir option for sync_invoices tool#8

Merged
luke-cf merged 1 commit into
mainfrom
feat/sync-invoices-save-xml
May 27, 2026
Merged

feat(mcp): saveDir option for sync_invoices tool#8
luke-cf merged 1 commit into
mainfrom
feat/sync-invoices-save-xml

Conversation

@luke-cf

@luke-cf luke-cf commented May 27, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds opt-in saveDir parameter to the sync_invoices MCP tool. When set, the tool downloads the full FA(2)/FA(3) XML for each invoice (via the existing fetchInvoiceXml HTTP path) and writes one file per invoice to ${saveDir}/${ksefReferenceNumber}.xml.

Changes

  • shared: documents FetchInvoicesOpts.includeXml (was untyped before).
  • core: KsefClient.fetchInvoices accepts optional includeXml; KsefAdapter forwards it.
  • http: KsefHttpClient.fetchInvoices forwards includeXml; new public fetchInvoiceXml(token, ksefNumber) for non-MCP callers.
  • mcp: sync_invoices tool gains saveDir (absolute or relative) - when present, writes XMLs and returns savedFiles + savedCount.

Default behavior unchanged - sync_invoices without saveDir returns metadata only.

Test plan

  • Existing tests still pass (ksef.adapter.test.ts already covers rawXml round-trip)
  • CI pipeline goes green on PR (build + typecheck + unit tests on the codeformers self-hosted runner)
  • Verifies end-to-end after merge to mainprod (4-job release pipeline: verify → publish-npm → build-docs → deploy)

Adds an opt-in `saveDir` parameter to the sync_invoices MCP tool. When set,
the tool fetches the full FA(2)/FA(3) XML for each invoice (via the existing
fetchInvoiceXml HTTP path) and writes one file per invoice to
${saveDir}/${ksefReferenceNumber}.xml. mkdir -p semantics, absolute or
relative paths accepted (relative resolved against cwd of the MCP host).

Plumbing for the new option:
  shared    FetchInvoicesOpts.includeXml: documents the flag + that rawXml
            lands on Invoice.rawXml when set (was already handled by adapter).
  core      KsefClient.fetchInvoices gains optional includeXml. KsefAdapter
            forwards it to the underlying client.
  http      KsefHttpClient.fetchInvoices forwards includeXml. Adds
            fetchInvoiceXml(token, ksefNumber) public method backed by the
            existing http/invoices.ts helper so non-MCP consumers can also
            grab single XMLs.

Default behavior unchanged — fetchInvoices without includeXml still returns
metadata only.
@luke-cf luke-cf merged commit b8293f4 into main May 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant