@teamnetwork-nz/gosweetspot-mcp-server 0.2.3 → 0.3.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.
package/README.md CHANGED
@@ -8,6 +8,8 @@ MCP server for the **[GoSweetSpot (GSS) Freight API](https://api-docs.gosweetspo
8
8
 
9
9
  Compatible with Claude Desktop, Claude Code, Cursor, Cline, and any MCP-capable client.
10
10
 
11
+ Tools accept optional `outputFormat: "json"` to return valid JSON text without Markdown wrappers. Omit it to keep each tool's normal response. The option is handled locally and is not sent to the GoSweetSpot API.
12
+
11
13
  **Read-only by default.** Write operations (publish orders, create/delete shipments, manifest, print, book pickups) are hidden until you set `GSS_READWRITE=true`.
12
14
 
13
15
  ## Requirements
package/dist/format.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ /** Return valid bare JSON text from an existing JSON block or any legacy tool response. */
2
+ export declare function forceJson(text: string): string;
1
3
  export declare function jsonBlock(title: string, data: unknown): string;
2
4
  export declare function table(title: string, headers: string[], rows: string[][]): string;
3
5
  export declare function cell(v: unknown): string;
package/dist/format.js CHANGED
@@ -1,5 +1,34 @@
1
1
  import { maybeFromUtc } from './datetime.js';
2
2
  const MAX_OUTPUT_CHARS = 40_000;
3
+ /** Return valid bare JSON text from an existing JSON block or any legacy tool response. */
4
+ export function forceJson(text) {
5
+ const fenced = text.match(/```json\s*([\s\S]*?)\s*```/i)?.[1];
6
+ const candidate = fenced ?? text;
7
+ try {
8
+ return JSON.stringify(JSON.parse(candidate), null, 2);
9
+ }
10
+ catch {
11
+ const lines = text.split(/\r?\n/);
12
+ const title = lines[0]?.match(/^\*\*(.*?)\*\*$/)?.[1];
13
+ const tableStart = lines.findIndex((line) => /^\s*\|.*\|\s*$/.test(line));
14
+ if (tableStart >= 0 && lines[tableStart + 1]?.includes('---')) {
15
+ const cells = (line) => line.trim().replace(/^\||\|$/g, '').split('|').map((value) => value.trim());
16
+ const headers = cells(lines[tableStart] ?? '');
17
+ const rows = [];
18
+ let cursor = tableStart + 2;
19
+ while (cursor < lines.length && /^\s*\|.*\|\s*$/.test(lines[cursor] ?? '')) {
20
+ const values = cells(lines[cursor] ?? '');
21
+ rows.push(Object.fromEntries(headers.map((header, index) => [header, values[index] ?? ''])));
22
+ cursor += 1;
23
+ }
24
+ const notes = lines.slice(cursor).join('\n').trim();
25
+ return JSON.stringify({ ...(title ? { title } : {}), rows, ...(notes ? { notes } : {}) }, null, 2);
26
+ }
27
+ if (title && /No records found\./.test(text))
28
+ return JSON.stringify({ title, rows: [] }, null, 2);
29
+ return JSON.stringify(text);
30
+ }
31
+ }
3
32
  // Recursively convert ISO datetime strings within any value to the configured timezone.
4
33
  function convertDates(v) {
5
34
  if (Array.isArray(v))
package/dist/index.js CHANGED
@@ -7,6 +7,8 @@ import { allTools } from './tools/index.js';
7
7
  import { createHttpServer } from './http-server.js';
8
8
  import { parsePositiveInt } from './env.js';
9
9
  import { packageName, packageVersion } from './package-info.js';
10
+ import { z } from 'zod/v3';
11
+ import { forceJson } from './format.js';
10
12
  const config = loadConfig();
11
13
  const client = new GssClient(config);
12
14
  // In read-only mode, hide the write tools entirely so agents don't attempt them.
@@ -42,10 +44,10 @@ GoSweetSpot (GSS) Freight API MCP server — NZ freight rating, shipment creatio
42
44
  `.trim(),
43
45
  });
44
46
  for (const tool of activeTools) {
45
- server.registerTool(tool.name, { description: tool.description, inputSchema: tool.inputSchema.strict() }, async (args) => {
47
+ server.registerTool(tool.name, { description: tool.description, inputSchema: tool.inputSchema.extend({ outputFormat: z.enum(['json']).optional().describe('Return valid JSON text without Markdown wrappers.') }).strict() }, async ({ outputFormat, ...args }) => {
46
48
  try {
47
49
  const text = await tool.handler(client, args);
48
- return { content: [{ type: 'text', text }] };
50
+ return { content: [{ type: 'text', text: outputFormat === 'json' ? forceJson(text) : text }] };
49
51
  }
50
52
  catch (err) {
51
53
  const message = err instanceof Error ? err.message : String(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@teamnetwork-nz/gosweetspot-mcp-server",
3
- "version": "0.2.3",
3
+ "version": "0.3.0",
4
4
  "description": "MCP server for the GoSweetSpot (GSS) Freight API — NZ freight rating, shipment creation, customer orders, manifesting, labels & tracking, with a read-only gate",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",