1+ label : order_workflow
2+ processors :
3+ - label : validate_order
4+ mutation : |
5+ # Validation logic
6+ root = if this.total <= 0 {
7+ throw("Invalid order total")
8+ } else { this }
9+
10+ - label : mock_inventory_check
11+ mutation : |
12+ # Mock inventory data for testing
13+ let inventory = {
14+ "widget-001": {"quantity": 100, "name": "Standard Widget"},
15+ "widget-premium": {"quantity": 25, "name": "Premium Widget"},
16+ "widget-limited": {"quantity": 2, "name": "Limited Edition Widget"}
17+ }
18+
19+ let product = $inventory.get(this.product_id)
20+ root = if $product == null {
21+ throw("Product not found: " + this.product_id)
22+ } else if $product.quantity < this.quantity {
23+ throw("Insufficient inventory. Available: " + $product.quantity.string())
24+ } else {
25+ this.merge({
26+ "inventory_check": "passed",
27+ "available_quantity": $product.quantity,
28+ "product_name": $product.name
29+ })
30+ }
31+
32+ - label : route_by_priority
33+ switch :
34+ - check : ' this.total > 1000'
35+ processors :
36+ - label : mock_high_value_processing
37+ mutation : |
38+ # Mock premium processing
39+ root = this.merge({
40+ "processing_tier": "premium",
41+ "processing_time_estimate": "2-4 hours",
42+ "assigned_rep": "[email protected] ", 43+ "priority_score": 95
44+ })
45+
46+ - check : ' this.customer_tier == "vip"'
47+ processors :
48+ - label : mock_vip_processing
49+ mutation : |
50+ # Mock VIP processing
51+ root = this.merge({
52+ "processing_tier": "vip",
53+ "processing_time_estimate": "1-2 hours",
54+ "assigned_rep": "[email protected] ", 55+ "priority_score": 90,
56+ "perks": ["expedited_shipping", "white_glove_service"]
57+ })
58+
59+ - processors :
60+ - label : mock_standard_processing
61+ mutation : |
62+ # Mock standard processing
63+ root = this.merge({
64+ "processing_tier": "standard",
65+ "processing_time_estimate": "24-48 hours",
66+ "assigned_rep": "[email protected] ", 67+ "priority_score": 50
68+ })
69+
70+ - label : finalize_order
71+ mutation : |
72+ # Add final processing metadata
73+ # Calculate estimated fulfillment by parsing processing time
74+ let max_hours = this.processing_time_estimate.split("-").index(1).split(" ").index(0).number()
75+
76+ root = this.merge({
77+ "order_status": "processed",
78+ "processed_at": now().ts_format("2006-01-02T15:04:05.000Z"),
79+ "estimated_fulfillment": "TBD - calculated based on processing tier",
80+ "processing_time_hours": $max_hours
81+ })
82+
83+ meta :
84+ mcp :
85+ enabled : true
86+ description : " Process orders with validation, inventory check, and tiered routing (with mocks for testing)"
87+ properties :
88+ - name : order_id
89+ type : string
90+ description : " Unique order identifier"
91+ required : true
92+ - name : product_id
93+ type : string
94+ description : " Product ID (try: widget-001, widget-premium, widget-limited)"
95+ required : true
96+ - name : quantity
97+ type : number
98+ description : " Quantity to order"
99+ required : true
100+ - name : total
101+ type : number
102+ description : " Order total in dollars"
103+ required : true
104+ - name : customer_tier
105+ type : string
106+ description : " Customer tier (optional: vip, standard)"
107+ required : false
0 commit comments