|
|
@@ -62,7 +62,7 @@ const SERVER_VERSION = '2.0.0';
|
|
|
const TOOLS: McpTool[] = [
|
|
|
{
|
|
|
name: 'shoprenter_get_order',
|
|
|
- description: 'Get a specific order from a ShopRenter store by order ID. Returns complete order details including customer info, items, status, and totals. Use this when a customer provides their order number.',
|
|
|
+ description: 'Get a specific order from a ShopRenter store by customer-visible order number (innerId). Returns complete order details including customer info, items, status, and totals. Use this when a customer provides their order number.',
|
|
|
inputSchema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
@@ -72,7 +72,7 @@ const TOOLS: McpTool[] = [
|
|
|
},
|
|
|
order_id: {
|
|
|
type: 'string',
|
|
|
- description: 'The ShopRenter order ID'
|
|
|
+ description: 'The customer-visible order number (innerId), e.g., "172" - NOT the internal API ID'
|
|
|
}
|
|
|
},
|
|
|
required: ['shop_id', 'order_id']
|
|
|
@@ -169,7 +169,7 @@ function formatOrderForLlm(order: any): LlmOrder {
|
|
|
|
|
|
return {
|
|
|
id: order.id,
|
|
|
- orderNumber: order.order_number || order.number || order.id,
|
|
|
+ orderNumber: order.innerId || order.order_number || order.number || order.id,
|
|
|
customer: {
|
|
|
name: customerName,
|
|
|
email: customerEmail,
|
|
|
@@ -259,11 +259,25 @@ async function handleGetOrder(args: Record<string, any>): Promise<ToolCallResult
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- // Fetch the specific order
|
|
|
- const order = await fetchOrder(shop_id, order_id);
|
|
|
+ // Search for order by innerId (customer-visible order number)
|
|
|
+ // The order_id parameter is actually the innerId from the customer's perspective
|
|
|
+ const response = await fetchOrders(shop_id, 1, 1, { innerId: order_id });
|
|
|
+ const orders = Array.isArray(response) ? response : (response.data || response.orders || []);
|
|
|
+
|
|
|
+ if (orders.length === 0) {
|
|
|
+ return {
|
|
|
+ content: [{
|
|
|
+ type: 'text',
|
|
|
+ text: JSON.stringify({
|
|
|
+ error: `No order found with order number: ${order_id}`
|
|
|
+ })
|
|
|
+ }],
|
|
|
+ isError: true
|
|
|
+ };
|
|
|
+ }
|
|
|
|
|
|
// Format for LLM
|
|
|
- const formattedOrder = formatOrderForLlm(order);
|
|
|
+ const formattedOrder = formatOrderForLlm(orders[0]);
|
|
|
|
|
|
return {
|
|
|
content: [{
|