|
|
@@ -80,7 +80,7 @@ const TOOLS: McpTool[] = [
|
|
|
},
|
|
|
{
|
|
|
name: 'shoprenter_list_orders',
|
|
|
- description: 'List orders from a ShopRenter store with filtering. At least one filter is REQUIRED (created_from, created_to, updated_from, updated_to, customer_email, or customer_name). Returns order details including customer info, items, status, and totals. Limited to 20 results maximum.',
|
|
|
+ description: 'List orders from a ShopRenter store with filtering. At least one filter is REQUIRED (createdAtMin, createdAtMax, updatedAtMin, updatedAtMax, or email). Returns order details including customer info, items, status, and totals. Limited to 20 results maximum.',
|
|
|
inputSchema: {
|
|
|
type: 'object',
|
|
|
properties: {
|
|
|
@@ -88,30 +88,26 @@ const TOOLS: McpTool[] = [
|
|
|
type: 'string',
|
|
|
description: 'The UUID of the ShopRenter store from the stores table'
|
|
|
},
|
|
|
- created_from: {
|
|
|
+ createdAtMin: {
|
|
|
type: 'string',
|
|
|
- description: 'Filter orders created after this ISO 8601 datetime (e.g., 2025-01-01T00:00:00Z)'
|
|
|
+ description: 'Filter orders created after this ISO 8601 datetime (e.g., 2025-01-01T10:30:00)'
|
|
|
},
|
|
|
- created_to: {
|
|
|
+ createdAtMax: {
|
|
|
type: 'string',
|
|
|
- description: 'Filter orders created before this ISO 8601 datetime'
|
|
|
+ description: 'Filter orders created before this ISO 8601 datetime (e.g., 2025-01-01T10:30:00)'
|
|
|
},
|
|
|
- updated_from: {
|
|
|
+ updatedAtMin: {
|
|
|
type: 'string',
|
|
|
- description: 'Filter orders updated after this ISO 8601 datetime'
|
|
|
+ description: 'Filter orders updated after this ISO 8601 datetime (e.g., 2025-01-01T10:30:00)'
|
|
|
},
|
|
|
- updated_to: {
|
|
|
+ updatedAtMax: {
|
|
|
type: 'string',
|
|
|
- description: 'Filter orders updated before this ISO 8601 datetime'
|
|
|
+ description: 'Filter orders updated before this ISO 8601 datetime (e.g., 2025-01-01T10:30:00)'
|
|
|
},
|
|
|
- customer_email: {
|
|
|
+ email: {
|
|
|
type: 'string',
|
|
|
description: 'Filter by customer email address'
|
|
|
},
|
|
|
- customer_name: {
|
|
|
- type: 'string',
|
|
|
- description: 'Filter by customer name (searches billing name)'
|
|
|
- },
|
|
|
status: {
|
|
|
type: 'string',
|
|
|
description: 'Filter by order status: any, pending, processing, on-hold, completed, cancelled, refunded, failed'
|
|
|
@@ -307,24 +303,23 @@ async function handleGetOrder(args: Record<string, any>): Promise<ToolCallResult
|
|
|
async function handleListOrders(args: Record<string, any>): Promise<ToolCallResult> {
|
|
|
const {
|
|
|
shop_id,
|
|
|
- created_from,
|
|
|
- created_to,
|
|
|
- updated_from,
|
|
|
- updated_to,
|
|
|
- customer_email,
|
|
|
- customer_name,
|
|
|
+ createdAtMin,
|
|
|
+ createdAtMax,
|
|
|
+ updatedAtMin,
|
|
|
+ updatedAtMax,
|
|
|
+ email,
|
|
|
status,
|
|
|
limit = 5
|
|
|
} = args;
|
|
|
|
|
|
// Validate at least one filter is provided
|
|
|
- const hasFilter = created_from || created_to || updated_from || updated_to || customer_email || customer_name;
|
|
|
+ const hasFilter = createdAtMin || createdAtMax || updatedAtMin || updatedAtMax || email;
|
|
|
if (!hasFilter) {
|
|
|
return {
|
|
|
content: [{
|
|
|
type: 'text',
|
|
|
text: JSON.stringify({
|
|
|
- error: 'At least one filter is required: created_from, created_to, updated_from, updated_to, customer_email, or customer_name'
|
|
|
+ error: 'At least one filter is required: createdAtMin, createdAtMax, updatedAtMin, updatedAtMax, or email'
|
|
|
})
|
|
|
}],
|
|
|
isError: true
|
|
|
@@ -359,29 +354,18 @@ async function handleListOrders(args: Record<string, any>): Promise<ToolCallResu
|
|
|
}
|
|
|
|
|
|
try {
|
|
|
- // Build filters
|
|
|
+ // Build filters using correct parameter names
|
|
|
const filters: ShopRenterOrderFilters = {};
|
|
|
if (status) filters.status = status;
|
|
|
- if (customer_email) filters.customer_email = customer_email;
|
|
|
- if (created_from) filters.created_from = created_from;
|
|
|
- if (created_to) filters.created_to = created_to;
|
|
|
- if (updated_from) filters.updated_from = updated_from;
|
|
|
- if (updated_to) filters.updated_to = updated_to;
|
|
|
+ if (email) filters.email = email;
|
|
|
+ if (createdAtMin) filters.createdAtMin = createdAtMin;
|
|
|
+ if (createdAtMax) filters.createdAtMax = createdAtMax;
|
|
|
+ if (updatedAtMin) filters.updatedAtMin = updatedAtMin;
|
|
|
+ if (updatedAtMax) filters.updatedAtMax = updatedAtMax;
|
|
|
|
|
|
// Fetch orders from ShopRenter API
|
|
|
- let orders: any[];
|
|
|
-
|
|
|
- if (customer_name) {
|
|
|
- // If filtering by customer name, we need to fetch and filter locally
|
|
|
- // because ShopRenter doesn't support name filtering directly
|
|
|
- filters.customer_name = customer_name;
|
|
|
- const response = await fetchOrders(shop_id, 0, actualLimit, filters);
|
|
|
- orders = Array.isArray(response) ? response : (response.data || response.orders || []);
|
|
|
- } else {
|
|
|
- // Direct API fetch with filters
|
|
|
- const response = await fetchOrders(shop_id, 0, actualLimit, filters);
|
|
|
- orders = Array.isArray(response) ? response : (response.data || response.orders || []);
|
|
|
- }
|
|
|
+ const response = await fetchOrders(shop_id, 0, actualLimit, filters);
|
|
|
+ const orders = Array.isArray(response) ? response : (response.data || response.orders || []);
|
|
|
|
|
|
// Apply limit
|
|
|
const limitedOrders = orders.slice(0, actualLimit);
|
|
|
@@ -396,12 +380,11 @@ async function handleListOrders(args: Record<string, any>): Promise<ToolCallResu
|
|
|
count: formattedOrders.length,
|
|
|
limit: actualLimit,
|
|
|
filters_applied: {
|
|
|
- created_from,
|
|
|
- created_to,
|
|
|
- updated_from,
|
|
|
- updated_to,
|
|
|
- customer_email,
|
|
|
- customer_name,
|
|
|
+ createdAtMin,
|
|
|
+ createdAtMax,
|
|
|
+ updatedAtMin,
|
|
|
+ updatedAtMax,
|
|
|
+ email,
|
|
|
status
|
|
|
},
|
|
|
orders: formattedOrders
|
|
|
@@ -579,7 +562,7 @@ async function handleToolCall(params: ToolCallParams): Promise<ToolCallResult> {
|
|
|
content: [{
|
|
|
type: 'text',
|
|
|
text: JSON.stringify({
|
|
|
- error: 'This tool has been removed. Use shoprenter_list_orders with customer_email filter instead.'
|
|
|
+ error: 'This tool has been removed. Use shoprenter_list_orders with email filter instead.'
|
|
|
})
|
|
|
}],
|
|
|
isError: true
|