@amazon-sp-api-release/dev-mcp 0.0.1

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 (47) hide show
  1. package/README.md +82 -0
  2. package/dist/auth/sp-api-auth.d.ts +17 -0
  3. package/dist/auth/sp-api-auth.d.ts.map +1 -0
  4. package/dist/auth/sp-api-auth.js +55 -0
  5. package/dist/index.d.ts +3 -0
  6. package/dist/index.d.ts.map +1 -0
  7. package/dist/index.js +96 -0
  8. package/dist/tools/api-tools/orders-api-tools.d.ts +103 -0
  9. package/dist/tools/api-tools/orders-api-tools.d.ts.map +1 -0
  10. package/dist/tools/api-tools/orders-api-tools.js +459 -0
  11. package/dist/tools/migration-assistant-tools/migration-tools.d.ts +21 -0
  12. package/dist/tools/migration-assistant-tools/migration-tools.d.ts.map +1 -0
  13. package/dist/tools/migration-assistant-tools/migration-tools.js +82 -0
  14. package/dist/tools/migration-assistant-tools/orders-api-migration/code-analyzer.d.ts +19 -0
  15. package/dist/tools/migration-assistant-tools/orders-api-migration/code-analyzer.d.ts.map +1 -0
  16. package/dist/tools/migration-assistant-tools/orders-api-migration/code-analyzer.js +52 -0
  17. package/dist/tools/migration-assistant-tools/orders-api-migration/code-generator.d.ts +3 -0
  18. package/dist/tools/migration-assistant-tools/orders-api-migration/code-generator.d.ts.map +1 -0
  19. package/dist/tools/migration-assistant-tools/orders-api-migration/code-generator.js +45 -0
  20. package/dist/tools/migration-assistant-tools/orders-api-migration/guidance-formatter.d.ts +3 -0
  21. package/dist/tools/migration-assistant-tools/orders-api-migration/guidance-formatter.d.ts.map +1 -0
  22. package/dist/tools/migration-assistant-tools/orders-api-migration/guidance-formatter.js +134 -0
  23. package/dist/tools/migration-assistant-tools/orders-api-migration/migration-data.d.ts +13 -0
  24. package/dist/tools/migration-assistant-tools/orders-api-migration/migration-data.d.ts.map +1 -0
  25. package/dist/tools/migration-assistant-tools/orders-api-migration/migration-data.js +181 -0
  26. package/dist/tools/migration-assistant-tools/orders-api-migration/report-formatter.d.ts +5 -0
  27. package/dist/tools/migration-assistant-tools/orders-api-migration/report-formatter.d.ts.map +1 -0
  28. package/dist/tools/migration-assistant-tools/orders-api-migration/report-formatter.js +64 -0
  29. package/dist/zod-schemas/migration-schemas.d.ts +24 -0
  30. package/dist/zod-schemas/migration-schemas.d.ts.map +1 -0
  31. package/dist/zod-schemas/migration-schemas.js +24 -0
  32. package/dist/zod-schemas/orders-schemas.d.ts +291 -0
  33. package/dist/zod-schemas/orders-schemas.d.ts.map +1 -0
  34. package/dist/zod-schemas/orders-schemas.js +178 -0
  35. package/package.json +66 -0
  36. package/src/auth/sp-api-auth.ts +88 -0
  37. package/src/index.ts +168 -0
  38. package/src/tools/api-tools/orders-api-tools.ts +684 -0
  39. package/src/tools/migration-assistant-tools/migration-tools.ts +143 -0
  40. package/src/tools/migration-assistant-tools/orders-api-migration/code-analyzer.ts +72 -0
  41. package/src/tools/migration-assistant-tools/orders-api-migration/code-generator.ts +64 -0
  42. package/src/tools/migration-assistant-tools/orders-api-migration/guidance-formatter.ts +154 -0
  43. package/src/tools/migration-assistant-tools/orders-api-migration/migration-data.ts +221 -0
  44. package/src/tools/migration-assistant-tools/orders-api-migration/report-formatter.ts +85 -0
  45. package/src/utils/logger.ts +75 -0
  46. package/src/zod-schemas/migration-schemas.ts +28 -0
  47. package/src/zod-schemas/orders-schemas.ts +196 -0
@@ -0,0 +1,291 @@
1
+ /**
2
+ * Zod schemas for Orders API tools
3
+ */
4
+ import { z } from "zod";
5
+ export declare const searchOrdersSchema: z.ZodObject<{
6
+ createdAfter: z.ZodOptional<z.ZodString>;
7
+ createdBefore: z.ZodOptional<z.ZodString>;
8
+ lastUpdatedAfter: z.ZodOptional<z.ZodString>;
9
+ lastUpdatedBefore: z.ZodOptional<z.ZodString>;
10
+ fulfillmentStatuses: z.ZodOptional<z.ZodArray<z.ZodEnum<["PENDING", "UNSHIPPED", "PARTIALLY_SHIPPED", "SHIPPED", "CANCELLED", "UNFULFILLABLE"]>, "many">>;
11
+ marketplaceIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
12
+ fulfilledBy: z.ZodOptional<z.ZodArray<z.ZodEnum<["AMAZON", "MERCHANT"]>, "many">>;
13
+ maxResultsPerPage: z.ZodDefault<z.ZodNumber>;
14
+ includedData: z.ZodOptional<z.ZodArray<z.ZodEnum<["BUYER", "RECIPIENT", "PROCEEDS", "EXPENSE", "PROMOTION", "CANCELLATION", "FULFILLMENT", "PACKAGES"]>, "many">>;
15
+ paginationToken: z.ZodOptional<z.ZodString>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ marketplaceIds: string[];
18
+ maxResultsPerPage: number;
19
+ createdAfter?: string | undefined;
20
+ createdBefore?: string | undefined;
21
+ lastUpdatedAfter?: string | undefined;
22
+ lastUpdatedBefore?: string | undefined;
23
+ fulfillmentStatuses?: ("PENDING" | "UNSHIPPED" | "PARTIALLY_SHIPPED" | "SHIPPED" | "CANCELLED" | "UNFULFILLABLE")[] | undefined;
24
+ fulfilledBy?: ("AMAZON" | "MERCHANT")[] | undefined;
25
+ includedData?: ("BUYER" | "RECIPIENT" | "PROCEEDS" | "EXPENSE" | "PROMOTION" | "CANCELLATION" | "FULFILLMENT" | "PACKAGES")[] | undefined;
26
+ paginationToken?: string | undefined;
27
+ }, {
28
+ createdAfter?: string | undefined;
29
+ createdBefore?: string | undefined;
30
+ lastUpdatedAfter?: string | undefined;
31
+ lastUpdatedBefore?: string | undefined;
32
+ fulfillmentStatuses?: ("PENDING" | "UNSHIPPED" | "PARTIALLY_SHIPPED" | "SHIPPED" | "CANCELLED" | "UNFULFILLABLE")[] | undefined;
33
+ marketplaceIds?: string[] | undefined;
34
+ fulfilledBy?: ("AMAZON" | "MERCHANT")[] | undefined;
35
+ maxResultsPerPage?: number | undefined;
36
+ includedData?: ("BUYER" | "RECIPIENT" | "PROCEEDS" | "EXPENSE" | "PROMOTION" | "CANCELLATION" | "FULFILLMENT" | "PACKAGES")[] | undefined;
37
+ paginationToken?: string | undefined;
38
+ }>;
39
+ export declare const getOrderSchema: z.ZodObject<{
40
+ orderId: z.ZodString;
41
+ includedData: z.ZodOptional<z.ZodArray<z.ZodEnum<["BUYER", "RECIPIENT", "PROCEEDS", "EXPENSE", "PROMOTION", "CANCELLATION", "FULFILLMENT", "PACKAGES"]>, "many">>;
42
+ }, "strip", z.ZodTypeAny, {
43
+ orderId: string;
44
+ includedData?: ("BUYER" | "RECIPIENT" | "PROCEEDS" | "EXPENSE" | "PROMOTION" | "CANCELLATION" | "FULFILLMENT" | "PACKAGES")[] | undefined;
45
+ }, {
46
+ orderId: string;
47
+ includedData?: ("BUYER" | "RECIPIENT" | "PROCEEDS" | "EXPENSE" | "PROMOTION" | "CANCELLATION" | "FULFILLMENT" | "PACKAGES")[] | undefined;
48
+ }>;
49
+ export declare const cancelOrderSchema: z.ZodObject<{
50
+ orderId: z.ZodString;
51
+ cancelReasonCode: z.ZodEnum<["NO_INVENTORY", "BUYER_CANCELLED", "SHIPPING_ADDRESS_UNDELIVERABLE", "CUSTOMER_EXCHANGE", "PRICING_ERROR"]>;
52
+ }, "strip", z.ZodTypeAny, {
53
+ orderId: string;
54
+ cancelReasonCode: "NO_INVENTORY" | "BUYER_CANCELLED" | "SHIPPING_ADDRESS_UNDELIVERABLE" | "CUSTOMER_EXCHANGE" | "PRICING_ERROR";
55
+ }, {
56
+ orderId: string;
57
+ cancelReasonCode: "NO_INVENTORY" | "BUYER_CANCELLED" | "SHIPPING_ADDRESS_UNDELIVERABLE" | "CUSTOMER_EXCHANGE" | "PRICING_ERROR";
58
+ }>;
59
+ export declare const updateShipmentStatusSchema: z.ZodObject<{
60
+ orderId: z.ZodString;
61
+ marketplaceId: z.ZodDefault<z.ZodString>;
62
+ shipmentStatus: z.ZodEnum<["ReadyForPickup", "PickedUp", "RefusedPickup"]>;
63
+ orderItems: z.ZodOptional<z.ZodArray<z.ZodObject<{
64
+ orderItemId: z.ZodOptional<z.ZodString>;
65
+ quantity: z.ZodOptional<z.ZodNumber>;
66
+ }, "strip", z.ZodTypeAny, {
67
+ orderItemId?: string | undefined;
68
+ quantity?: number | undefined;
69
+ }, {
70
+ orderItemId?: string | undefined;
71
+ quantity?: number | undefined;
72
+ }>, "many">>;
73
+ }, "strip", z.ZodTypeAny, {
74
+ orderId: string;
75
+ marketplaceId: string;
76
+ shipmentStatus: "ReadyForPickup" | "PickedUp" | "RefusedPickup";
77
+ orderItems?: {
78
+ orderItemId?: string | undefined;
79
+ quantity?: number | undefined;
80
+ }[] | undefined;
81
+ }, {
82
+ orderId: string;
83
+ shipmentStatus: "ReadyForPickup" | "PickedUp" | "RefusedPickup";
84
+ marketplaceId?: string | undefined;
85
+ orderItems?: {
86
+ orderItemId?: string | undefined;
87
+ quantity?: number | undefined;
88
+ }[] | undefined;
89
+ }>;
90
+ export declare const updateVerificationStatusSchema: z.ZodObject<{
91
+ orderId: z.ZodString;
92
+ marketplaceId: z.ZodDefault<z.ZodString>;
93
+ regulatedOrderVerificationStatus: z.ZodObject<{
94
+ status: z.ZodEnum<["Approved", "Rejected", "Expired", "Cancelled"]>;
95
+ validUntil: z.ZodOptional<z.ZodString>;
96
+ rejectionReason: z.ZodOptional<z.ZodObject<{
97
+ rejectionReasonId: z.ZodString;
98
+ rejectionReasonDescription: z.ZodString;
99
+ }, "strip", z.ZodTypeAny, {
100
+ rejectionReasonId: string;
101
+ rejectionReasonDescription: string;
102
+ }, {
103
+ rejectionReasonId: string;
104
+ rejectionReasonDescription: string;
105
+ }>>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ status: "Approved" | "Rejected" | "Expired" | "Cancelled";
108
+ validUntil?: string | undefined;
109
+ rejectionReason?: {
110
+ rejectionReasonId: string;
111
+ rejectionReasonDescription: string;
112
+ } | undefined;
113
+ }, {
114
+ status: "Approved" | "Rejected" | "Expired" | "Cancelled";
115
+ validUntil?: string | undefined;
116
+ rejectionReason?: {
117
+ rejectionReasonId: string;
118
+ rejectionReasonDescription: string;
119
+ } | undefined;
120
+ }>;
121
+ }, "strip", z.ZodTypeAny, {
122
+ orderId: string;
123
+ marketplaceId: string;
124
+ regulatedOrderVerificationStatus: {
125
+ status: "Approved" | "Rejected" | "Expired" | "Cancelled";
126
+ validUntil?: string | undefined;
127
+ rejectionReason?: {
128
+ rejectionReasonId: string;
129
+ rejectionReasonDescription: string;
130
+ } | undefined;
131
+ };
132
+ }, {
133
+ orderId: string;
134
+ regulatedOrderVerificationStatus: {
135
+ status: "Approved" | "Rejected" | "Expired" | "Cancelled";
136
+ validUntil?: string | undefined;
137
+ rejectionReason?: {
138
+ rejectionReasonId: string;
139
+ rejectionReasonDescription: string;
140
+ } | undefined;
141
+ };
142
+ marketplaceId?: string | undefined;
143
+ }>;
144
+ export declare const confirmShipmentSchema: z.ZodObject<{
145
+ orderId: z.ZodString;
146
+ marketplaceId: z.ZodDefault<z.ZodString>;
147
+ packageDetail: z.ZodObject<{
148
+ packageReferenceId: z.ZodString;
149
+ carrierCode: z.ZodString;
150
+ shippingMethod: z.ZodOptional<z.ZodString>;
151
+ trackingNumber: z.ZodOptional<z.ZodString>;
152
+ shipDate: z.ZodString;
153
+ carrierName: z.ZodOptional<z.ZodString>;
154
+ shipFrom: z.ZodOptional<z.ZodObject<{
155
+ name: z.ZodString;
156
+ addressLine1: z.ZodString;
157
+ addressLine2: z.ZodOptional<z.ZodString>;
158
+ addressLine3: z.ZodOptional<z.ZodString>;
159
+ city: z.ZodString;
160
+ county: z.ZodOptional<z.ZodString>;
161
+ district: z.ZodOptional<z.ZodString>;
162
+ stateOrRegion: z.ZodString;
163
+ postalCode: z.ZodString;
164
+ countryCode: z.ZodString;
165
+ phone: z.ZodString;
166
+ }, "strip", z.ZodTypeAny, {
167
+ name: string;
168
+ addressLine1: string;
169
+ city: string;
170
+ stateOrRegion: string;
171
+ postalCode: string;
172
+ countryCode: string;
173
+ phone: string;
174
+ addressLine2?: string | undefined;
175
+ addressLine3?: string | undefined;
176
+ county?: string | undefined;
177
+ district?: string | undefined;
178
+ }, {
179
+ name: string;
180
+ addressLine1: string;
181
+ city: string;
182
+ stateOrRegion: string;
183
+ postalCode: string;
184
+ countryCode: string;
185
+ phone: string;
186
+ addressLine2?: string | undefined;
187
+ addressLine3?: string | undefined;
188
+ county?: string | undefined;
189
+ district?: string | undefined;
190
+ }>>;
191
+ }, "strip", z.ZodTypeAny, {
192
+ packageReferenceId: string;
193
+ carrierCode: string;
194
+ shipDate: string;
195
+ shippingMethod?: string | undefined;
196
+ trackingNumber?: string | undefined;
197
+ carrierName?: string | undefined;
198
+ shipFrom?: {
199
+ name: string;
200
+ addressLine1: string;
201
+ city: string;
202
+ stateOrRegion: string;
203
+ postalCode: string;
204
+ countryCode: string;
205
+ phone: string;
206
+ addressLine2?: string | undefined;
207
+ addressLine3?: string | undefined;
208
+ county?: string | undefined;
209
+ district?: string | undefined;
210
+ } | undefined;
211
+ }, {
212
+ packageReferenceId: string;
213
+ carrierCode: string;
214
+ shipDate: string;
215
+ shippingMethod?: string | undefined;
216
+ trackingNumber?: string | undefined;
217
+ carrierName?: string | undefined;
218
+ shipFrom?: {
219
+ name: string;
220
+ addressLine1: string;
221
+ city: string;
222
+ stateOrRegion: string;
223
+ postalCode: string;
224
+ countryCode: string;
225
+ phone: string;
226
+ addressLine2?: string | undefined;
227
+ addressLine3?: string | undefined;
228
+ county?: string | undefined;
229
+ district?: string | undefined;
230
+ } | undefined;
231
+ }>;
232
+ codCollectionMethod: z.ZodOptional<z.ZodEnum<["DirectPayment"]>>;
233
+ }, "strip", z.ZodTypeAny, {
234
+ orderId: string;
235
+ marketplaceId: string;
236
+ packageDetail: {
237
+ packageReferenceId: string;
238
+ carrierCode: string;
239
+ shipDate: string;
240
+ shippingMethod?: string | undefined;
241
+ trackingNumber?: string | undefined;
242
+ carrierName?: string | undefined;
243
+ shipFrom?: {
244
+ name: string;
245
+ addressLine1: string;
246
+ city: string;
247
+ stateOrRegion: string;
248
+ postalCode: string;
249
+ countryCode: string;
250
+ phone: string;
251
+ addressLine2?: string | undefined;
252
+ addressLine3?: string | undefined;
253
+ county?: string | undefined;
254
+ district?: string | undefined;
255
+ } | undefined;
256
+ };
257
+ codCollectionMethod?: "DirectPayment" | undefined;
258
+ }, {
259
+ orderId: string;
260
+ packageDetail: {
261
+ packageReferenceId: string;
262
+ carrierCode: string;
263
+ shipDate: string;
264
+ shippingMethod?: string | undefined;
265
+ trackingNumber?: string | undefined;
266
+ carrierName?: string | undefined;
267
+ shipFrom?: {
268
+ name: string;
269
+ addressLine1: string;
270
+ city: string;
271
+ stateOrRegion: string;
272
+ postalCode: string;
273
+ countryCode: string;
274
+ phone: string;
275
+ addressLine2?: string | undefined;
276
+ addressLine3?: string | undefined;
277
+ county?: string | undefined;
278
+ district?: string | undefined;
279
+ } | undefined;
280
+ };
281
+ marketplaceId?: string | undefined;
282
+ codCollectionMethod?: "DirectPayment" | undefined;
283
+ }>;
284
+ export declare const getOrderRegulatedInfoSchema: z.ZodObject<{
285
+ orderId: z.ZodString;
286
+ }, "strip", z.ZodTypeAny, {
287
+ orderId: string;
288
+ }, {
289
+ orderId: string;
290
+ }>;
291
+ //# sourceMappingURL=orders-schemas.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orders-schemas.d.ts","sourceRoot":"","sources":["../../src/zod-schemas/orders-schemas.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAiE7B,CAAC;AAEH,eAAO,MAAM,cAAc;;;;;;;;;EAiBzB,CAAC;AAEH,eAAO,MAAM,iBAAiB;;;;;;;;;EAW5B,CAAC;AAGH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBrC,CAAC;AAEH,eAAO,MAAM,8BAA8B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAwBzC,CAAC;AAEH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsChC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;EAEtC,CAAC"}
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Zod schemas for Orders API tools
3
+ */
4
+ import { z } from "zod";
5
+ // Orders API V1 Schemas
6
+ export const searchOrdersSchema = z.object({
7
+ createdAfter: z
8
+ .string()
9
+ .optional()
10
+ .describe("ISO 8601 date for orders created after this time (e.g., '2025-10-01T00:00:00Z')"),
11
+ createdBefore: z
12
+ .string()
13
+ .optional()
14
+ .describe("ISO 8601 date for orders created before this time"),
15
+ lastUpdatedAfter: z
16
+ .string()
17
+ .optional()
18
+ .describe("ISO 8601 date for orders last updated after this time"),
19
+ lastUpdatedBefore: z
20
+ .string()
21
+ .optional()
22
+ .describe("ISO 8601 date for orders last updated before this time"),
23
+ fulfillmentStatuses: z
24
+ .array(z.enum([
25
+ "PENDING",
26
+ "UNSHIPPED",
27
+ "PARTIALLY_SHIPPED",
28
+ "SHIPPED",
29
+ "CANCELLED",
30
+ "UNFULFILLABLE",
31
+ ]))
32
+ .optional()
33
+ .describe("Filter by fulfillment status"),
34
+ marketplaceIds: z
35
+ .array(z.string())
36
+ .default(["ATVPDKIKX0DER"])
37
+ .describe("Marketplace IDs to search in (e.g., ['ATVPDKIKX0DER' for US])"),
38
+ fulfilledBy: z
39
+ .array(z.enum(["AMAZON", "MERCHANT"]))
40
+ .optional()
41
+ .describe("Filter by fulfillment channel"),
42
+ maxResultsPerPage: z
43
+ .number()
44
+ .min(1)
45
+ .max(100)
46
+ .default(50)
47
+ .describe("Number of results per page (1-100)"),
48
+ includedData: z
49
+ .array(z.enum([
50
+ "BUYER",
51
+ "RECIPIENT",
52
+ "PROCEEDS",
53
+ "EXPENSE",
54
+ "PROMOTION",
55
+ "CANCELLATION",
56
+ "FULFILLMENT",
57
+ "PACKAGES",
58
+ ]))
59
+ .optional()
60
+ .describe("Data sets to include in response"),
61
+ paginationToken: z
62
+ .string()
63
+ .optional()
64
+ .describe("Token for pagination from previous response"),
65
+ });
66
+ export const getOrderSchema = z.object({
67
+ orderId: z.string().describe("Amazon order ID (e.g., '123-4567890-1234567')"),
68
+ includedData: z
69
+ .array(z.enum([
70
+ "BUYER",
71
+ "RECIPIENT",
72
+ "PROCEEDS",
73
+ "EXPENSE",
74
+ "PROMOTION",
75
+ "CANCELLATION",
76
+ "FULFILLMENT",
77
+ "PACKAGES",
78
+ ]))
79
+ .optional()
80
+ .describe("Data sets to include in response"),
81
+ });
82
+ export const cancelOrderSchema = z.object({
83
+ orderId: z.string().describe("Amazon order ID to cancel"),
84
+ cancelReasonCode: z
85
+ .enum([
86
+ "NO_INVENTORY",
87
+ "BUYER_CANCELLED",
88
+ "SHIPPING_ADDRESS_UNDELIVERABLE",
89
+ "CUSTOMER_EXCHANGE",
90
+ "PRICING_ERROR",
91
+ ])
92
+ .describe("Reason for cancellation"),
93
+ });
94
+ // Orders API V0 Schemas
95
+ export const updateShipmentStatusSchema = z.object({
96
+ orderId: z.string().describe("Amazon order ID"),
97
+ marketplaceId: z
98
+ .string()
99
+ .default("ATVPDKIKX0DER")
100
+ .describe("Marketplace ID (e.g., 'ATVPDKIKX0DER' for US)"),
101
+ shipmentStatus: z
102
+ .enum(["ReadyForPickup", "PickedUp", "RefusedPickup"])
103
+ .describe("New shipment status"),
104
+ orderItems: z
105
+ .array(z.object({
106
+ orderItemId: z.string().optional().describe("Order item ID"),
107
+ quantity: z.number().optional().describe("Quantity"),
108
+ }))
109
+ .optional()
110
+ .describe("Optional order items to update"),
111
+ });
112
+ export const updateVerificationStatusSchema = z.object({
113
+ orderId: z.string().describe("Amazon order ID"),
114
+ marketplaceId: z
115
+ .string()
116
+ .default("ATVPDKIKX0DER")
117
+ .describe("Marketplace ID (e.g., 'ATVPDKIKX0DER' for US)"),
118
+ regulatedOrderVerificationStatus: z.object({
119
+ status: z
120
+ .enum(["Approved", "Rejected", "Expired", "Cancelled"])
121
+ .describe("Verification status"),
122
+ validUntil: z
123
+ .string()
124
+ .optional()
125
+ .describe("ISO 8601 date when status is valid until"),
126
+ rejectionReason: z
127
+ .object({
128
+ rejectionReasonId: z.string().describe("Rejection reason ID"),
129
+ rejectionReasonDescription: z
130
+ .string()
131
+ .describe("Rejection reason description"),
132
+ })
133
+ .optional()
134
+ .describe("Rejection reason (required if status is 'Rejected')"),
135
+ }),
136
+ });
137
+ export const confirmShipmentSchema = z.object({
138
+ orderId: z.string().describe("Amazon order ID"),
139
+ marketplaceId: z
140
+ .string()
141
+ .default("ATVPDKIKX0DER")
142
+ .describe("Marketplace ID (e.g., 'ATVPDKIKX0DER' for US)"),
143
+ packageDetail: z.object({
144
+ packageReferenceId: z.string().describe("Package reference ID"),
145
+ carrierCode: z
146
+ .string()
147
+ .describe("Carrier code (e.g., 'UPS', 'FEDEX', 'USPS')"),
148
+ shippingMethod: z.string().optional().describe("Shipping method"),
149
+ trackingNumber: z.string().optional().describe("Tracking number"),
150
+ shipDate: z
151
+ .string()
152
+ .describe("ISO 8601 ship date (e.g., '2025-10-01T00:00:00Z')"),
153
+ carrierName: z.string().optional().describe("Carrier name"),
154
+ shipFrom: z
155
+ .object({
156
+ name: z.string().describe("Sender name"),
157
+ addressLine1: z.string().describe("Address line 1"),
158
+ addressLine2: z.string().optional().describe("Address line 2"),
159
+ addressLine3: z.string().optional().describe("Address line 3"),
160
+ city: z.string().describe("City"),
161
+ county: z.string().optional().describe("County"),
162
+ district: z.string().optional().describe("District"),
163
+ stateOrRegion: z.string().describe("State or region"),
164
+ postalCode: z.string().describe("Postal code"),
165
+ countryCode: z.string().describe("Country code (e.g., 'US')"),
166
+ phone: z.string().describe("Phone number"),
167
+ })
168
+ .optional()
169
+ .describe("Ship from address"),
170
+ }),
171
+ codCollectionMethod: z
172
+ .enum(["DirectPayment"])
173
+ .optional()
174
+ .describe("Cash on delivery collection method"),
175
+ });
176
+ export const getOrderRegulatedInfoSchema = z.object({
177
+ orderId: z.string().describe("Amazon order ID"),
178
+ });
package/package.json ADDED
@@ -0,0 +1,66 @@
1
+ {
2
+ "name": "@amazon-sp-api-release/dev-mcp",
3
+ "version": "0.0.1",
4
+ "description": "MCP server for Amazon SP-API Developers",
5
+ "license": "Apache-2.0",
6
+ "type": "module",
7
+ "main": "dist/index.js",
8
+ "bin": {
9
+ "selling-partner-api-dev-mcp": "./dist/index.js"
10
+ },
11
+ "scripts": {
12
+ "start": "node dist/index.js",
13
+ "dev": "tsx src/index.ts",
14
+ "build": "tsc",
15
+ "lint": "eslint src --ext .ts",
16
+ "lint:fix": "eslint src --ext .ts --fix",
17
+ "format": "prettier --write \"src/**/*.ts\"",
18
+ "format:check": "prettier --check \"src/**/*.ts\"",
19
+ "test": "jest",
20
+ "test:watch": "jest --watch",
21
+ "type-check": "tsc --noEmit",
22
+ "prepublishOnly": "npm run build",
23
+ "prepare": "npm run lint:fix && npm run format && npm run type-check"
24
+ },
25
+ "dependencies": {
26
+ "@modelcontextprotocol/sdk": "^1.11.2",
27
+ "axios": "^1.7.7",
28
+ "dotenv": "^16.4.5",
29
+ "zod": "^3.22.4"
30
+ },
31
+ "devDependencies": {
32
+ "@babel/core": "^7.25.2",
33
+ "@babel/preset-env": "^7.25.4",
34
+ "@babel/preset-typescript": "^7.24.7",
35
+ "@types/jest": "^29.5.12",
36
+ "@types/node": "^22.5.4",
37
+ "@typescript-eslint/eslint-plugin": "^8.3.0",
38
+ "@typescript-eslint/parser": "^8.3.0",
39
+ "babel-jest": "^29.7.0",
40
+ "eslint": "^9.9.1",
41
+ "eslint-config-prettier": "^9.1.0",
42
+ "jest": "^29.7.0",
43
+ "prettier": "^3.3.3",
44
+ "ts-jest": "^29.2.5",
45
+ "ts-node": "^10.9.2",
46
+ "tsx": "^4.19.1",
47
+ "typescript": "^5.5.4"
48
+ },
49
+ "files": [
50
+ "src/",
51
+ "dist/",
52
+ "!dist/utils",
53
+ "index.js",
54
+ "README.md"
55
+ ],
56
+ "keywords": [
57
+ "mcp",
58
+ "amazon",
59
+ "sp-api",
60
+ "orders",
61
+ "model-context-protocol"
62
+ ],
63
+ "publishConfig": {
64
+ "access": "public"
65
+ }
66
+ }
@@ -0,0 +1,88 @@
1
+ import axios, { AxiosInstance, AxiosRequestConfig, AxiosResponse } from "axios";
2
+
3
+ export interface SPAPIConfig {
4
+ clientId?: string;
5
+ clientSecret?: string;
6
+ refreshToken?: string;
7
+ baseUrl?: string;
8
+ }
9
+
10
+ interface TokenResponse {
11
+ access_token: string;
12
+ expires_in: number;
13
+ token_type: string;
14
+ }
15
+
16
+ export class SPAPIAuth {
17
+ private config: SPAPIConfig;
18
+ private accessToken: string | null = null;
19
+ private tokenExpiry: number | null = null;
20
+ private axiosInstance: AxiosInstance;
21
+
22
+ constructor(config: SPAPIConfig) {
23
+ this.config = config;
24
+ this.axiosInstance = axios.create();
25
+ }
26
+
27
+ private async getAccessToken(): Promise<string> {
28
+ // Check if we have a valid token
29
+ if (this.accessToken && this.tokenExpiry && Date.now() < this.tokenExpiry) {
30
+ return this.accessToken;
31
+ }
32
+
33
+ // Refresh the access token using LWA refresh token
34
+ try {
35
+ const response = await this.axiosInstance.post<TokenResponse>(
36
+ "https://api.amazon.com/auth/o2/token",
37
+ {
38
+ grant_type: "refresh_token",
39
+ client_id: this.config.clientId,
40
+ client_secret: this.config.clientSecret,
41
+ refresh_token: this.config.refreshToken,
42
+ },
43
+ {
44
+ headers: {
45
+ "Content-Type": "application/x-www-form-urlencoded",
46
+ },
47
+ },
48
+ );
49
+
50
+ this.accessToken = response.data.access_token;
51
+ // Set expiry 5 minutes before actual expiry to be safe
52
+ this.tokenExpiry = Date.now() + (response.data.expires_in - 300) * 1000;
53
+
54
+ return this.accessToken;
55
+ } catch (error: any) {
56
+ throw new Error(
57
+ `Failed to get access token: ${error.response?.data?.error_description || error.message}`,
58
+ );
59
+ }
60
+ }
61
+
62
+ async makeAuthenticatedRequest<T = any>(
63
+ method: string,
64
+ url: string,
65
+ params: Record<string, string> = {},
66
+ data: any = null,
67
+ ): Promise<AxiosResponse<T>> {
68
+ const accessToken = await this.getAccessToken();
69
+
70
+ const config: AxiosRequestConfig = {
71
+ method,
72
+ url,
73
+ headers: {
74
+ "x-amz-access-token": accessToken!,
75
+ "Content-Type": "application/json",
76
+ "User-Agent": "SP-API-Orders-V1-MCP/1.1.0",
77
+ },
78
+ params,
79
+ timeout: 30000,
80
+ };
81
+
82
+ if (data && (method === "POST" || method === "PUT")) {
83
+ config.data = data;
84
+ }
85
+
86
+ return this.axiosInstance.request<T>(config);
87
+ }
88
+ }