claude-plugin-wordpress-manager 1.7.2 → 1.8.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 (38) hide show
  1. package/.claude-plugin/plugin.json +5 -3
  2. package/CHANGELOG.md +28 -0
  3. package/agents/wp-ecommerce-manager.md +136 -0
  4. package/agents/wp-site-manager.md +1 -0
  5. package/docs/plans/2026-02-28-roadmap-v1.8-v2.1-design.md +314 -0
  6. package/docs/plans/2026-02-28-woocommerce-v1.8.0.md +2012 -0
  7. package/package.json +6 -3
  8. package/servers/wp-rest-bridge/build/tools/index.d.ts +927 -0
  9. package/servers/wp-rest-bridge/build/tools/index.js +20 -2
  10. package/servers/wp-rest-bridge/build/tools/wc-coupons.d.ts +144 -0
  11. package/servers/wp-rest-bridge/build/tools/wc-coupons.js +92 -0
  12. package/servers/wp-rest-bridge/build/tools/wc-customers.d.ts +141 -0
  13. package/servers/wp-rest-bridge/build/tools/wc-customers.js +92 -0
  14. package/servers/wp-rest-bridge/build/tools/wc-orders.d.ts +186 -0
  15. package/servers/wp-rest-bridge/build/tools/wc-orders.js +128 -0
  16. package/servers/wp-rest-bridge/build/tools/wc-products.d.ts +324 -0
  17. package/servers/wp-rest-bridge/build/tools/wc-products.js +177 -0
  18. package/servers/wp-rest-bridge/build/tools/wc-reports.d.ts +117 -0
  19. package/servers/wp-rest-bridge/build/tools/wc-reports.js +94 -0
  20. package/servers/wp-rest-bridge/build/tools/wc-settings.d.ts +72 -0
  21. package/servers/wp-rest-bridge/build/tools/wc-settings.js +70 -0
  22. package/servers/wp-rest-bridge/build/types.d.ts +85 -0
  23. package/servers/wp-rest-bridge/build/wordpress.d.ts +9 -0
  24. package/servers/wp-rest-bridge/build/wordpress.js +75 -0
  25. package/skills/wordpress-router/references/decision-tree.md +3 -1
  26. package/skills/wp-audit/SKILL.md +1 -0
  27. package/skills/wp-backup/SKILL.md +1 -0
  28. package/skills/wp-deploy/SKILL.md +1 -0
  29. package/skills/wp-woocommerce/SKILL.md +110 -0
  30. package/skills/wp-woocommerce/references/analytics-reports.md +75 -0
  31. package/skills/wp-woocommerce/references/coupon-marketing.md +92 -0
  32. package/skills/wp-woocommerce/references/order-workflow.md +88 -0
  33. package/skills/wp-woocommerce/references/payment-gateways.md +69 -0
  34. package/skills/wp-woocommerce/references/product-management.md +61 -0
  35. package/skills/wp-woocommerce/references/shipping-setup.md +79 -0
  36. package/skills/wp-woocommerce/references/tax-configuration.md +91 -0
  37. package/skills/wp-woocommerce/references/wc-extensions.md +97 -0
  38. package/skills/wp-woocommerce/scripts/woocommerce_inspect.mjs +181 -0
@@ -0,0 +1,128 @@
1
+ import { makeWooCommerceRequest } from '../wordpress.js';
2
+ import { z } from 'zod';
3
+ const wcListOrdersSchema = z.object({
4
+ per_page: z.number().optional().default(10).describe("Results per page (1-100)"),
5
+ page: z.number().optional().default(1).describe("Page number"),
6
+ status: z.enum(['pending', 'processing', 'on-hold', 'completed', 'cancelled', 'refunded', 'failed', 'trash', 'any']).optional().describe("Order status filter"),
7
+ customer: z.number().optional().describe("Filter by customer ID"),
8
+ after: z.string().optional().describe("Orders after date (ISO 8601)"),
9
+ before: z.string().optional().describe("Orders before date (ISO 8601)"),
10
+ orderby: z.enum(['date', 'id', 'title', 'slug']).optional().describe("Sort by field"),
11
+ order: z.enum(['asc', 'desc']).optional().default('desc').describe("Sort order"),
12
+ }).strict();
13
+ const wcGetOrderSchema = z.object({
14
+ id: z.number().describe("Order ID"),
15
+ }).strict();
16
+ const wcUpdateOrderStatusSchema = z.object({
17
+ id: z.number().describe("Order ID"),
18
+ status: z.enum(['pending', 'processing', 'on-hold', 'completed', 'cancelled', 'refunded', 'failed']).describe("New order status"),
19
+ }).strict();
20
+ const wcListOrderNotesSchema = z.object({
21
+ order_id: z.number().describe("Order ID"),
22
+ }).strict();
23
+ const wcCreateOrderNoteSchema = z.object({
24
+ order_id: z.number().describe("Order ID"),
25
+ note: z.string().describe("Note content"),
26
+ customer_note: z.boolean().optional().default(false).describe("If true, note is visible to customer"),
27
+ }).strict();
28
+ const wcCreateRefundSchema = z.object({
29
+ order_id: z.number().describe("Order ID"),
30
+ amount: z.string().describe("Refund amount (e.g. '9.99')"),
31
+ reason: z.string().optional().describe("Reason for refund"),
32
+ }).strict();
33
+ export const wcOrderTools = [
34
+ {
35
+ name: "wc_list_orders",
36
+ description: "Lists WooCommerce orders with filtering by status, customer, and date range",
37
+ inputSchema: { type: "object", properties: wcListOrdersSchema.shape },
38
+ },
39
+ {
40
+ name: "wc_get_order",
41
+ description: "Retrieves a single WooCommerce order with full details including line items",
42
+ inputSchema: { type: "object", properties: wcGetOrderSchema.shape },
43
+ },
44
+ {
45
+ name: "wc_update_order_status",
46
+ description: "Updates the status of a WooCommerce order (e.g. processing to completed)",
47
+ inputSchema: { type: "object", properties: wcUpdateOrderStatusSchema.shape },
48
+ },
49
+ {
50
+ name: "wc_list_order_notes",
51
+ description: "Lists all notes for a WooCommerce order",
52
+ inputSchema: { type: "object", properties: wcListOrderNotesSchema.shape },
53
+ },
54
+ {
55
+ name: "wc_create_order_note",
56
+ description: "Adds a note to a WooCommerce order (internal or customer-visible)",
57
+ inputSchema: { type: "object", properties: wcCreateOrderNoteSchema.shape },
58
+ },
59
+ {
60
+ name: "wc_create_refund",
61
+ description: "Creates a refund for a WooCommerce order",
62
+ inputSchema: { type: "object", properties: wcCreateRefundSchema.shape },
63
+ },
64
+ ];
65
+ export const wcOrderHandlers = {
66
+ wc_list_orders: async (params) => {
67
+ try {
68
+ const response = await makeWooCommerceRequest("GET", "orders", params);
69
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
70
+ }
71
+ catch (error) {
72
+ const errorMessage = error.response?.data?.message || error.message;
73
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error listing orders: ${errorMessage}` }] } };
74
+ }
75
+ },
76
+ wc_get_order: async (params) => {
77
+ try {
78
+ const response = await makeWooCommerceRequest("GET", `orders/${params.id}`);
79
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
80
+ }
81
+ catch (error) {
82
+ const errorMessage = error.response?.data?.message || error.message;
83
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error retrieving order: ${errorMessage}` }] } };
84
+ }
85
+ },
86
+ wc_update_order_status: async (params) => {
87
+ try {
88
+ const response = await makeWooCommerceRequest("PUT", `orders/${params.id}`, { status: params.status });
89
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
90
+ }
91
+ catch (error) {
92
+ const errorMessage = error.response?.data?.message || error.message;
93
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error updating order status: ${errorMessage}` }] } };
94
+ }
95
+ },
96
+ wc_list_order_notes: async (params) => {
97
+ try {
98
+ const response = await makeWooCommerceRequest("GET", `orders/${params.order_id}/notes`);
99
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
100
+ }
101
+ catch (error) {
102
+ const errorMessage = error.response?.data?.message || error.message;
103
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error listing order notes: ${errorMessage}` }] } };
104
+ }
105
+ },
106
+ wc_create_order_note: async (params) => {
107
+ try {
108
+ const { order_id, ...data } = params;
109
+ const response = await makeWooCommerceRequest("POST", `orders/${order_id}/notes`, data);
110
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
111
+ }
112
+ catch (error) {
113
+ const errorMessage = error.response?.data?.message || error.message;
114
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error creating order note: ${errorMessage}` }] } };
115
+ }
116
+ },
117
+ wc_create_refund: async (params) => {
118
+ try {
119
+ const { order_id, ...data } = params;
120
+ const response = await makeWooCommerceRequest("POST", `orders/${order_id}/refunds`, data);
121
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
122
+ }
123
+ catch (error) {
124
+ const errorMessage = error.response?.data?.message || error.message;
125
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error creating refund: ${errorMessage}` }] } };
126
+ }
127
+ },
128
+ };
@@ -0,0 +1,324 @@
1
+ import { Tool } from '@modelcontextprotocol/sdk/types.js';
2
+ import { z } from 'zod';
3
+ declare const wcListProductsSchema: z.ZodObject<{
4
+ per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
5
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
6
+ search: z.ZodOptional<z.ZodString>;
7
+ status: z.ZodOptional<z.ZodEnum<["draft", "pending", "private", "publish", "any"]>>;
8
+ category: z.ZodOptional<z.ZodNumber>;
9
+ tag: z.ZodOptional<z.ZodNumber>;
10
+ sku: z.ZodOptional<z.ZodString>;
11
+ stock_status: z.ZodOptional<z.ZodEnum<["instock", "outofstock", "onbackorder"]>>;
12
+ orderby: z.ZodOptional<z.ZodEnum<["date", "id", "title", "slug", "price", "popularity", "rating"]>>;
13
+ order: z.ZodDefault<z.ZodOptional<z.ZodEnum<["asc", "desc"]>>>;
14
+ }, "strict", z.ZodTypeAny, {
15
+ page: number;
16
+ per_page: number;
17
+ order: "asc" | "desc";
18
+ search?: string | undefined;
19
+ status?: "draft" | "pending" | "private" | "publish" | "any" | undefined;
20
+ orderby?: "slug" | "date" | "id" | "title" | "price" | "popularity" | "rating" | undefined;
21
+ category?: number | undefined;
22
+ tag?: number | undefined;
23
+ sku?: string | undefined;
24
+ stock_status?: "instock" | "outofstock" | "onbackorder" | undefined;
25
+ }, {
26
+ page?: number | undefined;
27
+ per_page?: number | undefined;
28
+ search?: string | undefined;
29
+ status?: "draft" | "pending" | "private" | "publish" | "any" | undefined;
30
+ orderby?: "slug" | "date" | "id" | "title" | "price" | "popularity" | "rating" | undefined;
31
+ order?: "asc" | "desc" | undefined;
32
+ category?: number | undefined;
33
+ tag?: number | undefined;
34
+ sku?: string | undefined;
35
+ stock_status?: "instock" | "outofstock" | "onbackorder" | undefined;
36
+ }>;
37
+ declare const wcGetProductSchema: z.ZodObject<{
38
+ id: z.ZodNumber;
39
+ }, "strict", z.ZodTypeAny, {
40
+ id: number;
41
+ }, {
42
+ id: number;
43
+ }>;
44
+ declare const wcCreateProductSchema: z.ZodObject<{
45
+ name: z.ZodString;
46
+ type: z.ZodDefault<z.ZodOptional<z.ZodEnum<["simple", "grouped", "external", "variable"]>>>;
47
+ status: z.ZodDefault<z.ZodOptional<z.ZodEnum<["draft", "pending", "private", "publish"]>>>;
48
+ regular_price: z.ZodOptional<z.ZodString>;
49
+ sale_price: z.ZodOptional<z.ZodString>;
50
+ description: z.ZodOptional<z.ZodString>;
51
+ short_description: z.ZodOptional<z.ZodString>;
52
+ sku: z.ZodOptional<z.ZodString>;
53
+ manage_stock: z.ZodOptional<z.ZodBoolean>;
54
+ stock_quantity: z.ZodOptional<z.ZodNumber>;
55
+ categories: z.ZodOptional<z.ZodArray<z.ZodObject<{
56
+ id: z.ZodNumber;
57
+ }, "strip", z.ZodTypeAny, {
58
+ id: number;
59
+ }, {
60
+ id: number;
61
+ }>, "many">>;
62
+ tags: z.ZodOptional<z.ZodArray<z.ZodObject<{
63
+ id: z.ZodNumber;
64
+ }, "strip", z.ZodTypeAny, {
65
+ id: number;
66
+ }, {
67
+ id: number;
68
+ }>, "many">>;
69
+ images: z.ZodOptional<z.ZodArray<z.ZodObject<{
70
+ src: z.ZodString;
71
+ }, "strip", z.ZodTypeAny, {
72
+ src: string;
73
+ }, {
74
+ src: string;
75
+ }>, "many">>;
76
+ }, "strict", z.ZodTypeAny, {
77
+ status: "draft" | "pending" | "private" | "publish";
78
+ type: "simple" | "grouped" | "external" | "variable";
79
+ name: string;
80
+ categories?: {
81
+ id: number;
82
+ }[] | undefined;
83
+ tags?: {
84
+ id: number;
85
+ }[] | undefined;
86
+ description?: string | undefined;
87
+ sku?: string | undefined;
88
+ regular_price?: string | undefined;
89
+ sale_price?: string | undefined;
90
+ short_description?: string | undefined;
91
+ manage_stock?: boolean | undefined;
92
+ stock_quantity?: number | undefined;
93
+ images?: {
94
+ src: string;
95
+ }[] | undefined;
96
+ }, {
97
+ name: string;
98
+ status?: "draft" | "pending" | "private" | "publish" | undefined;
99
+ type?: "simple" | "grouped" | "external" | "variable" | undefined;
100
+ categories?: {
101
+ id: number;
102
+ }[] | undefined;
103
+ tags?: {
104
+ id: number;
105
+ }[] | undefined;
106
+ description?: string | undefined;
107
+ sku?: string | undefined;
108
+ regular_price?: string | undefined;
109
+ sale_price?: string | undefined;
110
+ short_description?: string | undefined;
111
+ manage_stock?: boolean | undefined;
112
+ stock_quantity?: number | undefined;
113
+ images?: {
114
+ src: string;
115
+ }[] | undefined;
116
+ }>;
117
+ declare const wcUpdateProductSchema: z.ZodObject<{
118
+ id: z.ZodNumber;
119
+ name: z.ZodOptional<z.ZodString>;
120
+ status: z.ZodOptional<z.ZodEnum<["draft", "pending", "private", "publish"]>>;
121
+ regular_price: z.ZodOptional<z.ZodString>;
122
+ sale_price: z.ZodOptional<z.ZodString>;
123
+ description: z.ZodOptional<z.ZodString>;
124
+ short_description: z.ZodOptional<z.ZodString>;
125
+ sku: z.ZodOptional<z.ZodString>;
126
+ manage_stock: z.ZodOptional<z.ZodBoolean>;
127
+ stock_quantity: z.ZodOptional<z.ZodNumber>;
128
+ stock_status: z.ZodOptional<z.ZodEnum<["instock", "outofstock", "onbackorder"]>>;
129
+ }, "strict", z.ZodTypeAny, {
130
+ id: number;
131
+ status?: "draft" | "pending" | "private" | "publish" | undefined;
132
+ description?: string | undefined;
133
+ name?: string | undefined;
134
+ sku?: string | undefined;
135
+ stock_status?: "instock" | "outofstock" | "onbackorder" | undefined;
136
+ regular_price?: string | undefined;
137
+ sale_price?: string | undefined;
138
+ short_description?: string | undefined;
139
+ manage_stock?: boolean | undefined;
140
+ stock_quantity?: number | undefined;
141
+ }, {
142
+ id: number;
143
+ status?: "draft" | "pending" | "private" | "publish" | undefined;
144
+ description?: string | undefined;
145
+ name?: string | undefined;
146
+ sku?: string | undefined;
147
+ stock_status?: "instock" | "outofstock" | "onbackorder" | undefined;
148
+ regular_price?: string | undefined;
149
+ sale_price?: string | undefined;
150
+ short_description?: string | undefined;
151
+ manage_stock?: boolean | undefined;
152
+ stock_quantity?: number | undefined;
153
+ }>;
154
+ declare const wcDeleteProductSchema: z.ZodObject<{
155
+ id: z.ZodNumber;
156
+ force: z.ZodDefault<z.ZodOptional<z.ZodBoolean>>;
157
+ }, "strict", z.ZodTypeAny, {
158
+ id: number;
159
+ force: boolean;
160
+ }, {
161
+ id: number;
162
+ force?: boolean | undefined;
163
+ }>;
164
+ declare const wcListProductCategoriesSchema: z.ZodObject<{
165
+ per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
166
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
167
+ search: z.ZodOptional<z.ZodString>;
168
+ parent: z.ZodOptional<z.ZodNumber>;
169
+ orderby: z.ZodOptional<z.ZodEnum<["id", "name", "slug", "count"]>>;
170
+ order: z.ZodDefault<z.ZodOptional<z.ZodEnum<["asc", "desc"]>>>;
171
+ }, "strict", z.ZodTypeAny, {
172
+ page: number;
173
+ per_page: number;
174
+ order: "asc" | "desc";
175
+ search?: string | undefined;
176
+ parent?: number | undefined;
177
+ orderby?: "slug" | "id" | "name" | "count" | undefined;
178
+ }, {
179
+ page?: number | undefined;
180
+ per_page?: number | undefined;
181
+ search?: string | undefined;
182
+ parent?: number | undefined;
183
+ orderby?: "slug" | "id" | "name" | "count" | undefined;
184
+ order?: "asc" | "desc" | undefined;
185
+ }>;
186
+ declare const wcListProductVariationsSchema: z.ZodObject<{
187
+ product_id: z.ZodNumber;
188
+ per_page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
189
+ page: z.ZodDefault<z.ZodOptional<z.ZodNumber>>;
190
+ status: z.ZodOptional<z.ZodEnum<["draft", "pending", "private", "publish", "any"]>>;
191
+ }, "strict", z.ZodTypeAny, {
192
+ page: number;
193
+ per_page: number;
194
+ product_id: number;
195
+ status?: "draft" | "pending" | "private" | "publish" | "any" | undefined;
196
+ }, {
197
+ product_id: number;
198
+ page?: number | undefined;
199
+ per_page?: number | undefined;
200
+ status?: "draft" | "pending" | "private" | "publish" | "any" | undefined;
201
+ }>;
202
+ export declare const wcProductTools: Tool[];
203
+ export declare const wcProductHandlers: {
204
+ wc_list_products: (params: z.infer<typeof wcListProductsSchema>) => Promise<{
205
+ toolResult: {
206
+ content: {
207
+ type: string;
208
+ text: string;
209
+ }[];
210
+ isError?: undefined;
211
+ };
212
+ } | {
213
+ toolResult: {
214
+ isError: boolean;
215
+ content: {
216
+ type: string;
217
+ text: string;
218
+ }[];
219
+ };
220
+ }>;
221
+ wc_get_product: (params: z.infer<typeof wcGetProductSchema>) => Promise<{
222
+ toolResult: {
223
+ content: {
224
+ type: string;
225
+ text: string;
226
+ }[];
227
+ isError?: undefined;
228
+ };
229
+ } | {
230
+ toolResult: {
231
+ isError: boolean;
232
+ content: {
233
+ type: string;
234
+ text: string;
235
+ }[];
236
+ };
237
+ }>;
238
+ wc_create_product: (params: z.infer<typeof wcCreateProductSchema>) => Promise<{
239
+ toolResult: {
240
+ content: {
241
+ type: string;
242
+ text: string;
243
+ }[];
244
+ isError?: undefined;
245
+ };
246
+ } | {
247
+ toolResult: {
248
+ isError: boolean;
249
+ content: {
250
+ type: string;
251
+ text: string;
252
+ }[];
253
+ };
254
+ }>;
255
+ wc_update_product: (params: z.infer<typeof wcUpdateProductSchema>) => Promise<{
256
+ toolResult: {
257
+ content: {
258
+ type: string;
259
+ text: string;
260
+ }[];
261
+ isError?: undefined;
262
+ };
263
+ } | {
264
+ toolResult: {
265
+ isError: boolean;
266
+ content: {
267
+ type: string;
268
+ text: string;
269
+ }[];
270
+ };
271
+ }>;
272
+ wc_delete_product: (params: z.infer<typeof wcDeleteProductSchema>) => Promise<{
273
+ toolResult: {
274
+ content: {
275
+ type: string;
276
+ text: string;
277
+ }[];
278
+ isError?: undefined;
279
+ };
280
+ } | {
281
+ toolResult: {
282
+ isError: boolean;
283
+ content: {
284
+ type: string;
285
+ text: string;
286
+ }[];
287
+ };
288
+ }>;
289
+ wc_list_product_categories: (params: z.infer<typeof wcListProductCategoriesSchema>) => Promise<{
290
+ toolResult: {
291
+ content: {
292
+ type: string;
293
+ text: string;
294
+ }[];
295
+ isError?: undefined;
296
+ };
297
+ } | {
298
+ toolResult: {
299
+ isError: boolean;
300
+ content: {
301
+ type: string;
302
+ text: string;
303
+ }[];
304
+ };
305
+ }>;
306
+ wc_list_product_variations: (params: z.infer<typeof wcListProductVariationsSchema>) => Promise<{
307
+ toolResult: {
308
+ content: {
309
+ type: string;
310
+ text: string;
311
+ }[];
312
+ isError?: undefined;
313
+ };
314
+ } | {
315
+ toolResult: {
316
+ isError: boolean;
317
+ content: {
318
+ type: string;
319
+ text: string;
320
+ }[];
321
+ };
322
+ }>;
323
+ };
324
+ export {};
@@ -0,0 +1,177 @@
1
+ import { makeWooCommerceRequest } from '../wordpress.js';
2
+ import { z } from 'zod';
3
+ // ── Schemas ──────────────────────────────────────────────────────────
4
+ const wcListProductsSchema = z.object({
5
+ per_page: z.number().optional().default(10).describe("Results per page (1-100)"),
6
+ page: z.number().optional().default(1).describe("Page number"),
7
+ search: z.string().optional().describe("Search products by keyword"),
8
+ status: z.enum(['draft', 'pending', 'private', 'publish', 'any']).optional().describe("Product status filter"),
9
+ category: z.number().optional().describe("Filter by category ID"),
10
+ tag: z.number().optional().describe("Filter by tag ID"),
11
+ sku: z.string().optional().describe("Filter by exact SKU"),
12
+ stock_status: z.enum(['instock', 'outofstock', 'onbackorder']).optional().describe("Filter by stock status"),
13
+ orderby: z.enum(['date', 'id', 'title', 'slug', 'price', 'popularity', 'rating']).optional().describe("Sort by field"),
14
+ order: z.enum(['asc', 'desc']).optional().default('desc').describe("Sort order"),
15
+ }).strict();
16
+ const wcGetProductSchema = z.object({
17
+ id: z.number().describe("Product ID"),
18
+ }).strict();
19
+ const wcCreateProductSchema = z.object({
20
+ name: z.string().describe("Product name"),
21
+ type: z.enum(['simple', 'grouped', 'external', 'variable']).optional().default('simple').describe("Product type"),
22
+ status: z.enum(['draft', 'pending', 'private', 'publish']).optional().default('publish').describe("Product status"),
23
+ regular_price: z.string().optional().describe("Regular price (e.g. '19.99')"),
24
+ sale_price: z.string().optional().describe("Sale price"),
25
+ description: z.string().optional().describe("Full product description (HTML)"),
26
+ short_description: z.string().optional().describe("Short product description (HTML)"),
27
+ sku: z.string().optional().describe("Stock Keeping Unit"),
28
+ manage_stock: z.boolean().optional().describe("Enable stock management"),
29
+ stock_quantity: z.number().optional().describe("Stock quantity (requires manage_stock: true)"),
30
+ categories: z.array(z.object({ id: z.number() })).optional().describe("Category IDs, e.g. [{id: 15}]"),
31
+ tags: z.array(z.object({ id: z.number() })).optional().describe("Tag IDs, e.g. [{id: 3}]"),
32
+ images: z.array(z.object({ src: z.string() })).optional().describe("Image URLs, e.g. [{src: 'https://...'}]"),
33
+ }).strict();
34
+ const wcUpdateProductSchema = z.object({
35
+ id: z.number().describe("Product ID to update"),
36
+ name: z.string().optional().describe("Product name"),
37
+ status: z.enum(['draft', 'pending', 'private', 'publish']).optional().describe("Product status"),
38
+ regular_price: z.string().optional().describe("Regular price"),
39
+ sale_price: z.string().optional().describe("Sale price"),
40
+ description: z.string().optional().describe("Full description"),
41
+ short_description: z.string().optional().describe("Short description"),
42
+ sku: z.string().optional().describe("SKU"),
43
+ manage_stock: z.boolean().optional().describe("Enable stock management"),
44
+ stock_quantity: z.number().optional().describe("Stock quantity"),
45
+ stock_status: z.enum(['instock', 'outofstock', 'onbackorder']).optional().describe("Stock status"),
46
+ }).strict();
47
+ const wcDeleteProductSchema = z.object({
48
+ id: z.number().describe("Product ID to delete"),
49
+ force: z.boolean().optional().default(false).describe("True to permanently delete, false to move to trash"),
50
+ }).strict();
51
+ const wcListProductCategoriesSchema = z.object({
52
+ per_page: z.number().optional().default(10).describe("Results per page (1-100)"),
53
+ page: z.number().optional().default(1).describe("Page number"),
54
+ search: z.string().optional().describe("Search categories by keyword"),
55
+ parent: z.number().optional().describe("Filter by parent category ID"),
56
+ orderby: z.enum(['id', 'name', 'slug', 'count']).optional().describe("Sort by field"),
57
+ order: z.enum(['asc', 'desc']).optional().default('asc').describe("Sort order"),
58
+ }).strict();
59
+ const wcListProductVariationsSchema = z.object({
60
+ product_id: z.number().describe("Parent product ID"),
61
+ per_page: z.number().optional().default(10).describe("Results per page (1-100)"),
62
+ page: z.number().optional().default(1).describe("Page number"),
63
+ status: z.enum(['draft', 'pending', 'private', 'publish', 'any']).optional().describe("Variation status"),
64
+ }).strict();
65
+ // ── Tool Definitions ─────────────────────────────────────────────────
66
+ export const wcProductTools = [
67
+ {
68
+ name: "wc_list_products",
69
+ description: "Lists WooCommerce products with filtering, sorting, and pagination",
70
+ inputSchema: { type: "object", properties: wcListProductsSchema.shape },
71
+ },
72
+ {
73
+ name: "wc_get_product",
74
+ description: "Retrieves a single WooCommerce product by ID with full details",
75
+ inputSchema: { type: "object", properties: wcGetProductSchema.shape },
76
+ },
77
+ {
78
+ name: "wc_create_product",
79
+ description: "Creates a new WooCommerce product (simple, grouped, external, or variable)",
80
+ inputSchema: { type: "object", properties: wcCreateProductSchema.shape },
81
+ },
82
+ {
83
+ name: "wc_update_product",
84
+ description: "Updates an existing WooCommerce product's fields",
85
+ inputSchema: { type: "object", properties: wcUpdateProductSchema.shape },
86
+ },
87
+ {
88
+ name: "wc_delete_product",
89
+ description: "Deletes a WooCommerce product (trash or permanent)",
90
+ inputSchema: { type: "object", properties: wcDeleteProductSchema.shape },
91
+ },
92
+ {
93
+ name: "wc_list_product_categories",
94
+ description: "Lists WooCommerce product categories with hierarchy support",
95
+ inputSchema: { type: "object", properties: wcListProductCategoriesSchema.shape },
96
+ },
97
+ {
98
+ name: "wc_list_product_variations",
99
+ description: "Lists variations of a variable WooCommerce product",
100
+ inputSchema: { type: "object", properties: wcListProductVariationsSchema.shape },
101
+ },
102
+ ];
103
+ // ── Handlers ─────────────────────────────────────────────────────────
104
+ export const wcProductHandlers = {
105
+ wc_list_products: async (params) => {
106
+ try {
107
+ const response = await makeWooCommerceRequest("GET", "products", params);
108
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
109
+ }
110
+ catch (error) {
111
+ const errorMessage = error.response?.data?.message || error.message;
112
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error listing products: ${errorMessage}` }] } };
113
+ }
114
+ },
115
+ wc_get_product: async (params) => {
116
+ try {
117
+ const response = await makeWooCommerceRequest("GET", `products/${params.id}`);
118
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
119
+ }
120
+ catch (error) {
121
+ const errorMessage = error.response?.data?.message || error.message;
122
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error retrieving product: ${errorMessage}` }] } };
123
+ }
124
+ },
125
+ wc_create_product: async (params) => {
126
+ try {
127
+ const response = await makeWooCommerceRequest("POST", "products", params);
128
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
129
+ }
130
+ catch (error) {
131
+ const errorMessage = error.response?.data?.message || error.message;
132
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error creating product: ${errorMessage}` }] } };
133
+ }
134
+ },
135
+ wc_update_product: async (params) => {
136
+ try {
137
+ const { id, ...data } = params;
138
+ const response = await makeWooCommerceRequest("PUT", `products/${id}`, data);
139
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
140
+ }
141
+ catch (error) {
142
+ const errorMessage = error.response?.data?.message || error.message;
143
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error updating product: ${errorMessage}` }] } };
144
+ }
145
+ },
146
+ wc_delete_product: async (params) => {
147
+ try {
148
+ const response = await makeWooCommerceRequest("DELETE", `products/${params.id}`, { force: params.force });
149
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
150
+ }
151
+ catch (error) {
152
+ const errorMessage = error.response?.data?.message || error.message;
153
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error deleting product: ${errorMessage}` }] } };
154
+ }
155
+ },
156
+ wc_list_product_categories: async (params) => {
157
+ try {
158
+ const response = await makeWooCommerceRequest("GET", "products/categories", params);
159
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
160
+ }
161
+ catch (error) {
162
+ const errorMessage = error.response?.data?.message || error.message;
163
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error listing product categories: ${errorMessage}` }] } };
164
+ }
165
+ },
166
+ wc_list_product_variations: async (params) => {
167
+ try {
168
+ const { product_id, ...queryParams } = params;
169
+ const response = await makeWooCommerceRequest("GET", `products/${product_id}/variations`, queryParams);
170
+ return { toolResult: { content: [{ type: "text", text: JSON.stringify(response, null, 2) }] } };
171
+ }
172
+ catch (error) {
173
+ const errorMessage = error.response?.data?.message || error.message;
174
+ return { toolResult: { isError: true, content: [{ type: "text", text: `Error listing product variations: ${errorMessage}` }] } };
175
+ }
176
+ },
177
+ };