This commit is contained in:
unknown committed 2026-06-25 16:46:38 +07:00
1 parent c23a4723ed
commit 07e9413a6b
13 files changed
+497 -94

No files matched your search

+119 -9
View File
@@ -253,24 +253,49 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
},
{
name: "create_product",
description: "Create a new product, optionally including its options and variant matrix. Minimum required fields are categoryId and brandId.",
description: "Create a new product, optionally including its options and variant matrix. Provide categoryId/brandId OR categoryName/brandName.",
inputSchema: {
type: "object",
properties: {
categoryId: { type: "number" },
categoryName: { type: "string" },
brandId: { type: "number" },
brandName: { type: "string" },
name: { type: "string" },
description: { type: "string" },
details: { type: "string" },
price: { type: "number", description: "Base price if no variants are provided" },
options: {
type: "array",
description: "Array of option definitions (max 3). E.g., [{'name': 'Size', 'values': ['S', 'M']}]",
items: {
translations: {
type: "object",
description: "Object with lang codes as keys (e.g. 'th', 'en') and {name, description, details} as values",
additionalProperties: {
type: "object",
properties: {
name: { type: "string" },
values: { type: "array", items: { type: "string" } }
description: { type: "string" },
details: { type: "string" }
}
}
},
options: {
type: "array",
description: "Array of option definitions (max 3). E.g., [{'name': {'th': 'ขนาด'}, 'values': [{'th': 'เล็ก'}, {'en': 'Small'}]}]",
items: {
type: "object",
properties: {
name: {
type: "object",
description: "Object with lang codes as keys, e.g. {'th': 'ขนาด', 'en': 'Size'}",
additionalProperties: { type: "string" }
},
values: {
type: "array",
items: {
type: "object",
description: "Object with lang codes as keys",
additionalProperties: { type: "string" }
}
}
},
required: ["name", "values"]
}
@@ -292,8 +317,80 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
required: ["option1"]
}
}
}
}
},
{
name: "bulk_create_products",
description: "Create multiple products at once. Each object in the array has the same schema as create_product.",
inputSchema: {
type: "object",
properties: {
products: {
type: "array",
items: {
type: "object",
properties: {
categoryId: { type: "number" },
categoryName: { type: "string" },
brandId: { type: "number" },
brandName: { type: "string" },
name: { type: "string" },
description: { type: "string" },
details: { type: "string" },
price: { type: "number" },
translations: {
type: "object",
additionalProperties: {
type: "object",
properties: {
name: { type: "string" },
description: { type: "string" },
details: { type: "string" }
}
}
},
options: {
type: "array",
items: {
type: "object",
properties: {
name: {
type: "object",
additionalProperties: { type: "string" }
},
values: {
type: "array",
items: {
type: "object",
additionalProperties: { type: "string" }
}
}
},
required: ["name", "values"]
}
},
variants: {
type: "array",
items: {
type: "object",
properties: {
sku: { type: "string" },
barcode: { type: "string" },
price: { type: "number" },
stock: { type: "number", default: 0 },
option1: { type: "string" },
option2: { type: "string" },
option3: { type: "string" }
},
required: ["option1"]
}
}
}
}
}
},
required: ["categoryId", "brandId"]
required: ["products"]
}
},
{
@@ -309,8 +406,17 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
items: {
type: "object",
properties: {
name: { type: "string" },
values: { type: "array", items: { type: "string" } }
name: {
type: "object",
additionalProperties: { type: "string" }
},
values: {
type: "array",
items: {
type: "object",
additionalProperties: { type: "string" }
}
}
},
required: ["name", "values"]
}
@@ -585,6 +691,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
const res = await api.post(`/products`, params);
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
}
case "bulk_create_products": {
const res = await api.post(`/products/bulk`, params.products);
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
}
case "sync_product_variants": {
const payload = {
options: params.options,