bos_smart_order_cycle_time
Analyze order processing time from creation through confirmation, packaging, and delivery to identify bottlenecks and improve efficiency.
Instructions
Phân tích thời gian xử lý đơn hàng (từ lúc tạo đến xác nhận, đóng gói, giao hàng) để tìm ra điểm nghẽn.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| start_date | Yes | Ngày bắt đầu (YYYY-MM-DD) | |
| end_date | Yes | Ngày kết thúc (YYYY-MM-DD) |
Implementation Reference
- src/tools/smart.ts:25-33 (handler)The tool definition for 'bos_smart_order_cycle_time'. The handler calls client.get('/mcp/smart/orders/cycle-time', args) making a GET request to the BOS API endpoint for order cycle time analysis.
{ name: 'bos_smart_order_cycle_time', description: 'Phân tích thời gian xử lý đơn hàng (từ lúc tạo đến xác nhận, đóng gói, giao hàng) để tìm ra điểm nghẽn.', schema: { start_date: { type: 'string', description: 'Ngày bắt đầu (YYYY-MM-DD)' }, end_date: { type: 'string', description: 'Ngày kết thúc (YYYY-MM-DD)' } }, handler: async (args, client) => client.get('/mcp/smart/orders/cycle-time', args), }, - src/index.ts:44-44 (registration)Import of smartTools (which includes bos_smart_order_cycle_time) into the main server file.
...erpTools, - src/index.ts:55-76 (registration)Registration loop where all tools (including bos_smart_order_cycle_time) are registered with the MCP server via server.tool() using Zod schemas.
for (const tool of allTools) { const zodSchema = toZodSchema(tool.schema); server.tool( tool.name, tool.description, zodSchema.shape, async (args: any) => { try { const result = await tool.handler(args, client); return { content: [{ type: 'text' as const, text: JSON.stringify(result, null, 2) }], }; } catch (error: any) { return { content: [{ type: 'text' as const, text: JSON.stringify({ error: error.message || 'Unknown error' }) }], isError: true, }; } } ); } - src/tools/index.ts:4-9 (schema)The McpTool interface that defines the shape of a tool (name, description, schema, handler), used by the bos_smart_order_cycle_time definition.
export interface McpTool { name: string; description: string; schema: Record<string, any>; handler: (args: any, client: BosApiClient) => Promise<any>; } - src/tools/index.ts:21-62 (helper)The toZodSchema function that converts the simple schema format to Zod schemas for MCP SDK registration.
export function toZodSchema(schema: Record<string, any>): z.ZodObject<any> { const shape: Record<string, z.ZodTypeAny> = {}; for (const [key, def] of Object.entries(schema)) { let field: z.ZodTypeAny; switch (def.type) { case 'number': field = z.number(); break; case 'boolean': field = z.boolean(); break; case 'array': field = z.array(z.any()); break; case 'object': field = z.record(z.any()); break; case 'string': default: if (def.enum) { field = z.enum(def.enum); } else { field = z.string(); } break; } if (def.description) { field = field.describe(def.description); } if (def.optional) { field = field.optional(); } shape[key] = field; } return z.object(shape); }