@open-nav/mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,aAAa,EACb,cAAc,EACd,iBAAiB,EACjB,eAAe,GAGhB,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAuB,MAAM,kBAAkB,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AA2BvC,MAAM,SAAS,GAAG,CAAC;KAChB,IAAI,CAAC,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC;KACpC,QAAQ,CAAC,oDAAoD,CAAC,CAAC;AAElE,MAAM,QAAQ,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,2CAA2C,CAAC,CAAC;AAElG,MAAM,SAAS,GAAG,CAAC;KAChB,IAAI,CAAC,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;KAC7B,QAAQ,CAAC,sEAAsE,CAAC,CAAC;AAEpF,2EAA2E;AAC3E,SAAS,MAAM,CAAC,KAAc;IAI5B,OAAO;QACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC;QACjE,iBAAiB,EAAE,KAAgC;KACpD,CAAC;AACJ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AAE,EAAE,EAAE;QACxD,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,SAAS,IAAI,UAAU,CAAC;YAC1C,IAAI,SAAS,KAAK,SAAS,IAAI,CAAC,iBAAiB,EAAE,CAAC;gBAClD,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAC;YAC1E,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,MAAM,EAAE,CAAC,gBAAgB,CAAC;gBAC/C,kBAAkB,EAAE;oBAClB,aAAa;oBACb,gBAAgB,EAAE,SAAS;oBAC3B,GAAG,CAAC,iBAAiB;wBACnB,CAAC,CAAC,EAAE,iBAAiB,EAAE,cAAc,CAAC,iBAAiB,CAAC,CAAC,UAAU,EAAE;wBACrE,CAAC,CAAC,EAAE,CAAC;iBACR;aACF,CAAC,CAAC;YACH,MAAM,IAAI,GAAG,QAAQ,CAAC,iBAAiB,CAAC;YACxC,IAAI,CAAC,IAAI;gBAAE,OAAO,MAAM,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,CAAC;YAE1D,MAAM,OAAO,GAAG,iBAAiB,CAAC,IAAI,CAAC,WAAW,EAAE;gBAClD,UAAU,EAAE,IAAI,CAAC,0BAA0B;aAC5C,CAAC,CAAC;YACH,OAAO,MAAM,CAAC;gBACZ,KAAK,EAAE,IAAI;gBACX,aAAa;gBACb,SAAS,EAAE,IAAI,CAAC,SAAS;gBACzB,GAAG,EAAE,iBAAiB,CAAC,aAAa,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;gBAChE,OAAO;aACR,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;QACxB,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,3 @@
1
+ /** The package's own version, read from its manifest rather than duplicated. */
2
+ export declare const VERSION: string;
3
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA,gFAAgF;AAChF,eAAO,MAAM,OAAO,EAAE,MAEb,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { createRequire } from 'node:module';
2
+ /** The package's own version, read from its manifest rather than duplicated. */
3
+ export const VERSION = createRequire(import.meta.url)('../package.json').version;
4
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAE5C,gFAAgF;AAChF,MAAM,CAAC,MAAM,OAAO,GAClB,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,iBAAiB,CACjD,CAAC,OAAO,CAAC"}
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@open-nav/mcp",
3
+ "version": "0.1.0",
4
+ "description": "MCP server exposing the Hungarian NAV Online Számla invoice service to AI agents",
5
+ "keywords": [
6
+ "nav",
7
+ "onlineszamla",
8
+ "hungary",
9
+ "invoice",
10
+ "mcp",
11
+ "agent",
12
+ "ai"
13
+ ],
14
+ "license": "MIT",
15
+ "author": "open-nav contributors",
16
+ "homepage": "https://github.com/eshton/open-nav#readme",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/eshton/open-nav.git",
20
+ "directory": "packages/mcp"
21
+ },
22
+ "bugs": "https://github.com/eshton/open-nav/issues",
23
+ "type": "module",
24
+ "main": "./dist/index.js",
25
+ "types": "./dist/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "types": "./dist/index.d.ts",
29
+ "import": "./dist/index.js",
30
+ "default": "./dist/index.js"
31
+ },
32
+ "./package.json": "./package.json"
33
+ },
34
+ "bin": {
35
+ "open-nav-mcp": "./dist/bin.js"
36
+ },
37
+ "files": [
38
+ "dist",
39
+ "src",
40
+ "README.md",
41
+ "LICENSE"
42
+ ],
43
+ "sideEffects": false,
44
+ "engines": {
45
+ "node": ">=20.10.0"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ },
50
+ "dependencies": {
51
+ "@modelcontextprotocol/sdk": "^1.30.0",
52
+ "zod": "^4.5.4",
53
+ "@open-nav/client": "^0.1.0",
54
+ "@open-nav/invoicing": "^0.1.0",
55
+ "@open-nav/core": "^0.1.0"
56
+ },
57
+ "devDependencies": {
58
+ "@open-nav/mock-server": "^0.1.0"
59
+ },
60
+ "scripts": {
61
+ "build": "tsc -b"
62
+ }
63
+ }
package/src/bin.ts ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
3
+ import { createNavMcpServer } from './server.js';
4
+ import { resolveConfig } from './config.js';
5
+
6
+ const config = resolveConfig();
7
+
8
+ if (config.missing.length > 0) {
9
+ // stderr, never stdout: stdout carries the MCP protocol.
10
+ process.stderr.write(
11
+ `open-nav MCP: running with the offline tools only.\n` +
12
+ `Set ${config.missing.join(', ')} to enable the tools that talk to NAV.\n`,
13
+ );
14
+ }
15
+
16
+ const server = createNavMcpServer({
17
+ ...(config.credentials ? { credentials: config.credentials } : {}),
18
+ ...(config.software ? { software: config.software } : {}),
19
+ environment: config.environment,
20
+ ...(config.baseUrl ? { baseUrl: config.baseUrl } : {}),
21
+ });
22
+
23
+ await server.connect(new StdioServerTransport());
package/src/config.ts ADDED
@@ -0,0 +1,71 @@
1
+ import type { SoftwareType } from '@open-nav/core';
2
+ import type { NavCredentials } from '@open-nav/client';
3
+ import { VERSION } from './version.js';
4
+
5
+ /**
6
+ * Configuration from the environment, using the same variables as the CLI so
7
+ * one `.env` serves both.
8
+ *
9
+ * Credentials are never taken as tool arguments. A tool argument travels
10
+ * through the agent's context and its transcript; an environment variable does
11
+ * not.
12
+ */
13
+ export interface ResolvedConfig {
14
+ credentials?: NavCredentials;
15
+ software?: SoftwareType;
16
+ environment: 'test' | 'production';
17
+ baseUrl?: string;
18
+ /** Which required variables are absent, if any. */
19
+ missing: string[];
20
+ }
21
+
22
+ const REQUIRED = [
23
+ 'NAV_LOGIN',
24
+ 'NAV_PASSWORD',
25
+ 'NAV_SIGN_KEY',
26
+ 'NAV_EXCHANGE_KEY',
27
+ 'NAV_TAX_NUMBER',
28
+ 'NAV_SOFTWARE_ID',
29
+ ] as const;
30
+
31
+ export function resolveConfig(
32
+ env: Record<string, string | undefined> = process.env,
33
+ ): ResolvedConfig {
34
+ const missing = REQUIRED.filter((name) => !env[name]);
35
+ const environment = env['NAV_ENVIRONMENT'] === 'production' ? 'production' : 'test';
36
+
37
+ if (missing.length > 0) {
38
+ return {
39
+ environment,
40
+ missing,
41
+ ...(env['NAV_BASE_URL'] ? { baseUrl: env['NAV_BASE_URL'] } : {}),
42
+ };
43
+ }
44
+
45
+ const operation =
46
+ env['NAV_SOFTWARE_OPERATION'] === 'ONLINE_SERVICE' ? 'ONLINE_SERVICE' : 'LOCAL_SOFTWARE';
47
+
48
+ return {
49
+ credentials: {
50
+ login: env['NAV_LOGIN']!,
51
+ password: env['NAV_PASSWORD']!,
52
+ signKey: env['NAV_SIGN_KEY']!,
53
+ exchangeKey: env['NAV_EXCHANGE_KEY']!,
54
+ taxNumber: env['NAV_TAX_NUMBER']!,
55
+ },
56
+ software: {
57
+ softwareId: env['NAV_SOFTWARE_ID']!,
58
+ softwareName: env['NAV_SOFTWARE_NAME'] ?? 'open-nav',
59
+ softwareOperation: operation,
60
+ softwareMainVersion: env['NAV_SOFTWARE_VERSION'] ?? VERSION,
61
+ softwareDevName: env['NAV_SOFTWARE_DEV_NAME'] ?? 'open-nav',
62
+ softwareDevContact: env['NAV_SOFTWARE_DEV_CONTACT'] ?? 'unknown',
63
+ ...(env['NAV_SOFTWARE_DEV_TAX_NUMBER']
64
+ ? { softwareDevTaxNumber: env['NAV_SOFTWARE_DEV_TAX_NUMBER'] }
65
+ : {}),
66
+ },
67
+ environment,
68
+ ...(env['NAV_BASE_URL'] ? { baseUrl: env['NAV_BASE_URL'] } : {}),
69
+ missing: [],
70
+ };
71
+ }
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './server.js';
2
+ export * from './config.js';
package/src/server.ts ADDED
@@ -0,0 +1,468 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { z } from 'zod';
3
+ import {
4
+ NavApiError,
5
+ decodeInvoiceData,
6
+ faultMessage,
7
+ parseDocument,
8
+ parseTaxNumber,
9
+ serializeDocument,
10
+ validateInvoice,
11
+ type InvoiceData,
12
+ type SoftwareType,
13
+ } from '@open-nav/core';
14
+ import { NavClient, waitForTransaction, type NavCredentials } from '@open-nav/client';
15
+ import { createDataExport, renderInvoiceHtml } from '@open-nav/invoicing';
16
+ import { VERSION } from './version.js';
17
+
18
+ /**
19
+ * MCP server for the Online Számla invoice service.
20
+ *
21
+ * Shaped for an agent rather than for a person. Three things follow from
22
+ * that:
23
+ *
24
+ * - Tools that need no credentials are always registered, so an agent can
25
+ * validate and render invoices before anyone has a technical user.
26
+ * - Tools that reach NAV are registered only when credentials are present,
27
+ * so an agent is never offered a tool that cannot work, and never has to
28
+ * discover that by calling it.
29
+ * - Every result is structured content, not prose, and a validation failure
30
+ * is a normal result rather than an error: the fault list *is* the answer.
31
+ */
32
+
33
+ export interface NavMcpOptions {
34
+ /** Credentials. Omit to run with the offline tools only. */
35
+ credentials?: NavCredentials;
36
+ software?: SoftwareType;
37
+ environment?: 'test' | 'production';
38
+ baseUrl?: string;
39
+ /** Injected for tests. */
40
+ createClient?: (options: { credentials: NavCredentials }) => NavClient;
41
+ }
42
+
43
+ const OPERATION = z
44
+ .enum(['CREATE', 'MODIFY', 'STORNO'])
45
+ .describe('The operation the document will be submitted under');
46
+
47
+ const LANGUAGE = z.enum(['en', 'hu', 'de']).describe("Language for NAV's own fault descriptions");
48
+
49
+ const DIRECTION = z
50
+ .enum(['OUTBOUND', 'INBOUND'])
51
+ .describe('OUTBOUND for invoices you issued, INBOUND for invoices issued to you');
52
+
53
+ /** Wrap a value as an MCP tool result carrying both text and structure. */
54
+ function result(value: unknown): {
55
+ content: Array<{ type: 'text'; text: string }>;
56
+ structuredContent: Record<string, unknown>;
57
+ } {
58
+ return {
59
+ content: [{ type: 'text', text: JSON.stringify(value, null, 2) }],
60
+ structuredContent: value as Record<string, unknown>,
61
+ };
62
+ }
63
+
64
+ /** An error an agent can act on, rather than a stack trace. */
65
+ function failure(error: unknown): {
66
+ content: Array<{ type: 'text'; text: string }>;
67
+ isError: true;
68
+ } {
69
+ const detail =
70
+ error instanceof NavApiError
71
+ ? {
72
+ message: error.message,
73
+ errorCode: error.errorCode,
74
+ funcCode: error.funcCode,
75
+ status: error.status,
76
+ validationMessages: error.validationMessages,
77
+ }
78
+ : { message: (error as Error).message ?? String(error) };
79
+ return { content: [{ type: 'text', text: JSON.stringify(detail, null, 2) }], isError: true };
80
+ }
81
+
82
+ function parseInvoice(xml: string): InvoiceData {
83
+ const parsed = parseDocument(xml, { unknownElements: 'ignore' });
84
+ if (parsed.root !== 'InvoiceData') {
85
+ throw new Error(`Expected an InvoiceData document, found ${parsed.root}`);
86
+ }
87
+ return parsed.value as InvoiceData;
88
+ }
89
+
90
+ export function createNavMcpServer(options: NavMcpOptions = {}): McpServer {
91
+ const server = new McpServer({ name: 'open-nav', version: VERSION });
92
+ registerOfflineTools(server);
93
+ if (options.credentials && options.software) {
94
+ registerOnlineTools(server, {
95
+ ...options,
96
+ credentials: options.credentials,
97
+ software: options.software,
98
+ });
99
+ }
100
+ return server;
101
+ }
102
+
103
+ /** Tools that contact nothing and need no credentials. */
104
+ function registerOfflineTools(server: McpServer): void {
105
+ server.registerTool(
106
+ 'validate_invoice',
107
+ {
108
+ title: 'Validate invoice data',
109
+ description:
110
+ 'Check NAV invoice data (InvoiceData XML) against the schema and the business rules ' +
111
+ 'that are decidable from the document alone. Returns every finding with NAV’s own ' +
112
+ 'fault code, so a failure here names what the service would have rejected. Needs no ' +
113
+ 'credentials. Errors block a submission; warnings do not.',
114
+ inputSchema: {
115
+ xml: z.string().describe('The InvoiceData XML document to check'),
116
+ operation: OPERATION.optional(),
117
+ language: LANGUAGE.optional(),
118
+ },
119
+ annotations: { readOnlyHint: true, openWorldHint: false },
120
+ },
121
+ async ({ xml, operation, language }) => {
122
+ try {
123
+ const report = validateInvoice(parseInvoice(xml), {
124
+ ...(operation ? { operation } : {}),
125
+ ...(language ? { language } : {}),
126
+ });
127
+ // A failed validation is the answer, not an error.
128
+ return result({
129
+ valid: report.valid,
130
+ errorCount: report.errors.length,
131
+ warningCount: report.warnings.length,
132
+ issues: report.issues,
133
+ });
134
+ } catch (error) {
135
+ return failure(error);
136
+ }
137
+ },
138
+ );
139
+
140
+ server.registerTool(
141
+ 'lookup_fault_code',
142
+ {
143
+ title: 'Look up a NAV fault code',
144
+ description:
145
+ 'Explain a NAV validation fault code, such as INCORRECT_SUMMARY_CALCULATION_' +
146
+ "INVOICE_VAT_AMOUNT_SUMMARY, in NAV's own words. Use this to interpret a rejection.",
147
+ inputSchema: {
148
+ code: z.string().describe('The fault code, as NAV reported it'),
149
+ language: LANGUAGE.optional(),
150
+ },
151
+ annotations: { readOnlyHint: true, openWorldHint: false },
152
+ },
153
+ async ({ code, language }) => {
154
+ const normalised = code.trim().toUpperCase();
155
+ const message = faultMessage(normalised as 'SCHEMA_VIOLATION', language ?? 'en');
156
+ if (!message) {
157
+ return failure(new Error(`NAV defines no fault code ${normalised}`));
158
+ }
159
+ return result({ code: normalised, language: language ?? 'en', message });
160
+ },
161
+ );
162
+
163
+ server.registerTool(
164
+ 'render_invoice',
165
+ {
166
+ title: 'Render a printable invoice',
167
+ description:
168
+ 'Render NAV invoice data as a self-contained, printable HTML invoice, with the phrases ' +
169
+ 'the VAT Act requires derived from the data. Convert to PDF with any browser. Needs no ' +
170
+ 'credentials.',
171
+ inputSchema: {
172
+ xml: z.string().describe('The InvoiceData XML document to render'),
173
+ language: z
174
+ .enum(['hu', 'en'])
175
+ .optional()
176
+ .describe('Document language, Hungarian by default'),
177
+ note: z.string().optional().describe('Extra note printed under the totals'),
178
+ },
179
+ annotations: { readOnlyHint: true, openWorldHint: false },
180
+ },
181
+ async ({ xml, language, note }) => {
182
+ try {
183
+ const html = renderInvoiceHtml(parseInvoice(xml), {
184
+ ...(language ? { language } : {}),
185
+ ...(note ? { note } : {}),
186
+ });
187
+ return {
188
+ content: [{ type: 'text' as const, text: html }],
189
+ structuredContent: { html, bytes: html.length },
190
+ };
191
+ } catch (error) {
192
+ return failure(error);
193
+ }
194
+ },
195
+ );
196
+
197
+ server.registerTool(
198
+ 'export_invoices',
199
+ {
200
+ title: 'Produce the tax authority data export',
201
+ description:
202
+ 'Build the data export required of invoicing programs by decree 23/2014. (VI. 30.) NGM ' +
203
+ 'from a set of InvoiceData documents, selected by issue date or invoice number range. ' +
204
+ 'Returns the files rather than writing them. Needs no credentials.',
205
+ inputSchema: {
206
+ invoices: z.array(z.string()).describe('InvoiceData XML documents'),
207
+ issueDateFrom: z.string().optional().describe('First issue date, inclusive, as yyyy-mm-dd'),
208
+ issueDateTo: z.string().optional().describe('Last issue date, inclusive'),
209
+ invoiceNumberFrom: z.string().optional(),
210
+ invoiceNumberTo: z.string().optional(),
211
+ },
212
+ annotations: { readOnlyHint: true, openWorldHint: false },
213
+ },
214
+ async ({ invoices, ...selection }) => {
215
+ try {
216
+ const parsed = invoices.map((xml) => parseInvoice(xml));
217
+ const exported = createDataExport(parsed, selection);
218
+ return result({
219
+ manifest: exported.manifest,
220
+ files: exported.files,
221
+ });
222
+ } catch (error) {
223
+ return failure(error);
224
+ }
225
+ },
226
+ );
227
+ }
228
+
229
+ /** Tools that talk to NAV. Registered only when credentials are configured. */
230
+ function registerOnlineTools(
231
+ server: McpServer,
232
+ options: NavMcpOptions & { credentials: NavCredentials; software: SoftwareType },
233
+ ): void {
234
+ const client = (): NavClient =>
235
+ options.createClient
236
+ ? options.createClient({ credentials: options.credentials })
237
+ : new NavClient({
238
+ credentials: options.credentials,
239
+ software: options.software,
240
+ environment: options.environment ?? 'test',
241
+ ...(options.baseUrl ? { baseUrl: options.baseUrl } : {}),
242
+ });
243
+
244
+ server.registerTool(
245
+ 'query_taxpayer',
246
+ {
247
+ title: 'Look up a Hungarian taxpayer',
248
+ description:
249
+ "Check whether a Hungarian tax number is valid and registered, and get the taxpayer's " +
250
+ 'name. This is the authoritative check on a tax number; a check digit is not. Accepts ' +
251
+ 'the 8 digit core or the 11 digit written form.',
252
+ inputSchema: { taxNumber: z.string().describe('8 or 11 digit Hungarian tax number') },
253
+ annotations: { readOnlyHint: true, openWorldHint: true },
254
+ },
255
+ async ({ taxNumber }) => {
256
+ try {
257
+ const { taxpayerId } = parseTaxNumber(taxNumber);
258
+ const response = await client().queryTaxpayer({ taxNumber: taxpayerId });
259
+ return result({
260
+ taxNumber: taxpayerId,
261
+ valid: response.taxpayerValidity ?? false,
262
+ taxpayer: response.taxpayerData ?? null,
263
+ });
264
+ } catch (error) {
265
+ return failure(error);
266
+ }
267
+ },
268
+ );
269
+
270
+ server.registerTool(
271
+ 'submit_invoices',
272
+ {
273
+ title: 'Submit invoice data to NAV',
274
+ description:
275
+ 'Report invoice data to NAV. Validates locally first and refuses to submit a document ' +
276
+ 'with errors, because a rejection costs a round trip and consumes the request id. ' +
277
+ 'Returns the transaction id, and the per-invoice verdict when waitForVerdict is set. ' +
278
+ 'This reports data to the tax authority and cannot be undone except by a technical ' +
279
+ 'annulment.',
280
+ inputSchema: {
281
+ invoices: z.array(z.string()).describe('InvoiceData XML documents to report'),
282
+ operation: OPERATION.optional(),
283
+ compress: z.boolean().optional().describe('Gzip the payloads'),
284
+ waitForVerdict: z
285
+ .boolean()
286
+ .optional()
287
+ .describe('Poll until NAV decides, and return the per-invoice outcome'),
288
+ },
289
+ annotations: {
290
+ readOnlyHint: false,
291
+ destructiveHint: false,
292
+ idempotentHint: false,
293
+ openWorldHint: true,
294
+ },
295
+ },
296
+ async ({ invoices, operation, compress, waitForVerdict }) => {
297
+ try {
298
+ const parsed = invoices.map((xml) => parseInvoice(xml));
299
+ const effective = operation ?? 'CREATE';
300
+
301
+ const blocking = parsed
302
+ .map((invoice, index) => ({
303
+ index,
304
+ report: validateInvoice(invoice, { operation: effective }),
305
+ }))
306
+ .filter((entry) => !entry.report.valid);
307
+
308
+ if (blocking.length > 0) {
309
+ return result({
310
+ submitted: false,
311
+ reason: 'local validation failed',
312
+ invalid: blocking.map((entry) => ({
313
+ index: entry.index,
314
+ errors: entry.report.errors,
315
+ })),
316
+ });
317
+ }
318
+
319
+ const navClient = client();
320
+ const response = await navClient.submitInvoices(
321
+ parsed.map((invoice) => ({ operation: effective, invoice })),
322
+ { compress: compress ?? false },
323
+ );
324
+
325
+ if (!waitForVerdict) {
326
+ return result({
327
+ submitted: true,
328
+ transactionId: response.transactionId,
329
+ count: parsed.length,
330
+ });
331
+ }
332
+
333
+ const outcome = await waitForTransaction(navClient, response.transactionId);
334
+ return result({
335
+ submitted: true,
336
+ transactionId: response.transactionId,
337
+ accepted: outcome.accepted.length,
338
+ rejected: outcome.rejected.length,
339
+ results: outcome.results,
340
+ });
341
+ } catch (error) {
342
+ return failure(error);
343
+ }
344
+ },
345
+ );
346
+
347
+ server.registerTool(
348
+ 'transaction_status',
349
+ {
350
+ title: 'Check a submission',
351
+ description:
352
+ 'Get the processing status of a submitted transaction. NAV validates asynchronously, ' +
353
+ 'so a submission has no verdict until this reports one.',
354
+ inputSchema: {
355
+ transactionId: z.string(),
356
+ waitForVerdict: z.boolean().optional().describe('Poll until NAV decides'),
357
+ },
358
+ annotations: { readOnlyHint: true, openWorldHint: true },
359
+ },
360
+ async ({ transactionId, waitForVerdict }) => {
361
+ try {
362
+ const navClient = client();
363
+ if (waitForVerdict) {
364
+ const outcome = await waitForTransaction(navClient, transactionId);
365
+ return result({
366
+ transactionId,
367
+ accepted: outcome.accepted.length,
368
+ rejected: outcome.rejected.length,
369
+ results: outcome.results,
370
+ });
371
+ }
372
+ const response = await navClient.queryTransactionStatus({ transactionId });
373
+ return result({
374
+ transactionId,
375
+ results: response.processingResults?.processingResult ?? [],
376
+ });
377
+ } catch (error) {
378
+ return failure(error);
379
+ }
380
+ },
381
+ );
382
+
383
+ server.registerTool(
384
+ 'list_invoices',
385
+ {
386
+ title: 'List invoices in a date range',
387
+ description:
388
+ 'List invoices issued by you (OUTBOUND) or issued to you (INBOUND) in a range of issue ' +
389
+ 'dates. Returns a summary per invoice; use get_invoice for the full data. Paged, 100 ' +
390
+ 'per page.',
391
+ inputSchema: {
392
+ dateFrom: z.string().describe('First issue date, inclusive, as yyyy-mm-dd'),
393
+ dateTo: z.string().describe('Last issue date, inclusive, as yyyy-mm-dd'),
394
+ direction: DIRECTION.optional(),
395
+ page: z.number().int().min(1).optional(),
396
+ },
397
+ annotations: { readOnlyHint: true, openWorldHint: true },
398
+ },
399
+ async ({ dateFrom, dateTo, direction, page }) => {
400
+ try {
401
+ const response = await client().queryInvoiceDigest({
402
+ page: page ?? 1,
403
+ invoiceDirection: direction ?? 'OUTBOUND',
404
+ invoiceQueryParams: { mandatoryQueryParams: { invoiceIssueDate: { dateFrom, dateTo } } },
405
+ });
406
+ const digest = response.invoiceDigestResult;
407
+ return result({
408
+ page: digest.currentPage,
409
+ availablePages: digest.availablePage,
410
+ invoices: digest.invoiceDigest ?? [],
411
+ });
412
+ } catch (error) {
413
+ return failure(error);
414
+ }
415
+ },
416
+ );
417
+
418
+ server.registerTool(
419
+ 'get_invoice',
420
+ {
421
+ title: 'Fetch one invoice in full',
422
+ description:
423
+ 'Fetch the complete data of one invoice by number, as reported to NAV. Returns the ' +
424
+ 'invoice as XML and as structured data.',
425
+ inputSchema: {
426
+ invoiceNumber: z.string(),
427
+ direction: DIRECTION.optional(),
428
+ supplierTaxNumber: z
429
+ .string()
430
+ .optional()
431
+ .describe('Required for an inbound invoice: who issued it'),
432
+ },
433
+ annotations: { readOnlyHint: true, openWorldHint: true },
434
+ },
435
+ async ({ invoiceNumber, direction, supplierTaxNumber }) => {
436
+ try {
437
+ const requested = direction ?? 'OUTBOUND';
438
+ if (requested === 'INBOUND' && !supplierTaxNumber) {
439
+ throw new Error('supplierTaxNumber is required for an inbound invoice');
440
+ }
441
+ const response = await client().queryInvoiceData({
442
+ invoiceNumberQuery: {
443
+ invoiceNumber,
444
+ invoiceDirection: requested,
445
+ ...(supplierTaxNumber
446
+ ? { supplierTaxNumber: parseTaxNumber(supplierTaxNumber).taxpayerId }
447
+ : {}),
448
+ },
449
+ });
450
+ const data = response.invoiceDataResult;
451
+ if (!data) return result({ found: false, invoiceNumber });
452
+
453
+ const invoice = decodeInvoiceData(data.invoiceData, {
454
+ compressed: data.compressedContentIndicator,
455
+ });
456
+ return result({
457
+ found: true,
458
+ invoiceNumber,
459
+ auditData: data.auditData,
460
+ xml: serializeDocument('InvoiceData', invoice, { indent: ' ' }),
461
+ invoice,
462
+ });
463
+ } catch (error) {
464
+ return failure(error);
465
+ }
466
+ },
467
+ );
468
+ }
package/src/version.ts ADDED
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'node:module';
2
+
3
+ /** The package's own version, read from its manifest rather than duplicated. */
4
+ export const VERSION: string = (
5
+ createRequire(import.meta.url)('../package.json') as { version: string }
6
+ ).version;