feat(mcp): saveDir option for sync_invoices tool#8
Merged
Conversation
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.
This was referenced May 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds opt-in
saveDirparameter to thesync_invoicesMCP tool. When set, the tool downloads the full FA(2)/FA(3) XML for each invoice (via the existingfetchInvoiceXmlHTTP path) and writes one file per invoice to${saveDir}/${ksefReferenceNumber}.xml.Changes
shared: documentsFetchInvoicesOpts.includeXml(was untyped before).core:KsefClient.fetchInvoicesaccepts optionalincludeXml;KsefAdapterforwards it.http:KsefHttpClient.fetchInvoicesforwardsincludeXml; new publicfetchInvoiceXml(token, ksefNumber)for non-MCP callers.mcp:sync_invoicestool gainssaveDir(absolute or relative) - when present, writes XMLs and returnssavedFiles+savedCount.Default behavior unchanged -
sync_invoiceswithoutsaveDirreturns metadata only.Test plan
ksef.adapter.test.tsalready coversrawXmlround-trip)codeformersself-hosted runner)main→prod(4-job release pipeline: verify → publish-npm → build-docs → deploy)