x
This commit is contained in:
1 parent
4fcdd8a816
commit
f49776f9cb
14 files changed
+4012
-21
No files matched your search
@@ -430,6 +430,64 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
required: ["productId", "variants"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "list_marketplace_products",
|
||||
description: "List marketplace products (TikTok, Shopee, Lazada) extracted from orders. Allows filtering by status ('unmapped', 'mapped', 'all'), channel ('tiktok', 'shopee', 'lazada', 'all'), search text, and pagination. Returns sales metrics and current masterVariant mapping.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
channel: { type: "string", enum: ["tiktok", "shopee", "lazada", "all"], description: "Marketplace channel. Default is 'all'." },
|
||||
status: { type: "string", enum: ["unmapped", "mapped", "all"], description: "Mapping status. Default is 'unmapped'." },
|
||||
search: { type: "string", description: "Search by product name, variation, or SKU" },
|
||||
page: { type: "number", description: "Page number. Default 1." },
|
||||
limit: { type: "number", description: "Items per page. Default 50." }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "get_master_product_variants",
|
||||
description: "List all master product variants from the core catalog for mapping, including product name, options (size/scent), SKU, barcode, and unit BOM cost.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
search: { type: "string", description: "Search by product name, variant option, or SKU" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "map_marketplace_product",
|
||||
description: "Link or unlink a single marketplace product (TikTok/Shopee/Lazada) to a master product variant (ProductVariant) to enable BOM cost and profitability calculation. Pass masterVariantId=null to unlink.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
marketplaceProductId: { type: "number", description: "Marketplace product ID" },
|
||||
masterVariantId: { type: ["number", "null"], description: "Master variant ID, or null to unlink" }
|
||||
},
|
||||
required: ["marketplaceProductId", "masterVariantId"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "bulk_map_marketplace_products",
|
||||
description: "Link multiple marketplace products to master catalog variants in a single batch operation.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
mappings: {
|
||||
type: "array",
|
||||
description: "Array of mappings to apply",
|
||||
items: {
|
||||
type: "object",
|
||||
properties: {
|
||||
marketplaceProductId: { type: "number", description: "Marketplace product ID" },
|
||||
masterVariantId: { type: ["number", "null"], description: "Master variant ID, or null to unlink" }
|
||||
},
|
||||
required: ["marketplaceProductId", "masterVariantId"]
|
||||
}
|
||||
}
|
||||
},
|
||||
required: ["mappings"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "update_category_translation",
|
||||
description: "Add or update translations for a specific category. Do NOT use this tool for products.",
|
||||
@@ -1524,6 +1582,41 @@ async function handleToolRequest(request: CallToolRequest) {
|
||||
const res = await api.put(`/products/${params.productId}/bom`, { variants: params.variants });
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "list_marketplace_products": {
|
||||
const query = new URLSearchParams();
|
||||
if (params.channel) query.set("channel", String(params.channel));
|
||||
if (params.status) query.set("status", String(params.status));
|
||||
if (params.search) query.set("search", String(params.search));
|
||||
if (params.page) query.set("page", String(params.page));
|
||||
query.set("limit", String(params.limit ?? 50));
|
||||
const res = await api.get(`/tools/marketplace-products?${query.toString()}`);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "get_master_product_variants": {
|
||||
const res = await api.get(`/tools/marketplace-products/master-variants`);
|
||||
let variants = res.data.variants || [];
|
||||
if (params.search) {
|
||||
const words = String(params.search).toLowerCase().split(/\s+/).filter(Boolean);
|
||||
variants = variants.filter((v: any) => {
|
||||
const target = `${v.displayName} ${v.sku} ${v.productName} ${v.optionsStr}`.toLowerCase();
|
||||
return words.every((w: string) => target.includes(w));
|
||||
});
|
||||
}
|
||||
return { content: [{ type: "text", text: JSON.stringify({ variants }, null, 2) }] };
|
||||
}
|
||||
case "map_marketplace_product": {
|
||||
const res = await api.post(`/tools/marketplace-products/map`, {
|
||||
marketplaceProductId: params.marketplaceProductId,
|
||||
masterVariantId: params.masterVariantId,
|
||||
});
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "bulk_map_marketplace_products": {
|
||||
const res = await api.post(`/tools/marketplace-products/bulk-map`, {
|
||||
mappings: params.mappings,
|
||||
});
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "create_product": {
|
||||
const res = await api.post(`/products`, params);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
|
||||
Reference in new issue
Block a user