@open-work-org/shadowfax-mcp-server 0.0.0-stage → 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.
package/README.md CHANGED
@@ -1,3 +1,118 @@
1
- # Temporary Holding Version
1
+ # @open-work-org/shadowfax-mcp-server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Local stdio MCP server for the Shadowfax Forward Logistics API.
4
+
5
+ ## Configure
6
+
7
+ Get an API token from the Shadowfax SFX 360 Partner Portal. Staging and production use separate credentials.
8
+
9
+ ```json
10
+ {
11
+ "mcpServers": {
12
+ "shadowfax": {
13
+ "command": "npx",
14
+ "args": ["-y", "@open-work-org/shadowfax-mcp-server"],
15
+ "env": {
16
+ "SHADOWFAX_API_TOKEN": "your_shadowfax_token",
17
+ "SHADOWFAX_ENV": "production"
18
+ }
19
+ }
20
+ }
21
+ }
22
+ ```
23
+
24
+ `SHADOWFAX_ENV` defaults to `production`. Set it to `staging` with the matching staging token. Staging uses `https://dale.staging.shadowfax.in/api`; production uses `https://dale.shadowfax.in/api`.
25
+
26
+ The package runs locally over stdio and does not start an HTTP listener. It uses Shadowfax Token authentication. The token is added to the Authorization header and cannot be supplied through tool arguments.
27
+
28
+ ## Tool
29
+
30
+ `shadowfax_fwd` sends a request to the configured Shadowfax Forward Logistics API host. Provide the HTTP `method`, API `path`, optional query `params`, and optional JSON `body`. Paths are limited to `/v1/clients/`, `/v3/clients/`, and `/v4/clients/` routes; caller-supplied hosts, credentials, query strings inside the path, and fragments are rejected.
31
+
32
+ GET requests are read-only. POST, PUT, PATCH, and DELETE require `confirm_mutation: true`. This includes POST endpoints that only read data, such as bulk tracking, because the tool requires confirmation for every non-GET method.
33
+
34
+ Shadowfax may respond with HTTP 200 and `message: "Failure"` when an order is rejected or its payload fails validation. The tool marks that response as an error and includes the response body so the caller can inspect the reason.
35
+
36
+ Example: check delivery serviceability:
37
+
38
+ ```json
39
+ {
40
+ "method": "GET",
41
+ "path": "/v1/clients/serviceability/",
42
+ "params": {
43
+ "service": "marketplace",
44
+ "pincodes": "560034"
45
+ }
46
+ }
47
+ ```
48
+
49
+ Example: track an order:
50
+
51
+ ```json
52
+ {
53
+ "method": "GET",
54
+ "path": "/v4/clients/orders/SF1234567890/track/"
55
+ }
56
+ ```
57
+
58
+ Example: place a forward order (write request):
59
+
60
+ ```json
61
+ {
62
+ "method": "POST",
63
+ "path": "/v3/clients/orders/",
64
+ "confirm_mutation": true,
65
+ "body": {
66
+ "customer_details": {
67
+ "name": "Rahul Sharma",
68
+ "contact": "9876543210",
69
+ "address_line_1": "42 MG Road, Koramangala",
70
+ "city": "BANGALORE",
71
+ "pincode": 560034,
72
+ "state": "Karnataka"
73
+ },
74
+ "order_details": {
75
+ "client_order_id": "FWD-TEST-001",
76
+ "product_value": 1299,
77
+ "payment_mode": "prepaid",
78
+ "cod_amount": 0,
79
+ "order_service": "Regular"
80
+ },
81
+ "pickup_details": {
82
+ "pickup_type": "seller",
83
+ "name": "TechStore Pvt Ltd",
84
+ "contact": "9876543211",
85
+ "address_line_1": "15 Industrial Area Phase 2",
86
+ "city": "BANGALORE",
87
+ "pincode": 560058
88
+ },
89
+ "return_details": {
90
+ "return_type": "seller",
91
+ "name": "TechStore Pvt Ltd",
92
+ "contact": "9876543211",
93
+ "address_line_1": "15 Industrial Area Phase 2",
94
+ "city": "BANGALORE",
95
+ "pincode": 560058
96
+ },
97
+ "product_details": [
98
+ {
99
+ "sku_name": "Wireless Bluetooth Headphones",
100
+ "sku_id": "SKU-HEADPHONE-001",
101
+ "price": 1299,
102
+ "category": "Electronics",
103
+ "hsn_code": "85183000",
104
+ "invoice_no": "INV-2026-001"
105
+ }
106
+ ]
107
+ }
108
+ }
109
+ ```
110
+
111
+ See the [Shadowfax Forward Logistics API documentation](https://developer.shadowfax.in/docs/api/forward-logistics) for required fields and endpoint-specific request formats. The tool returns binary responses, such as PDF labels, as base64 JSON.
112
+
113
+ ## Build from this repository
114
+
115
+ ```bash
116
+ npm run build:shadowfax
117
+ npm run start:shadowfax
118
+ ```
@@ -0,0 +1,7 @@
1
+ export declare const RESPONSE_CHARACTER_LIMIT = 80000;
2
+ export declare const RESPONSE_BYTE_LIMIT = 2000000;
3
+ export declare const REQUEST_TIMEOUT_MS = 30000;
4
+ export type ShadowfaxEnvironment = "staging" | "production";
5
+ export declare const API_BASE_URLS: Record<ShadowfaxEnvironment, string>;
6
+ export declare function getEnvironment(value: string | undefined): ShadowfaxEnvironment;
7
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAC/C,eAAO,MAAM,mBAAmB,UAAY,CAAC;AAC7C,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC,MAAM,MAAM,oBAAoB,GAAG,SAAS,GAAG,YAAY,CAAC;AAE5D,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,oBAAoB,EAAE,MAAM,CAG9D,CAAC;AAEF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,GAAG,oBAAoB,CAI9E"}
@@ -0,0 +1,14 @@
1
+ export const RESPONSE_CHARACTER_LIMIT = 80_000;
2
+ export const RESPONSE_BYTE_LIMIT = 2_000_000;
3
+ export const REQUEST_TIMEOUT_MS = 30_000;
4
+ export const API_BASE_URLS = {
5
+ staging: "https://dale.staging.shadowfax.in",
6
+ production: "https://dale.shadowfax.in",
7
+ };
8
+ export function getEnvironment(value) {
9
+ const environment = (value ?? "production").toLowerCase();
10
+ if (environment === "staging" || environment === "production")
11
+ return environment;
12
+ throw new Error('SHADOWFAX_ENV must be either "staging" or "production".');
13
+ }
14
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC;AAC/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAC7C,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAIzC,MAAM,CAAC,MAAM,aAAa,GAAyC;IACjE,OAAO,EAAE,mCAAmC;IAC5C,UAAU,EAAE,2BAA2B;CACxC,CAAC;AAEF,MAAM,UAAU,cAAc,CAAC,KAAyB;IACtD,MAAM,WAAW,GAAG,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC,WAAW,EAAE,CAAC;IAC1D,IAAI,WAAW,KAAK,SAAS,IAAI,WAAW,KAAK,YAAY;QAAE,OAAO,WAAW,CAAC;IAClF,MAAM,IAAI,KAAK,CAAC,yDAAyD,CAAC,CAAC;AAC7E,CAAC"}
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env node
2
+ export {};
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
+ import { getEnvironment } from "./constants.js";
4
+ import { ShadowfaxApiClient } from "./services/api.js";
5
+ import { createShadowfaxMcpServer } from "./server-factory.js";
6
+ const environment = getEnvironment(process.env.SHADOWFAX_ENV);
7
+ const server = createShadowfaxMcpServer(new ShadowfaxApiClient(process.env.SHADOWFAX_API_TOKEN ?? "", environment));
8
+ await server.connect(new StdioServerTransport());
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,MAAM,WAAW,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;AAC9D,MAAM,MAAM,GAAG,wBAAwB,CAAC,IAAI,kBAAkB,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,EAAE,WAAW,CAAC,CAAC,CAAC;AACpH,MAAM,MAAM,CAAC,OAAO,CAAC,IAAI,oBAAoB,EAAE,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { ShadowfaxApiClient } from "./services/api.js";
3
+ export declare function createShadowfaxMcpServer(client: ShadowfaxApiClient): McpServer;
4
+ //# sourceMappingURL=server-factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-factory.d.ts","sourceRoot":"","sources":["../src/server-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAGvD,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,kBAAkB,GAAG,SAAS,CAI9E"}
@@ -0,0 +1,8 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { registerShadowfaxForwardRequestTool } from "./tools/api-request.js";
3
+ export function createShadowfaxMcpServer(client) {
4
+ const server = new McpServer({ name: "shadowfax-mcp-server", version: "0.1.0" });
5
+ registerShadowfaxForwardRequestTool(server, client);
6
+ return server;
7
+ }
8
+ //# sourceMappingURL=server-factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-factory.js","sourceRoot":"","sources":["../src/server-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,mCAAmC,EAAE,MAAM,wBAAwB,CAAC;AAE7E,MAAM,UAAU,wBAAwB,CAAC,MAA0B;IACjE,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,sBAAsB,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;IACjF,mCAAmC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACpD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type ShadowfaxEnvironment } from "../constants.js";
2
+ export type ShadowfaxMethod = "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
3
+ export type ShadowfaxFields = Record<string, unknown>;
4
+ export declare class ShadowfaxApiClient {
5
+ private readonly token;
6
+ private readonly environment;
7
+ constructor(token: string, environment: ShadowfaxEnvironment);
8
+ private requireToken;
9
+ request(method: ShadowfaxMethod, path: string, params?: ShadowfaxFields, body?: ShadowfaxFields): Promise<{
10
+ text: string;
11
+ isBusinessFailure: boolean;
12
+ }>;
13
+ }
14
+ //# sourceMappingURL=api.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,eAAe,GAAG,KAAK,GAAG,MAAM,GAAG,KAAK,GAAG,OAAO,GAAG,QAAQ,CAAC;AAC1E,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAkDtD,qBAAa,kBAAkB;IAE3B,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,WAAW;gBADX,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,oBAAoB;IAGpD,OAAO,CAAC,YAAY;IAMd,OAAO,CACX,MAAM,EAAE,eAAe,EACvB,IAAI,EAAE,MAAM,EACZ,MAAM,GAAE,eAAoB,EAC5B,IAAI,GAAE,eAAoB,GACzB,OAAO,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,OAAO,CAAA;KAAE,CAAC;CA+DzD"}
@@ -0,0 +1,120 @@
1
+ import { API_BASE_URLS, REQUEST_TIMEOUT_MS, RESPONSE_BYTE_LIMIT, RESPONSE_CHARACTER_LIMIT, } from "../constants.js";
2
+ function encodeField(value) {
3
+ if (value === null || value === undefined)
4
+ return "";
5
+ return typeof value === "object" ? JSON.stringify(value) : String(value);
6
+ }
7
+ function serializeFields(fields) {
8
+ return Object.fromEntries(Object.entries(fields).map(([key, value]) => [key, encodeField(value)]));
9
+ }
10
+ function rejectCredentials(fields, label) {
11
+ const credentialKey = Object.keys(fields).find((key) => ["token", "authorization", "api_key", "apikey", "access_token"].includes(key.toLowerCase()));
12
+ if (credentialKey) {
13
+ throw new Error(`${label} must not contain credentials; the server injects SHADOWFAX_API_TOKEN in the Authorization header.`);
14
+ }
15
+ }
16
+ function validatePath(path) {
17
+ if (!path.startsWith("/") ||
18
+ path.startsWith("//") ||
19
+ path.includes("..") ||
20
+ path.includes("?") ||
21
+ path.includes("#") ||
22
+ /[\r\n]/.test(path) ||
23
+ !/^\/v(?:1|3|4)\/clients\//.test(path)) {
24
+ throw new Error("path must be a Forward Logistics client API path like /v4/clients/orders/{awb}/track/. Put query values in params.");
25
+ }
26
+ return path;
27
+ }
28
+ function truncate(text) {
29
+ if (text.length <= RESPONSE_CHARACTER_LIMIT)
30
+ return text;
31
+ return `${text.slice(0, RESPONSE_CHARACTER_LIMIT)}\n\n[Response truncated at ${RESPONSE_CHARACTER_LIMIT} characters.]`;
32
+ }
33
+ function isBusinessFailure(contentType, body) {
34
+ if (!/json/i.test(contentType))
35
+ return false;
36
+ try {
37
+ const parsed = JSON.parse(body);
38
+ return typeof parsed === "object" && parsed !== null && "message" in parsed && parsed.message === "Failure";
39
+ }
40
+ catch {
41
+ return false;
42
+ }
43
+ }
44
+ export class ShadowfaxApiClient {
45
+ token;
46
+ environment;
47
+ constructor(token, environment) {
48
+ this.token = token;
49
+ this.environment = environment;
50
+ }
51
+ requireToken() {
52
+ if (!this.token.trim()) {
53
+ throw new Error("SHADOWFAX_API_TOKEN is not configured. Add it to this MCP server's environment.");
54
+ }
55
+ }
56
+ async request(method, path, params = {}, body = {}) {
57
+ this.requireToken();
58
+ rejectCredentials(params, "params");
59
+ rejectCredentials(body, "body");
60
+ if (method === "GET" && Object.keys(body).length > 0) {
61
+ throw new Error("GET requests cannot contain a body; use params instead.");
62
+ }
63
+ const baseUrl = API_BASE_URLS[this.environment];
64
+ const url = new URL(`/api${validatePath(path)}`, baseUrl);
65
+ if (url.origin !== new URL(baseUrl).origin || !/^\/api\/v(?:1|3|4)\/clients\//.test(url.pathname)) {
66
+ throw new Error("Only the configured Shadowfax API host is allowed.");
67
+ }
68
+ for (const [key, value] of Object.entries(serializeFields(params)))
69
+ url.searchParams.set(key, value);
70
+ const headers = {
71
+ Authorization: `Token ${this.token}`,
72
+ Accept: "application/json, application/pdf, application/octet-stream;q=0.9, */*;q=0.8",
73
+ };
74
+ const init = {
75
+ method,
76
+ headers,
77
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
78
+ redirect: "error",
79
+ };
80
+ if (method !== "GET" && method !== "DELETE") {
81
+ headers["Content-Type"] = "application/json";
82
+ init.body = JSON.stringify(body);
83
+ }
84
+ else if (method === "DELETE" && Object.keys(body).length > 0) {
85
+ throw new Error("DELETE requests cannot contain a body; pass parameters in params.");
86
+ }
87
+ let response;
88
+ try {
89
+ response = await fetch(url, init);
90
+ }
91
+ catch (error) {
92
+ if (error instanceof Error && error.name === "TimeoutError") {
93
+ throw new Error(`Shadowfax request timed out after ${REQUEST_TIMEOUT_MS / 1000} seconds.`);
94
+ }
95
+ throw new Error(error instanceof Error ? `Shadowfax request failed: ${error.message}` : "Shadowfax request failed.");
96
+ }
97
+ const bytes = new Uint8Array(await response.arrayBuffer());
98
+ const contentType = response.headers.get("content-type") ?? "application/octet-stream";
99
+ const truncated = bytes.length > RESPONSE_BYTE_LIMIT;
100
+ const bodyBytes = truncated ? bytes.subarray(0, RESPONSE_BYTE_LIMIT) : bytes;
101
+ let responseBody;
102
+ if (/json|text|xml|javascript|urlencoded/i.test(contentType)) {
103
+ responseBody = truncate(new TextDecoder().decode(bodyBytes));
104
+ if (truncated)
105
+ responseBody += `\n\n[Response bytes truncated at ${RESPONSE_BYTE_LIMIT}.]`;
106
+ }
107
+ else {
108
+ responseBody = JSON.stringify({
109
+ encoding: "base64",
110
+ data: Buffer.from(bodyBytes).toString("base64"),
111
+ ...(truncated ? { truncated: true, byteLimit: RESPONSE_BYTE_LIMIT } : {}),
112
+ });
113
+ }
114
+ const text = `HTTP ${response.status} ${response.statusText}\nContent-Type: ${contentType}\n\n${responseBody}`;
115
+ if (!response.ok)
116
+ throw new Error(truncate(text));
117
+ return { text: truncate(text), isBusinessFailure: isBusinessFailure(contentType, responseBody) };
118
+ }
119
+ }
120
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/services/api.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,GAEzB,MAAM,iBAAiB,CAAC;AAKzB,SAAS,WAAW,CAAC,KAAc;IACjC,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,CAAC;IACrD,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC3E,CAAC;AAED,SAAS,eAAe,CAAC,MAAuB;IAC9C,OAAO,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,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M,IAAI,GAAG,QAAQ,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,mBAAmB,WAAW,OAAO,YAAY,EAAE,CAAC;QAC/G,IAAI,CAAC,QAAQ,CAAC,EAAE;YAAE,MAAM,IAAI,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC;QAClD,OAAO,EAAE,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,iBAAiB,EAAE,iBAAiB,CAAC,WAAW,EAAE,YAAY,CAAC,EAAE,CAAC;IACnG,CAAC;CACF"}
@@ -0,0 +1,4 @@
1
+ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
+ import { ShadowfaxApiClient } from "../services/api.js";
3
+ export declare function registerShadowfaxForwardRequestTool(server: McpServer, client: ShadowfaxApiClient): void;
4
+ //# sourceMappingURL=api-request.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-request.d.ts","sourceRoot":"","sources":["../../src/tools/api-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEpE,OAAO,EAAE,kBAAkB,EAA8C,MAAM,oBAAoB,CAAC;AAEpG,wBAAgB,mCAAmC,CAAC,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,kBAAkB,GAAG,IAAI,CA8CvG"}
@@ -0,0 +1,41 @@
1
+ import { z } from "zod";
2
+ export function registerShadowfaxForwardRequestTool(server, client) {
3
+ server.registerTool("shadowfax_fwd", {
4
+ title: "Shadowfax Forward Logistics API Request",
5
+ description: `Calls a documented Shadowfax Forward Logistics API path using SHADOWFAX_API_TOKEN. Supported API path versions are /v1/clients/, /v3/clients/, and /v4/clients/; the host is fixed to the configured Shadowfax environment.
6
+
7
+ Use the Shadowfax Forward Logistics API documentation for endpoint paths, methods, query parameters, and payloads. Common operations include serviceability, order placement, tracking, bulk tracking, cancellation, updates, rates, labels, proof of delivery, escalations, and AWB generation.
8
+
9
+ Pass query values in params and a JSON object in body. GET is read-only; every other method requires confirm_mutation=true. The token is injected only in the Authorization header. Shadowfax may return HTTP 200 with message="Failure" for validation or business rejections, so inspect the response message rather than relying only on the HTTP status.`,
10
+ inputSchema: z
11
+ .object({
12
+ method: z.enum(["GET", "POST", "PUT", "PATCH", "DELETE"]).default("GET"),
13
+ path: z.string().min(1).max(2048).describe("Forward Logistics API path beginning with /v1/clients/, /v3/clients/, or /v4/clients/, without query parameters"),
14
+ params: z.record(z.string(), z.unknown()).optional().describe("Query-string parameters"),
15
+ body: z.record(z.string(), z.unknown()).optional().describe("JSON request body fields"),
16
+ confirm_mutation: z.boolean().default(false).describe("Must be true for POST, PUT, PATCH, or DELETE requests"),
17
+ })
18
+ .strict(),
19
+ annotations: {
20
+ readOnlyHint: false,
21
+ destructiveHint: true,
22
+ idempotentHint: false,
23
+ openWorldHint: true,
24
+ },
25
+ }, async ({ method, path, params, body, confirm_mutation }) => {
26
+ if (method !== "GET" && !confirm_mutation) {
27
+ return { content: [{ type: "text", text: "Error: Mutation blocked. Set confirm_mutation=true for POST, PUT, PATCH, or DELETE." }], isError: true };
28
+ }
29
+ try {
30
+ const result = await client.request(method, path, (params ?? {}), (body ?? {}));
31
+ return { content: [{ type: "text", text: result.text }], ...(result.isBusinessFailure ? { isError: true } : {}) };
32
+ }
33
+ catch (error) {
34
+ return {
35
+ content: [{ type: "text", text: error instanceof Error ? `Error: ${error.message}` : "Error: Unexpected Shadowfax API error." }],
36
+ isError: true,
37
+ };
38
+ }
39
+ });
40
+ }
41
+ //# sourceMappingURL=api-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-request.js","sourceRoot":"","sources":["../../src/tools/api-request.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,MAAM,UAAU,mCAAmC,CAAC,MAAiB,EAAE,MAA0B;IAC/F,MAAM,CAAC,YAAY,CACjB,eAAe,EACf;QACE,KAAK,EAAE,yCAAyC;QA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ACD,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,OAAO,CACjC,MAAyB,EACzB,IAAI,EACJ,CAAC,MAAM,IAAI,EAAE,CAAoB,EACjC,CAAC,IAAI,IAAI,EAAE,CAAoB,CAChC,CAAC;YACF,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC;QACpH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO;gBACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,UAAU,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,wCAAwC,EAAE,CAAC;gBAChI,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@open-work-org/shadowfax-mcp-server",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "description": "Local stdio MCP server for Shadowfax Forward Logistics APIs.",
5
+ "type": "module",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "shadowfax-mcp-server": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist/",
12
+ "README.md"
13
+ ],
14
+ "scripts": {
15
+ "build": "tsc -p tsconfig.json",
16
+ "prepublishOnly": "npm run build"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/open-work-org/open-mcp-servers.git",
21
+ "directory": "packages/shadowfax"
22
+ },
23
+ "license": "MIT",
24
+ "author": "Open Work Org",
25
+ "keywords": [
26
+ "mcp",
27
+ "shadowfax",
28
+ "logistics",
29
+ "shipping",
30
+ "model-context-protocol"
31
+ ],
32
+ "engines": {
33
+ "node": ">=18"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
38
+ "dependencies": {
39
+ "@modelcontextprotocol/sdk": "^1.29.0",
40
+ "zod": "^3.25.76"
41
+ }
42
+ }