x
This commit is contained in:
1 parent
684fd6907b
commit
310e48fe6a
17 files changed
+424
-139
No files matched your search
@@ -70,7 +70,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
type: "object",
|
||||
properties: {
|
||||
search: { type: "string", description: "Search term" },
|
||||
limit: { type: "number", description: "Max results" }
|
||||
limit: { type: "number", description: "Max results" },
|
||||
lang: { type: "string", description: "Language code (e.g. th, en, all)" }
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -80,7 +81,8 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "number", description: "Product ID" }
|
||||
id: { type: "number", description: "Product ID" },
|
||||
lang: { type: "string", description: "Language code (e.g. th, en, all)" }
|
||||
},
|
||||
required: ["id"]
|
||||
}
|
||||
@@ -99,6 +101,21 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
|
||||
required: ["id"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "update_product_translation",
|
||||
description: "Update product translation for a specific language. Use this to add missing translations.",
|
||||
inputSchema: {
|
||||
type: "object",
|
||||
properties: {
|
||||
id: { type: "number", description: "Product ID" },
|
||||
lang: { type: "string", description: "Language code (e.g., en, ja, zh, vi, ko)" },
|
||||
name: { type: "string", description: "Translated product name" },
|
||||
description: { type: "string", description: "Translated description" },
|
||||
details: { type: "string", description: "Translated details (HTML or Markdown allowed)" }
|
||||
},
|
||||
required: ["id", "lang"]
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "upload_product_image_from_url",
|
||||
description: "Download image from URL, upload to backend, and append to product images",
|
||||
@@ -325,11 +342,13 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
case "search_products": {
|
||||
const search = params.search ? `&search=${encodeURIComponent(params.search)}` : "";
|
||||
const limit = params.limit ? `&limit=${params.limit}` : "&limit=10";
|
||||
const res = await api.get(`/products?${search}${limit}`);
|
||||
const lang = params.lang ? `&lang=${params.lang}` : "";
|
||||
const res = await api.get(`/products?${search}${limit}${lang}`);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "get_product_detail": {
|
||||
const res = await api.get(`/products/${params.id}`);
|
||||
const lang = params.lang ? `?lang=${params.lang}` : "";
|
||||
const res = await api.get(`/products/${params.id}${lang}`);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "update_product_content": {
|
||||
@@ -341,6 +360,15 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
||||
const res = await api.patch(`/products/${params.id}`, payload);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "update_product_translation": {
|
||||
const payload: any = {};
|
||||
if (params.name) payload.name = { [params.lang]: params.name };
|
||||
if (params.description) payload.description = { [params.lang]: params.description };
|
||||
if (params.details) payload.details = { [params.lang]: params.details };
|
||||
|
||||
const res = await api.patch(`/products/${params.id}`, payload);
|
||||
return { content: [{ type: "text", text: JSON.stringify(res.data, null, 2) }] };
|
||||
}
|
||||
case "upload_product_image_from_url": {
|
||||
// 1. Download image
|
||||
const imgRes = await axios.get(params.imageUrl, { responseType: 'arraybuffer' });
|
||||
|
||||
Reference in new issue
Block a user