x
This commit is contained in:
1 parent
d325cd8763
commit
c6bf2f70ac
45 files changed
+5195
-338
No files matched your search
@@ -124,6 +124,140 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
},
|
||||
required: ["productId", "rating", "customerName"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "get_order_status",
|
||||
description: "Get the status and details of a specific order",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
orderId: { type: "number" }
|
||||
},
|
||||
required: ["orderId"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "list_pending_orders",
|
||||
description: "List orders that are pending payment or processing",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
limit: { type: "number", description: "Max results" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "update_order_tracking",
|
||||
description: "Update the tracking number of an order and optionally its status",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
orderId: { type: "number" },
|
||||
trackingNo: { type: "string" },
|
||||
status: { type: "string", description: "Optional status to update (e.g. SHIPPED)" }
|
||||
},
|
||||
required: ["orderId", "trackingNo"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "search_customer",
|
||||
description: "Search for customers by name, email, phone, or line ID",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
search: { type: "string", description: "Search term" }
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "adjust_customer_points",
|
||||
description: "Add or deduct points for a customer",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "number", description: "Customer ID" },
|
||||
pointsDelta: { type: "number", description: "Amount of points to add (positive) or deduct (negative)" },
|
||||
reason: { type: "string", description: "Reason for the adjustment" }
|
||||
},
|
||||
required: ["id", "pointsDelta"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "generate_special_coupon",
|
||||
description: "Generate a special discount coupon",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
code: { type: "string", description: "Coupon code (e.g. VIP20)" },
|
||||
type: { type: "string", description: "PERCENTAGE, FIXED_AMOUNT, or FREE_SHIPPING" },
|
||||
value: { type: "number", description: "Discount value" },
|
||||
minPurchase: { type: "number", description: "Minimum purchase amount" },
|
||||
maxDiscount: { type: "number", description: "Maximum discount amount for PERCENTAGE type" },
|
||||
usageLimit: { type: "number", description: "Maximum number of times this coupon can be used" },
|
||||
expiresAt: { type: "string", description: "ISO date string for expiration" }
|
||||
},
|
||||
required: ["code", "type", "value"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "list_dynamic_pages",
|
||||
description: "List all dynamic pages and layouts managed by the CMS",
|
||||
inputSchema: { type: "object", properties: {} }
|
||||
},
|
||||
{
|
||||
name: "create_dynamic_page",
|
||||
description: "Create or update a dynamic page or layout",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
title: { type: "string", description: "Title of the page" },
|
||||
slug: { type: "string", description: "Unique slug identifier (e.g. about-us)" },
|
||||
isPublished: { type: "boolean", description: "Publish status" },
|
||||
id: { type: "number", description: "Numeric page ID (if updating existing page)" }
|
||||
},
|
||||
required: ["title", "slug"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "add_page_section",
|
||||
description: "Add a block section to a dynamic page layout",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
pageId: { type: "number", description: "The numeric ID of the page" },
|
||||
type: { type: "string", description: "Block type (e.g. HERO, ANNOUNCEMENT_BAR, NEWSLETTER, EDITORIAL_TILE, EDITORIAL_CAROUSEL, PRODUCTS, CATEGORIES, TEXT, BANNER)" },
|
||||
order: { type: "number", description: "Display order sequence (starts at 1)" },
|
||||
payload: { type: "object", description: "The JSON payload matching the section type rules" },
|
||||
isActive: { type: "boolean", description: "Initial active state" }
|
||||
},
|
||||
required: ["pageId", "type", "order", "payload"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "update_page_section",
|
||||
description: "Update an existing block section payload, order or active state",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
sectionId: { type: "number", description: "The numeric ID of the section to update" },
|
||||
type: { type: "string", description: "Optional new block type" },
|
||||
order: { type: "number", description: "Optional new display order sequence" },
|
||||
payload: { type: "object", description: "Optional new JSON payload matching the section type rules" },
|
||||
isActive: { type: "boolean", description: "Optional new active state" }
|
||||
},
|
||||
required: ["sectionId"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "delete_page_section",
|
||||
description: "Delete a block section from a dynamic page layout",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
sectionId: { type: "number", description: "The numeric ID of the section to delete" }
|
||||
},
|
||||
required: ["sectionId"]
|
||||
}
|
||||
}
|
||||
],
|
||||
};
|
||||
@@ -198,6 +332,91 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
});
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "get_order_status": {
|
||||
const res = await api.get(`/orders/${params.orderId}`);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "list_pending_orders": {
|
||||
const res = await api.get(`/orders`);
|
||||
const pending = res.data.filter((o: any) => o.status === "PENDING_PAYMENT" || o.status === "PENDING" || o.status === "PROCESSING");
|
||||
if (params.limit) {
|
||||
pending.splice(params.limit);
|
||||
}
|
||||
return { content: [{ type: "text", text: JSON.stringify(pending, null, 2) }] };
|
||||
}
|
||||
case "update_order_tracking": {
|
||||
const payload: any = { trackingNo: params.trackingNo };
|
||||
const res1 = await api.patch(`/orders/${params.orderId}/tracking`, payload);
|
||||
|
||||
let result = res1.data;
|
||||
if (params.status) {
|
||||
const res2 = await api.patch(`/orders/${params.orderId}/status`, { status: params.status });
|
||||
result = res2.data;
|
||||
}
|
||||
return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] };
|
||||
}
|
||||
case "search_customer": {
|
||||
const search = params.search ? `?search=${encodeURIComponent(params.search)}` : "";
|
||||
const res = await api.get(`/customers${search}`);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "adjust_customer_points": {
|
||||
const payload = { pointsDelta: params.pointsDelta, reason: params.reason };
|
||||
const res = await api.patch(`/customers/${params.id}/points`, payload);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "generate_special_coupon": {
|
||||
const payload = {
|
||||
code: params.code,
|
||||
type: params.type,
|
||||
value: params.value,
|
||||
minPurchase: params.minPurchase,
|
||||
maxDiscount: params.maxDiscount,
|
||||
usageLimit: params.usageLimit,
|
||||
expiresAt: params.expiresAt
|
||||
};
|
||||
const res = await api.post(`/coupons`, payload);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "list_dynamic_pages": {
|
||||
const res = await api.get("/pages");
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "create_dynamic_page": {
|
||||
const payload: any = {
|
||||
title: params.title,
|
||||
slug: params.slug,
|
||||
isPublished: params.isPublished !== false
|
||||
};
|
||||
if (params.id) {
|
||||
payload.id = params.id;
|
||||
}
|
||||
const res = await api.post("/pages", payload);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "add_page_section": {
|
||||
const payload = {
|
||||
type: params.type,
|
||||
order: params.order,
|
||||
payload: params.payload,
|
||||
isActive: params.isActive !== false
|
||||
};
|
||||
const res = await api.post(`/pages/${params.pageId}/sections`, payload);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "update_page_section": {
|
||||
const payload: any = {};
|
||||
if (params.type) payload.type = params.type;
|
||||
if (params.order !== undefined) payload.order = params.order;
|
||||
if (params.payload) payload.payload = params.payload;
|
||||
if (params.isActive !== undefined) payload.isActive = params.isActive;
|
||||
const res = await api.put(`/pages/sections/${params.sectionId}`, payload);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "delete_page_section": {
|
||||
const res = await api.delete(`/pages/sections/${params.sectionId}`);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
default:
|
||||
throw new Error(`Unknown tool: ${request.params.name}`);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user