@ausvector/cli 1.0.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.
Files changed (4) hide show
  1. package/LICENSE +191 -0
  2. package/README.md +26 -0
  3. package/dist/bin.mjs +434 -0
  4. package/package.json +27 -0
package/LICENSE ADDED
@@ -0,0 +1,191 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work.
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object
40
+ form, that is based on (or derived from) the Work and for which the
41
+ editorial revisions, annotations, elaborations, or other modifications
42
+ represent, as a whole, an original work of authorship. For the purposes
43
+ of this License, Derivative Works shall not include works that remain
44
+ separable from, or merely link to, the interfaces of the Work and
45
+ Derivative Works thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including the
48
+ original version of the Work and any modifications or additions
49
+ to that Work or Derivative Works thereof, that is intentionally
50
+ submitted to Licensor for inclusion in the Work by the copyright owner
51
+ or by an individual or Legal Entity authorized to submit on behalf of
52
+ the copyright owner. For the purposes of this definition, "submitted"
53
+ means any form of electronic, verbal, or written communication sent
54
+ to the Licensor or its representatives, including communication on
55
+ electronic mailing lists, source code control systems, and issue
56
+ tracking systems that are managed by, or on behalf of, the Licensor
57
+ for the purpose of discussing and improving the Work, but excluding
58
+ communication that is conspicuously marked or otherwise designated
59
+ in writing by the copyright owner as "Not a Contribution."
60
+
61
+ "Contributor" shall mean Licensor and any individual or Legal Entity
62
+ on behalf of whom a Contribution has been received by Licensor and
63
+ subsequently incorporated within the Work.
64
+
65
+ 2. Grant of Copyright License. Subject to the terms and conditions of
66
+ this License, each Contributor hereby grants to You a perpetual,
67
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
68
+ copyright license to reproduce, prepare Derivative Works of,
69
+ publicly display, publicly perform, sublicense, and distribute the
70
+ Work and such Derivative Works in Source or Object form.
71
+
72
+ 3. Grant of Patent License. Subject to the terms and conditions of
73
+ this License, each Contributor hereby grants to You a perpetual,
74
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
75
+ (except as stated in this section) patent license to make, have made,
76
+ use, offer to sell, sell, import, and otherwise transfer the Work,
77
+ where such license applies only to those patent claims licensable
78
+ by such Contributor that are necessarily infringed by their
79
+ Contribution(s) alone or by combination of their Contribution(s)
80
+ with the Work to which such Contribution(s) was submitted. If You
81
+ institute patent litigation against any entity alleging that the
82
+ Work or a Contribution incorporated within the Work constitutes
83
+ direct or contributory patent infringement, then any patent licenses
84
+ granted to You under this License for that Work shall terminate
85
+ as of the date such litigation is filed.
86
+
87
+ 4. Redistribution. You may reproduce and distribute copies of the
88
+ Work or Derivative Works thereof in any medium, with or without
89
+ modifications, and in Source or Object form, provided that You meet
90
+ the following conditions:
91
+
92
+ (a) You must give any other recipients of the Work or Derivative Works
93
+ a copy of this License; and
94
+
95
+ (b) You must cause any modified files to carry prominent notices
96
+ stating that You changed the files; and
97
+
98
+ (c) You must retain, in the Source form of any Derivative Works that
99
+ You distribute, all copyright, patent, trademark, and attribution
100
+ notices from the Source form of the Work, excluding those notices
101
+ that do not pertain to any part of the Derivative Works; and
102
+
103
+ (d) If the Work includes a "NOTICE" text file as part of its
104
+ distribution, then any Derivative Works that You distribute must
105
+ include a readable copy of the attribution notices contained
106
+ within such NOTICE file. The contents of the NOTICE file are for
107
+ informational purposes only and do not modify the License. You may
108
+ add Your own attribution notices within Derivative Works that You
109
+ distribute, alongside or as an addendum to the NOTICE text from
110
+ the Work, provided that such additional attribution notices cannot
111
+ be construed as modifying the License.
112
+
113
+ You may add Your own copyright statement to Your modifications and
114
+ may provide additional or different license terms and conditions
115
+ for use, reproduction, or distribution of Your modifications, or
116
+ for any such Derivative Works as a whole, provided Your use,
117
+ reproduction, and distribution of the Work otherwise complies with
118
+ the conditions stated in this License.
119
+
120
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
121
+ any Contribution intentionally submitted for inclusion in the Work
122
+ by You to the Licensor shall be under the terms and conditions of
123
+ this License, without any additional terms or conditions.
124
+ Notwithstanding the above, nothing herein shall supersede or modify
125
+ the terms of any separate license agreement you may have executed
126
+ with Licensor regarding such Contributions.
127
+
128
+ 6. Trademarks. This License does not grant permission to use the trade
129
+ names, trademarks, service marks, or product names of the Licensor,
130
+ except as required for reasonable and customary use in describing
131
+ the origin of the Work and reproducing the content of the NOTICE file.
132
+
133
+ 7. Disclaimer of Warranty. Unless required by applicable law or
134
+ agreed to in writing, Licensor provides the Work (and each
135
+ Contributor provides its Contributions) on an "AS IS" BASIS,
136
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
137
+ implied, including, without limitation, any warranties or conditions
138
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
139
+ PARTICULAR PURPOSE. You are solely responsible for determining the
140
+ appropriateness of using or redistributing the Work and assume any
141
+ risks associated with Your exercise of permissions under this License.
142
+
143
+ 8. Limitation of Liability. In no event and under no legal theory,
144
+ whether in tort (including negligence), contract, or otherwise,
145
+ unless required by applicable law (such as deliberate and grossly
146
+ negligent acts) or agreed to in writing, shall any Contributor be
147
+ liable to You for damages, including any direct, indirect, special,
148
+ incidental, or consequential damages of any character arising as a
149
+ result of this License or out of the use or inability to use the
150
+ Work (including but not limited to damages for loss of goodwill,
151
+ work stoppage, computer failure or malfunction, or any and all
152
+ other commercial damages or losses), even if such Contributor
153
+ has been advised of the possibility of such damages.
154
+
155
+ 9. Accepting Warranty or Additional Liability. While redistributing
156
+ the Work or Derivative Works thereof, You may choose to offer,
157
+ and charge a fee for, acceptance of support, warranty, indemnity,
158
+ or other liability obligations and/or rights consistent with this
159
+ License. However, in accepting such obligations, You may act only
160
+ on Your own behalf and on Your sole responsibility, not on behalf
161
+ of any other Contributor, and only if You agree to indemnify,
162
+ defend, and hold each Contributor harmless for any liability
163
+ incurred by, or claims asserted against, such Contributor by reason
164
+ of your accepting any such warranty or additional liability.
165
+
166
+ END OF TERMS AND CONDITIONS
167
+
168
+ APPENDIX: How to apply the Apache License to your work.
169
+
170
+ To apply the Apache License to your work, attach the following
171
+ boilerplate notice, with the fields enclosed by brackets "[]"
172
+ replaced with your own identifying information. (Don't include
173
+ the brackets!) The text should be enclosed in the appropriate
174
+ comment syntax for the file format. We also recommend that a
175
+ file or class name and description of purpose be included on the
176
+ same "printed page" as the copyright notice for easier identification
177
+ within third-party archives.
178
+
179
+ Copyright [yyyy] [name of copyright owner]
180
+
181
+ Licensed under the Apache License, Version 2.0 (the "License");
182
+ you may not use this file except in compliance with the License.
183
+ You may obtain a copy of the License at
184
+
185
+ http://www.apache.org/licenses/LICENSE-2.0
186
+
187
+ Unless required by applicable law or agreed to in writing, software
188
+ distributed under the License is distributed on an "AS IS" BASIS,
189
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
190
+ See the License for the specific language governing permissions and
191
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,26 @@
1
+ # @ausvector/cli
2
+
3
+ The Ausvector command-line client connects to the Ausvector Streamable HTTP MCP service.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install --global @ausvector/cli
9
+ ```
10
+
11
+ Set an API key with the `align:address` scope before using remote commands:
12
+
13
+ ```bash
14
+ set AUSVECTOR_API_KEY=your_api_key
15
+ ausvector tools list
16
+ ausvector suburb search "Sydney"
17
+ ausvector suburb summary --suburb "Sydney" --state NSW --postcode 2000
18
+ ```
19
+
20
+ Use `--format json` for machine-readable output. The CLI does not store credentials and does not accept API keys as command-line arguments.
21
+
22
+ ## License and data
23
+
24
+ The CLI source is licensed under Apache-2.0. This license does not grant rights to Ausvector trademarks, the remote service, API credentials, or the data returned by the service. Service terms, data-provider terms, and the G-NAF Core licence continue to apply to API usage.
25
+
26
+ Copyright 2026 Ausdata Science Pty Ltd.
package/dist/bin.mjs ADDED
@@ -0,0 +1,434 @@
1
+ #!/usr/bin/env node
2
+ import { defineCommand, runCommand } from "citty";
3
+ import { Client, StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
4
+
5
+ //#region ../../src/config/version.ts
6
+ /** MCP server release version. Increment independently from the HTTP API. */
7
+ const MCP_SERVER_VERSION = "1.2.0";
8
+ const SERVICE_VERSION = MCP_SERVER_VERSION;
9
+ /**
10
+ * The SDK's LATEST_PROTOCOL_VERSION identifies its legacy wire revision.
11
+ * createMcpHandler serves this explicit modern revision instead.
12
+ */
13
+ const MCP_PROTOCOL_VERSION = "2026-07-28";
14
+ const VERSION = `Ausdata MCP Server v${SERVICE_VERSION}`;
15
+
16
+ //#endregion
17
+ //#region ../../src/cli/mcp-client.ts
18
+ const DEFAULT_MCP_ENDPOINT = "https://mcp.ausvector.ai/mcp";
19
+ function parseEndpoint(value) {
20
+ const endpoint = value?.trim() || DEFAULT_MCP_ENDPOINT;
21
+ const url = new URL(endpoint);
22
+ if (url.protocol !== "https:" && !(url.protocol === "http:" && ["localhost", "127.0.0.1"].includes(url.hostname))) throw new Error("MCP endpoint must use HTTPS, except for localhost development endpoints.");
23
+ return url;
24
+ }
25
+ function getApiKey(env = process.env) {
26
+ const apiKey = env.AUSVECTOR_API_KEY?.trim();
27
+ if (!apiKey) throw new Error("AUSVECTOR_API_KEY is required. Set it in the environment before running this command.");
28
+ return apiKey;
29
+ }
30
+ async function createMcpClient(options) {
31
+ const apiKey = options.apiKey.trim();
32
+ if (!apiKey) throw new Error("AUSVECTOR_API_KEY must not be empty.");
33
+ const client = new Client({
34
+ name: "ausvector-cli",
35
+ version: "1.0.0"
36
+ }, { versionNegotiation: { mode: { pin: MCP_PROTOCOL_VERSION } } });
37
+ const transport = new StreamableHTTPClientTransport(parseEndpoint(options.endpoint), { authProvider: { token: async () => apiKey } });
38
+ await client.connect(transport, { timeout: options.timeoutMs ?? 1e4 });
39
+ return {
40
+ async listTools() {
41
+ return (await client.listTools(void 0, { timeout: options.timeoutMs ?? 1e4 })).tools.map((tool) => ({
42
+ name: tool.name,
43
+ title: tool.title,
44
+ description: tool.description,
45
+ inputSchema: tool.inputSchema
46
+ }));
47
+ },
48
+ async callTool(name, args) {
49
+ const result = await client.callTool({
50
+ name,
51
+ arguments: args
52
+ }, { timeout: options.timeoutMs ?? 1e4 });
53
+ return {
54
+ content: result.content,
55
+ structuredContent: result.structuredContent,
56
+ isError: result.isError
57
+ };
58
+ },
59
+ close() {
60
+ return client.close();
61
+ }
62
+ };
63
+ }
64
+
65
+ //#endregion
66
+ //#region ../../src/cli/commands.ts
67
+ const connectionArgs = {
68
+ endpoint: {
69
+ type: "string",
70
+ description: "MCP endpoint URL."
71
+ },
72
+ timeout: {
73
+ type: "string",
74
+ description: "Request timeout in milliseconds.",
75
+ default: "10000"
76
+ },
77
+ format: {
78
+ type: "string",
79
+ description: "Output format: table or json.",
80
+ default: "table"
81
+ }
82
+ };
83
+ function parseFormat(value) {
84
+ if (value === "json" || value === "table") return value;
85
+ throw new Error("--format must be either table or json.");
86
+ }
87
+ function parseTimeout(value) {
88
+ const timeout = Number.parseInt(value, 10);
89
+ if (!Number.isSafeInteger(timeout) || timeout < 250 || timeout > 12e4) throw new Error("--timeout must be an integer between 250 and 120000 milliseconds.");
90
+ return timeout;
91
+ }
92
+ function parseLimit(value) {
93
+ const limit = Number.parseInt(value, 10);
94
+ if (!Number.isSafeInteger(limit) || limit < 1 || limit > 20) throw new Error("--limit must be an integer between 1 and 20.");
95
+ return limit;
96
+ }
97
+ function resolveEndpoint(value, env) {
98
+ return value?.trim() || env.AUSVECTOR_MCP_ENDPOINT?.trim() || DEFAULT_MCP_ENDPOINT;
99
+ }
100
+ function cell(value) {
101
+ if (value === null || value === void 0 || value === "") return "-";
102
+ return String(value).replace(/[\r\n]+/g, " ");
103
+ }
104
+ function table(headers, rows) {
105
+ const widths = headers.map((header, index) => Math.max(header.length, ...rows.map((row) => cell(row[index]).length)));
106
+ const formatRow = (row) => row.map((value, index) => cell(value).padEnd(widths[index])).join(" ");
107
+ return [
108
+ formatRow(headers),
109
+ widths.map((width) => "-".repeat(width)).join(" "),
110
+ ...rows.map(formatRow)
111
+ ].join("\n");
112
+ }
113
+ function emit(runtimeValue, format, value, headers, rows) {
114
+ if (format === "json" || !headers || !rows) {
115
+ runtimeValue.stdout(JSON.stringify(value, null, 2));
116
+ return;
117
+ }
118
+ runtimeValue.stdout(table(headers, rows));
119
+ }
120
+ function record(value) {
121
+ return typeof value === "object" && value !== null ? value : {};
122
+ }
123
+ function resultData(result) {
124
+ if (result.isError) {
125
+ const text = Array.isArray(result.content) ? result.content.map((item) => record(item).text).filter((value) => typeof value === "string").join(" ") : "";
126
+ throw new Error(text || "The MCP tool reported an error.");
127
+ }
128
+ return result.structuredContent ?? result.content ?? null;
129
+ }
130
+ function redactError(error) {
131
+ return (error instanceof Error ? error.message : "CLI command failed.").replace(/Bearer\s+[^\s"']+/gi, "Bearer [REDACTED]").replace(/am_sk_[A-Za-z0-9+/=_-]+/g, "[REDACTED]");
132
+ }
133
+ async function withClient(runtimeValue, context, action) {
134
+ const args = context.args;
135
+ const client = await runtimeValue.createClient({
136
+ apiKey: getApiKey(runtimeValue.env),
137
+ endpoint: resolveEndpoint(args.endpoint, runtimeValue.env),
138
+ timeoutMs: parseTimeout(args.timeout)
139
+ });
140
+ try {
141
+ await action(client, parseFormat(args.format));
142
+ } finally {
143
+ await client.close();
144
+ }
145
+ }
146
+ function toolRows(tools) {
147
+ return tools.map((tool) => [
148
+ tool.name,
149
+ tool.title,
150
+ tool.description
151
+ ]);
152
+ }
153
+ function createRootCommand(runtimeValue) {
154
+ return defineCommand({
155
+ meta: {
156
+ name: "ausvector",
157
+ version: "1.0.0",
158
+ description: "Ausvector MCP command-line client."
159
+ },
160
+ subCommands: {
161
+ auth: defineCommand({
162
+ meta: {
163
+ name: "auth",
164
+ description: "Inspect API key availability."
165
+ },
166
+ subCommands: { status: defineCommand({
167
+ meta: {
168
+ name: "status",
169
+ description: "Report whether AUSVECTOR_API_KEY is configured."
170
+ },
171
+ args: {
172
+ format: connectionArgs.format,
173
+ endpoint: connectionArgs.endpoint
174
+ },
175
+ run(context) {
176
+ const args = context.args;
177
+ const configured = Boolean(runtimeValue.env.AUSVECTOR_API_KEY?.trim());
178
+ const value = {
179
+ configured,
180
+ credentialSource: configured ? "AUSVECTOR_API_KEY" : null,
181
+ endpoint: resolveEndpoint(args.endpoint, runtimeValue.env)
182
+ };
183
+ emit(runtimeValue, parseFormat(args.format), value, [
184
+ "CONFIGURED",
185
+ "SOURCE",
186
+ "ENDPOINT"
187
+ ], [[
188
+ configured ? "yes" : "no",
189
+ value.credentialSource,
190
+ value.endpoint
191
+ ]]);
192
+ }
193
+ }) }
194
+ }),
195
+ tools: defineCommand({
196
+ meta: {
197
+ name: "tools",
198
+ description: "Discover remote MCP tools."
199
+ },
200
+ subCommands: { list: defineCommand({
201
+ meta: {
202
+ name: "list",
203
+ description: "List available remote MCP tools."
204
+ },
205
+ args: connectionArgs,
206
+ run(context) {
207
+ return withClient(runtimeValue, context, async (client, format) => {
208
+ const tools = await client.listTools();
209
+ emit(runtimeValue, format, { tools }, [
210
+ "NAME",
211
+ "TITLE",
212
+ "DESCRIPTION"
213
+ ], toolRows(tools));
214
+ });
215
+ }
216
+ }) }
217
+ }),
218
+ call: defineCommand({
219
+ meta: {
220
+ name: "call",
221
+ description: "Call an MCP tool with a JSON object."
222
+ },
223
+ args: {
224
+ name: {
225
+ type: "positional",
226
+ required: true,
227
+ description: "Tool name."
228
+ },
229
+ args: {
230
+ type: "string",
231
+ required: true,
232
+ description: "JSON object passed as tool arguments."
233
+ },
234
+ ...connectionArgs
235
+ },
236
+ run(context) {
237
+ return withClient(runtimeValue, context, async (client, format) => {
238
+ const args = context.args;
239
+ let toolArgs;
240
+ try {
241
+ toolArgs = JSON.parse(args.args);
242
+ } catch {
243
+ throw new Error("--args must be valid JSON.");
244
+ }
245
+ if (!toolArgs || typeof toolArgs !== "object" || Array.isArray(toolArgs)) throw new Error("--args must be a JSON object.");
246
+ emit(runtimeValue, format, resultData(await client.callTool(args.name, toolArgs)));
247
+ });
248
+ }
249
+ }),
250
+ address: defineCommand({
251
+ meta: {
252
+ name: "address",
253
+ description: "Address search commands."
254
+ },
255
+ subCommands: { search: defineCommand({
256
+ meta: {
257
+ name: "search",
258
+ description: "Search Australian addresses."
259
+ },
260
+ args: {
261
+ query: {
262
+ type: "positional",
263
+ required: true,
264
+ description: "Address query."
265
+ },
266
+ limit: {
267
+ type: "string",
268
+ default: "5",
269
+ description: "Maximum candidate count."
270
+ },
271
+ suburb: {
272
+ type: "string",
273
+ description: "Optional suburb filter."
274
+ },
275
+ state: {
276
+ type: "string",
277
+ description: "Optional state filter."
278
+ },
279
+ postcode: {
280
+ type: "string",
281
+ description: "Optional postcode filter."
282
+ },
283
+ ...connectionArgs
284
+ },
285
+ run(context) {
286
+ return withClient(runtimeValue, context, async (client, format) => {
287
+ const args = context.args;
288
+ const result = record(resultData(await client.callTool("search_address", {
289
+ query: args.query,
290
+ limit: parseLimit(args.limit),
291
+ ...args.suburb ? { suburb: args.suburb } : {},
292
+ ...args.state ? { state: args.state } : {},
293
+ ...args.postcode ? { postcode: args.postcode } : {}
294
+ })));
295
+ emit(runtimeValue, format, result, [
296
+ "ID",
297
+ "ADDRESS",
298
+ "UNIT"
299
+ ], (Array.isArray(result.candidates) ? result.candidates.map(record) : []).map((candidate) => [
300
+ candidate.id,
301
+ candidate.label,
302
+ candidate.unit
303
+ ]));
304
+ });
305
+ }
306
+ }) }
307
+ }),
308
+ suburb: defineCommand({
309
+ meta: {
310
+ name: "suburb",
311
+ description: "Suburb discovery commands."
312
+ },
313
+ subCommands: {
314
+ search: defineCommand({
315
+ meta: {
316
+ name: "search",
317
+ description: "Search Australian suburbs."
318
+ },
319
+ args: {
320
+ query: {
321
+ type: "positional",
322
+ required: true,
323
+ description: "Suburb query."
324
+ },
325
+ state: {
326
+ type: "string",
327
+ description: "Optional state filter."
328
+ },
329
+ limit: {
330
+ type: "string",
331
+ default: "8",
332
+ description: "Maximum suburb count."
333
+ },
334
+ ...connectionArgs
335
+ },
336
+ run(context) {
337
+ return withClient(runtimeValue, context, async (client, format) => {
338
+ const args = context.args;
339
+ const result = record(resultData(await client.callTool("search_suburb", {
340
+ query: args.query,
341
+ limit: parseLimit(args.limit),
342
+ ...args.state ? { state: args.state } : {}
343
+ })));
344
+ emit(runtimeValue, format, result, [
345
+ "SUBURB",
346
+ "STATE",
347
+ "POSTCODE",
348
+ "LOCALITY PID"
349
+ ], (Array.isArray(result.suburbs) ? result.suburbs.map(record) : []).map((suburb) => [
350
+ suburb.suburb,
351
+ suburb.state,
352
+ suburb.postcode,
353
+ suburb.localityPid
354
+ ]));
355
+ });
356
+ }
357
+ }),
358
+ summary: defineCommand({
359
+ meta: {
360
+ name: "summary",
361
+ description: "Get summary statistics for an exact suburb."
362
+ },
363
+ args: {
364
+ suburb: {
365
+ type: "string",
366
+ required: true,
367
+ description: "Exact suburb name."
368
+ },
369
+ state: {
370
+ type: "string",
371
+ required: true,
372
+ description: "State abbreviation."
373
+ },
374
+ postcode: {
375
+ type: "string",
376
+ required: true,
377
+ description: "Four-digit postcode."
378
+ },
379
+ ...connectionArgs
380
+ },
381
+ run(context) {
382
+ return withClient(runtimeValue, context, async (client, format) => {
383
+ const args = context.args;
384
+ const result = record(resultData(await client.callTool("get_suburb_summary", {
385
+ suburb: args.suburb,
386
+ state: args.state,
387
+ postcode: args.postcode
388
+ })));
389
+ const statistics = record(result.statistics);
390
+ emit(runtimeValue, format, result, [
391
+ "SUBURB",
392
+ "STATE",
393
+ "POSTCODE",
394
+ "ADDRESSES",
395
+ "STREETS"
396
+ ], [[
397
+ result.suburb,
398
+ result.state,
399
+ result.postcode,
400
+ statistics.addressCount,
401
+ statistics.streetCount
402
+ ]]);
403
+ });
404
+ }
405
+ })
406
+ }
407
+ })
408
+ }
409
+ });
410
+ }
411
+ async function runCli(rawArgs, options = {}) {
412
+ const runtimeValue = {
413
+ env: options.env ?? process.env,
414
+ stdout: options.stdout ?? ((message) => console.log(message)),
415
+ stderr: options.stderr ?? ((message) => console.error(message)),
416
+ createClient: options.createClient ?? createMcpClient
417
+ };
418
+ try {
419
+ await runCommand(createRootCommand(runtimeValue), { rawArgs });
420
+ return 0;
421
+ } catch (error) {
422
+ runtimeValue.stderr(`Error: ${redactError(error)}`);
423
+ return 1;
424
+ }
425
+ }
426
+
427
+ //#endregion
428
+ //#region ../../src/cli/bin.ts
429
+ runCli(process.argv.slice(2)).then((exitCode) => {
430
+ process.exitCode = exitCode;
431
+ });
432
+
433
+ //#endregion
434
+ export { };
package/package.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "name": "@ausvector/cli",
3
+ "version": "1.0.0",
4
+ "description": "Command-line client for the Ausvector Streamable HTTP MCP service.",
5
+ "license": "Apache-2.0",
6
+ "private": false,
7
+ "type": "module",
8
+ "bin": {
9
+ "ausvector": "./dist/bin.mjs"
10
+ },
11
+ "files": ["dist", "README.md", "LICENSE"],
12
+ "scripts": {
13
+ "build": "tsdown",
14
+ "pack:check": "npm pack --dry-run"
15
+ },
16
+ "engines": { "node": ">=20" },
17
+ "dependencies": {
18
+ "@modelcontextprotocol/client": "^2.0.0",
19
+ "citty": "^0.1.6"
20
+ },
21
+ "devDependencies": {
22
+ "@types/node": "^22",
23
+ "tsdown": "^0.18.4",
24
+ "typescript": "^5"
25
+ },
26
+ "publishConfig": { "access": "public" }
27
+ }