@lehaotech/walmart-mcp 0.5.4

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 (87) hide show
  1. package/.env.example +25 -0
  2. package/CHANGELOG.md +247 -0
  3. package/LICENSE +21 -0
  4. package/README.md +344 -0
  5. package/build/api/advertising/ad-client.d.ts +24 -0
  6. package/build/api/advertising/ad-client.js +174 -0
  7. package/build/api/advertising/advertising-api.d.ts +50 -0
  8. package/build/api/advertising/advertising-api.js +89 -0
  9. package/build/api/client.d.ts +19 -0
  10. package/build/api/client.js +150 -0
  11. package/build/api/feeds/feeds-api.d.ts +15 -0
  12. package/build/api/feeds/feeds-api.js +53 -0
  13. package/build/api/fulfillment/fulfillment-api.d.ts +37 -0
  14. package/build/api/fulfillment/fulfillment-api.js +81 -0
  15. package/build/api/index.d.ts +44 -0
  16. package/build/api/index.js +56 -0
  17. package/build/api/inventory/inventory-api.d.ts +27 -0
  18. package/build/api/inventory/inventory-api.js +49 -0
  19. package/build/api/items/items-api.d.ts +33 -0
  20. package/build/api/items/items-api.js +67 -0
  21. package/build/api/notifications/notifications-api.d.ts +14 -0
  22. package/build/api/notifications/notifications-api.js +33 -0
  23. package/build/api/orders/orders-api.d.ts +32 -0
  24. package/build/api/orders/orders-api.js +47 -0
  25. package/build/api/pricing/pricing-api.d.ts +32 -0
  26. package/build/api/pricing/pricing-api.js +60 -0
  27. package/build/api/reports/reports-api.d.ts +37 -0
  28. package/build/api/reports/reports-api.js +51 -0
  29. package/build/api/returns/returns-api.d.ts +26 -0
  30. package/build/api/returns/returns-api.js +37 -0
  31. package/build/api/settings/settings-api.d.ts +9 -0
  32. package/build/api/settings/settings-api.js +21 -0
  33. package/build/auth/oauth.d.ts +16 -0
  34. package/build/auth/oauth.js +125 -0
  35. package/build/config/environment.d.ts +22 -0
  36. package/build/config/environment.js +50 -0
  37. package/build/index.d.ts +2 -0
  38. package/build/index.js +180 -0
  39. package/build/scripts/client-configs.d.ts +36 -0
  40. package/build/scripts/client-configs.js +132 -0
  41. package/build/scripts/diagnose.d.ts +15 -0
  42. package/build/scripts/diagnose.js +320 -0
  43. package/build/scripts/setup.d.ts +17 -0
  44. package/build/scripts/setup.js +276 -0
  45. package/build/tools/definitions/advertising.d.ts +664 -0
  46. package/build/tools/definitions/advertising.js +315 -0
  47. package/build/tools/definitions/discovery.d.ts +24 -0
  48. package/build/tools/definitions/discovery.js +65 -0
  49. package/build/tools/definitions/feeds.d.ts +46 -0
  50. package/build/tools/definitions/feeds.js +42 -0
  51. package/build/tools/definitions/fulfillment.d.ts +1127 -0
  52. package/build/tools/definitions/fulfillment.js +272 -0
  53. package/build/tools/definitions/inventory.d.ts +392 -0
  54. package/build/tools/definitions/inventory.js +182 -0
  55. package/build/tools/definitions/items.d.ts +447 -0
  56. package/build/tools/definitions/items.js +223 -0
  57. package/build/tools/definitions/notifications.d.ts +84 -0
  58. package/build/tools/definitions/notifications.js +73 -0
  59. package/build/tools/definitions/orders.d.ts +2659 -0
  60. package/build/tools/definitions/orders.js +298 -0
  61. package/build/tools/definitions/pricing.d.ts +724 -0
  62. package/build/tools/definitions/pricing.js +254 -0
  63. package/build/tools/definitions/reports.d.ts +223 -0
  64. package/build/tools/definitions/reports.js +144 -0
  65. package/build/tools/definitions/returns.d.ts +441 -0
  66. package/build/tools/definitions/returns.js +126 -0
  67. package/build/tools/definitions/settings.d.ts +100 -0
  68. package/build/tools/definitions/settings.js +52 -0
  69. package/build/tools/definitions/shared-schemas.d.ts +40 -0
  70. package/build/tools/definitions/shared-schemas.js +47 -0
  71. package/build/tools/definitions/token-management.d.ts +16 -0
  72. package/build/tools/definitions/token-management.js +41 -0
  73. package/build/tools/index.d.ts +6924 -0
  74. package/build/tools/index.js +379 -0
  75. package/build/utils/api-error.d.ts +41 -0
  76. package/build/utils/api-error.js +97 -0
  77. package/build/utils/endpoint-catalog.d.ts +22 -0
  78. package/build/utils/endpoint-catalog.js +89 -0
  79. package/build/utils/env-file.d.ts +12 -0
  80. package/build/utils/env-file.js +27 -0
  81. package/build/utils/known-issues.d.ts +29 -0
  82. package/build/utils/known-issues.js +122 -0
  83. package/build/utils/logger.d.ts +15 -0
  84. package/build/utils/logger.js +56 -0
  85. package/build/utils/rate-limiter.d.ts +51 -0
  86. package/build/utils/rate-limiter.js +109 -0
  87. package/package.json +1 -0
@@ -0,0 +1,298 @@
1
+ import { z } from 'zod';
2
+ import { SkuSchema, Iso8601UtcSchema } from './shared-schemas.js';
3
+ // ---------- Ship order ----------
4
+ // Walmart ship payload is deeply nested:
5
+ // { orderLines: { orderLine: [{ lineNumber, orderLineStatuses: { orderLineStatus: [...] } }] } }
6
+ const TrackingInfoSchema = z
7
+ .object({
8
+ shipDateTime: Iso8601UtcSchema,
9
+ carrierName: z
10
+ .object({
11
+ carrier: z.string().min(1).optional(),
12
+ otherCarrier: z.string().optional(),
13
+ })
14
+ .passthrough(),
15
+ methodCode: z.string().min(1),
16
+ trackingNumber: z.string().min(1),
17
+ trackingURL: z.string().url().optional(),
18
+ })
19
+ .passthrough();
20
+ const ShipOrderLineSchema = z
21
+ .object({
22
+ lineNumber: z.string().min(1),
23
+ orderLineStatuses: z
24
+ .object({
25
+ orderLineStatus: z
26
+ .array(z
27
+ .object({
28
+ status: z.enum(['Shipped']).default('Shipped'),
29
+ statusQuantity: z
30
+ .object({
31
+ unitOfMeasurement: z.string().default('EACH'),
32
+ amount: z.string().regex(/^\d+$/, 'amount must be a numeric string'),
33
+ })
34
+ .passthrough(),
35
+ trackingInfo: TrackingInfoSchema,
36
+ })
37
+ .passthrough())
38
+ .min(1),
39
+ })
40
+ .strict(),
41
+ })
42
+ .strict();
43
+ const ShipOrderBodySchema = z
44
+ .object({
45
+ orderLines: z
46
+ .object({
47
+ orderLine: z.array(ShipOrderLineSchema).min(1, 'Need at least 1 order line to ship'),
48
+ })
49
+ .strict(),
50
+ })
51
+ .strict();
52
+ // ---------- Cancel order ----------
53
+ const CancellationReasonSchema = z.enum([
54
+ 'CUSTOMER_REQUESTED_SELLER_TO_CANCEL',
55
+ 'INVALID_BILLING_ADDRESS',
56
+ 'INVALID_SHIPPING_ADDRESS',
57
+ 'NO_INVENTORY',
58
+ 'PRICING_ERROR',
59
+ 'OTHER',
60
+ ]);
61
+ const CancelOrderLineSchema = z
62
+ .object({
63
+ lineNumber: z.string().min(1),
64
+ orderLineStatuses: z
65
+ .object({
66
+ orderLineStatus: z
67
+ .array(z
68
+ .object({
69
+ status: z.literal('Cancelled').default('Cancelled'),
70
+ cancellationReason: CancellationReasonSchema,
71
+ statusQuantity: z
72
+ .object({
73
+ unitOfMeasurement: z.string().default('EACH'),
74
+ amount: z.string().regex(/^\d+$/, 'amount must be a numeric string'),
75
+ })
76
+ .passthrough(),
77
+ })
78
+ .passthrough())
79
+ .min(1),
80
+ })
81
+ .strict(),
82
+ })
83
+ .strict();
84
+ const CancelOrderBodySchema = z
85
+ .object({
86
+ orderCancellation: z
87
+ .object({
88
+ orderLines: z
89
+ .object({
90
+ orderLine: z.array(CancelOrderLineSchema).min(1),
91
+ })
92
+ .strict(),
93
+ })
94
+ .strict(),
95
+ })
96
+ .strict();
97
+ // ---------- Refund order ----------
98
+ // Walmart wants refundAmount as a NEGATIVE number.
99
+ const ChargeSchema = z
100
+ .object({
101
+ chargeType: z.enum(['PRODUCT', 'SHIPPING', 'TAX', 'FEE']),
102
+ chargeName: z.string().min(1),
103
+ chargeAmount: z
104
+ .object({
105
+ currency: z.enum(['USD', 'MXN', 'CAD', 'CLP']),
106
+ amount: z.number().negative('Refund amount must be negative (e.g. -10.50)'),
107
+ })
108
+ .strict(),
109
+ tax: z.unknown().optional(),
110
+ })
111
+ .passthrough();
112
+ const RefundOrderLineSchema = z
113
+ .object({
114
+ lineNumber: z.string().min(1),
115
+ refunds: z
116
+ .object({
117
+ refund: z
118
+ .array(z
119
+ .object({
120
+ refundComments: z.string().min(1),
121
+ refundCharges: z
122
+ .object({
123
+ refundCharge: z
124
+ .array(z
125
+ .object({
126
+ refundReason: z.string().min(1),
127
+ charge: ChargeSchema,
128
+ })
129
+ .strict())
130
+ .min(1),
131
+ })
132
+ .strict(),
133
+ })
134
+ .passthrough())
135
+ .min(1),
136
+ })
137
+ .strict(),
138
+ })
139
+ .strict();
140
+ const RefundOrderBodySchema = z
141
+ .object({
142
+ orderLines: z
143
+ .object({
144
+ orderLine: z.array(RefundOrderLineSchema).min(1, 'Need at least 1 line to refund'),
145
+ })
146
+ .strict(),
147
+ })
148
+ .strict();
149
+ // ---------- Ship-with-Walmart label purchase ----------
150
+ const ShippingLabelSchema = z
151
+ .object({
152
+ purchaseOrderId: z.string().min(1),
153
+ lineNumber: z.string().min(1).optional(),
154
+ carrierName: z.enum(['USPS', 'FedEx']).optional(),
155
+ serviceType: z.string().optional(),
156
+ package: z
157
+ .object({
158
+ weight: z
159
+ .object({
160
+ value: z.number().positive(),
161
+ unit: z.enum(['LB', 'OZ', 'KG', 'G']).default('LB'),
162
+ })
163
+ .strict(),
164
+ dimensions: z
165
+ .object({
166
+ length: z.number().positive(),
167
+ width: z.number().positive(),
168
+ height: z.number().positive(),
169
+ unit: z.enum(['IN', 'CM']).default('IN'),
170
+ })
171
+ .strict()
172
+ .optional(),
173
+ })
174
+ .strict(),
175
+ })
176
+ .passthrough();
177
+ // ---------- Shipping rate estimate ----------
178
+ const ShippingEstimateSchema = z
179
+ .object({
180
+ fromAddress: z.unknown().optional(),
181
+ toAddress: z.unknown().optional(),
182
+ package: z
183
+ .object({
184
+ weight: z
185
+ .object({
186
+ value: z.number().positive(),
187
+ unit: z.enum(['LB', 'OZ', 'KG', 'G']).default('LB'),
188
+ })
189
+ .strict(),
190
+ dimensions: z
191
+ .object({
192
+ length: z.number().positive(),
193
+ width: z.number().positive(),
194
+ height: z.number().positive(),
195
+ unit: z.enum(['IN', 'CM']).default('IN'),
196
+ })
197
+ .strict()
198
+ .optional(),
199
+ })
200
+ .strict()
201
+ .optional(),
202
+ })
203
+ .passthrough();
204
+ export const orderTools = [
205
+ {
206
+ name: 'walmart_get_all_orders',
207
+ description: 'Get all orders with optional filters. Returns order details including line items, shipping, and payment info.',
208
+ inputSchema: {
209
+ limit: z.number().int().min(1).max(200).optional().describe('Orders per page (default 100, max 200)'),
210
+ offset: z.string().optional().describe('Pagination offset'),
211
+ status: z
212
+ .enum(['Created', 'Acknowledged', 'Shipped', 'Delivered', 'Cancelled'])
213
+ .optional()
214
+ .describe('Filter by order status'),
215
+ createdStartDate: z.string().optional().describe('Start date filter (ISO 8601, e.g., 2026-01-01T00:00:00.000Z)'),
216
+ createdEndDate: z.string().optional().describe('End date filter (ISO 8601)'),
217
+ customerOrderId: z.string().optional().describe('Filter by customer order ID'),
218
+ purchaseOrderId: z.string().optional().describe('Filter by Walmart purchase order ID'),
219
+ sku: SkuSchema.optional().describe('Filter by SKU'),
220
+ shipNode: z.string().optional().describe('Filter by ship node'),
221
+ },
222
+ },
223
+ {
224
+ name: 'walmart_get_released_orders',
225
+ description: 'Get all released orders (ready to be fulfilled). These orders have been acknowledged and need to be shipped.',
226
+ inputSchema: {
227
+ limit: z.number().int().min(1).max(200).optional(),
228
+ offset: z.string().optional(),
229
+ createdStartDate: z.string().optional(),
230
+ createdEndDate: z.string().optional(),
231
+ shipNode: z.string().optional(),
232
+ },
233
+ },
234
+ {
235
+ name: 'walmart_get_order',
236
+ description: 'Get a single order by purchase order ID. Returns full order details including all line items.',
237
+ inputSchema: {
238
+ purchaseOrderId: z.string().describe('Walmart purchase order ID'),
239
+ },
240
+ },
241
+ {
242
+ name: 'walmart_acknowledge_order',
243
+ description: 'Acknowledge a new order. This confirms you received the order and intend to fulfill it.',
244
+ inputSchema: {
245
+ purchaseOrderId: z.string().describe('Walmart purchase order ID to acknowledge'),
246
+ },
247
+ },
248
+ {
249
+ name: 'walmart_ship_order',
250
+ description: 'Mark order lines as shipped with tracking info. Body shape: ' +
251
+ '{ orderLines: { orderLine: [{ lineNumber, orderLineStatuses: { orderLineStatus: ' +
252
+ '[{ status: "Shipped", statusQuantity, trackingInfo: { shipDateTime, carrierName, ' +
253
+ 'methodCode, trackingNumber } }] } }] } }. shipDateTime is ISO 8601 UTC.',
254
+ inputSchema: {
255
+ purchaseOrderId: z.string().describe('Walmart purchase order ID'),
256
+ shipmentData: ShipOrderBodySchema,
257
+ },
258
+ },
259
+ {
260
+ name: 'walmart_cancel_order',
261
+ description: 'Cancel order lines. Only works for orders in Created or Acknowledged status (not yet shipped). ' +
262
+ 'cancellationReason must be one of CUSTOMER_REQUESTED_SELLER_TO_CANCEL, INVALID_BILLING_ADDRESS, ' +
263
+ 'INVALID_SHIPPING_ADDRESS, NO_INVENTORY, PRICING_ERROR, OTHER.',
264
+ inputSchema: {
265
+ purchaseOrderId: z.string().describe('Walmart purchase order ID'),
266
+ cancelData: CancelOrderBodySchema,
267
+ },
268
+ },
269
+ {
270
+ name: 'walmart_refund_order',
271
+ description: 'Refund order lines. Only works for orders in Shipped status. chargeAmount.amount MUST be ' +
272
+ 'a negative number (e.g. -10.50). chargeType: PRODUCT | SHIPPING | TAX | FEE.',
273
+ inputSchema: {
274
+ purchaseOrderId: z.string().describe('Walmart purchase order ID'),
275
+ refundData: RefundOrderBodySchema,
276
+ },
277
+ },
278
+ {
279
+ name: 'walmart_get_shipping_carriers',
280
+ description: 'Get list of shipping carriers supported by Walmart for Ship with Walmart (SWW) label purchases.',
281
+ inputSchema: {},
282
+ },
283
+ {
284
+ name: 'walmart_create_shipping_label',
285
+ description: 'Purchase a shipping label through Ship with Walmart (SWW). Required: purchaseOrderId + ' +
286
+ 'package.weight. Optional: carrierName (USPS|FedEx), package.dimensions.',
287
+ inputSchema: {
288
+ labelData: ShippingLabelSchema,
289
+ },
290
+ },
291
+ {
292
+ name: 'walmart_get_shipping_estimate',
293
+ description: 'Get shipping rate estimates for a package. Returns rates from available carriers.',
294
+ inputSchema: {
295
+ estimateParams: ShippingEstimateSchema,
296
+ },
297
+ },
298
+ ];