Building a Two-Step Injection Molding Agent: Deterministic First-Shot Setup & Sink-Mark Tuning via REST and MCP A developer demonstrated a two-step closed-loop injection molding agent that splits LLM reasoning from deterministic shop-floor physics via a REST API and MCP server. The workflow uses a /v1/first-shot endpoint to compute 47 machine parameters for a 56 g ABS electronics enclosure on a 160-ton press, then a /v1/optimize endpoint that loads the archived state and applies fuzzy rule Rule.dat #65 to raise holding pressure from 0 to 27.54 MPa and holding time to 1.54 s in response to moderate sink marks. When developers build AI copilots for manufacturing plants using Claude, Cursor, Dify, Coze, or OpenAI GPT Actions , the UI and workflow glue are the easy part. The hard part is physics : if an LLM guesses screw stroke positions or packing pressures on a 160-ton injection molding press, you get short shots, flash, or damaged tooling. A cleaner architecture separates reasoning/UI the LLM from deterministic shop-floor math a stateful physics API/MCP tool . In this tutorial, we'll walk through a production two-step closed-loop workflow using the AICraft Injection Process API & MCP Server https://aicraft4injection.com/?utm source=devto trial-card on a real cosmetic ABS electronics enclosure 2.2 mm wall, 56 g shot weight, Ø40 mm screw, 160 T press . first-shot → optimize Beat Stateless Prompts Real injection molding tryouts follow decoupled scientific molding: /v1/first-shot MEL , ML0 , VPTL , IL0..IL2 , barrel temperatures NT , BT1..BT4 , and multi-stage fill speeds/pressures — intentionally leaving holding/packing at 0 so the technician verifies fill balance first. /v1/optimize business id . Always pass target shot weight g total shot weight including runner . Without shot mass, no physical engine can derive true screw displacement from shot mass / density pi R^2 . curl -X POST https://aicraft4injection.com/v1/first-shot \ -H "Authorization: Bearer $AICRAFT API KEY" \ -H "Content-Type: application/json" \ -d '{ "business id": "ABS-HOUSING-160T", "target shot weight g": 56.0, "polymer": { "polymer abbreviation": "ABS" }, "mold": { "product ave thickness": 2.2, "product max length": 185.0 }, "machine": { "clamping force": 160, "injector": { "injector screw diameter mm": 40.0 } } }' For 56 g ABS on a Ø40 mm barrel A = π × 20² = 1256.6 mm² : | Parameter | Meaning | Calculated Value | Engineering Basis | |---|---|---|---| | MEL | Metering end position | 62.72 mm | 14.28 cushion + 41.44 fill stroke + 7.0 suck-back | | ML0 | Metering position stage 0 | 55.72 mm | 14.28 + 41.44 mm 93% initial first-shot fill | | VPTL | V/P switchover position | 14.28 mm | max 25% × fill, 0.085 × max stroke clamped 8, 20 mm | | IL0 | Stage 0 stroke end | 49.5 mm | Slow gate-entry ramp 0.50 × peak | | NT / BT1 | Nozzle / Zone 1 temp | 242.0 °C / 256.0 °C | Amorphous ABS melt gradient | | IP0 / IP1 | Injection pressure stages 0 & 1 | 55.25 / 57.38 MPa | Flow-length & wall-thickness pressure factors | | IV0 / IV1 | Injection velocity stages 0 & 1 | 12.95 / 25.9 mm/s | 2.20 s target fill window vs. 3.78 s freeze clock | | CT | Cooling time | 10.0 s | Derived from 2.2 mm ABS thermal diffusivity | | PP0 / PT0 | Holding pressure / time | 0.0 MPa / 0.0 s | T1 baseline prior to packing calibration | Because we included "business id": "ABS-HOUSING-160T" , the gateway automatically persists all 47 parameters scoped to your API key. SHRINKAGE Now the press operator reports moderate sink marks. Your agent only needs to send the same business id and the English defect enum: curl -X POST https://aicraft4injection.com/v1/optimize \ -H "Authorization: Bearer $AICRAFT API KEY" \ -H "Content-Type: application/json" \ -d '{ "business id": "ABS-HOUSING-160T", "defect info": { "defect": "SHRINKAGE", "level": "moderate" } }' The engine loads the archived 47-key state, fires fuzzy rule Rule.dat 65 IF SHRINKAGE mid AND PP0 low THEN PP0 add mid , and applies material-specific packing guards for ABS: PP0 0.0 → 27.54 MPa 0.48 × 57.38 MPa peak injection pressure PT0 0.0 → 1.54 s 2.2 mm wall × 0.7 PP1 = 12.39 MPa , PT1 = 1.1 s avoids gate overpacking and residual stress IT 5.2 s → 2.2 s so packing engages cleanly at V/P transfer without dead delay Every adjustment is returned inside recommend thinking , so your agent can explain why each number changed directly to the shop-floor technician. You don't even have to write wrapper code if your client supports remote MCP: { "mcpServers": { "aicraft-injection": { "url": "https://aicraft4injection.com/mcp", "headers": { "Authorization": "Bearer YOUR API KEY" } } } } Or run the open-source stdio wrapper github.com/DreamwayChan/aicraft-mcp-server . You can test this exact ABS scenario in the interactive browser sandbox or generate an instant 30-call free trial API/MCP key no credit card required here: 👉 https://aicraft4injection.com/?utm source=devto trial-card https://aicraft4injection.com/?utm source=devto trial-card If you're building plant-floor AI tools or MCP servers for manufacturing, I'd love to hear how you're separating LLM orchestration from deterministic engineering math in the comments