x
This commit is contained in:
1 parent
81ed9af406
commit
4536db6741
56 files changed
+1127
-198
No files matched your search
@@ -253,20 +253,88 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
},
|
||||
{
|
||||
name: "create_product",
|
||||
description: "Create a new product. Minimum required fields are categoryId and brandId.",
|
||||
description: "Create a new product, optionally including its options and variant matrix. Minimum required fields are categoryId and brandId.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
categoryId: { type: "number" },
|
||||
brandId: { type: "number" },
|
||||
name: { type: "string" },
|
||||
price: { type: "number" },
|
||||
description: { type: "string" },
|
||||
details: { 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: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: { type: "string" },
|
||||
values: { type: "array", items: { type: "string" } }
|
||||
},
|
||||
required: ["name", "values"]
|
||||
}
|
||||
},
|
||||
variants: {
|
||||
type: "array",
|
||||
description: "List of variants. 'option1' maps to options[0].values, 'option2' to options[1].values, etc.",
|
||||
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"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "sync_product_variants",
|
||||
description: "Overwrite and synchronize the options and variant matrix for an existing product. The provided variants will replace or update existing ones based on option combinations.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
productId: { type: "number" },
|
||||
options: {
|
||||
type: "array",
|
||||
description: "The new or updated options array (max 3).",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
name: { type: "string" },
|
||||
values: { type: "array", items: { type: "string" } }
|
||||
},
|
||||
required: ["name", "values"]
|
||||
}
|
||||
},
|
||||
variants: {
|
||||
type: "array",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "number", description: "Include if updating an existing variant" },
|
||||
sku: { type: "string" },
|
||||
price: { type: "number" },
|
||||
stock: { type: "number" },
|
||||
option1: { type: "string" },
|
||||
option2: { type: "string" },
|
||||
option3: { type: "string" }
|
||||
},
|
||||
required: ["option1"]
|
||||
}
|
||||
}
|
||||
},
|
||||
required: ["productId", "options", "variants"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "update_product_content",
|
||||
description: "Update product basic content for the default/Thai translation. Note: If the Thai translation record does not exist yet, the 'name' field is strictly required, otherwise the backend will silently drop the update.",
|
||||
@@ -517,6 +585,14 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
const res = await api.post(`/products`, params);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "sync_product_variants": {
|
||||
const payload = {
|
||||
options: params.options,
|
||||
variants: params.variants
|
||||
};
|
||||
const res = await api.put(`/products/${params.productId}`, payload);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "update_category_translation": {
|
||||
const { id, lang, name } = params as any;
|
||||
const res = await api.patch(`/categories/${id}/translations`, {
|
||||
|
||||
Reference in new issue
Block a user