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 on a real cosmetic ABS electronics enclosure (2.2 mm wall, 56 g shot weight, Ø40 mm screw, 160 T press).

Why Two Steps (first-shot → optimize) Beat Stateless Prompts

Real injection molding tryouts follow decoupled scientific molding:

  1. First-shot baseline (/v1/first-shot): Compute exact volumetric screw positions (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.
  2. Defect-driven optimization (/v1/optimize): Once parts come out of the mold (say, with moderate sink marks / shrinkage), you feed the observed defect back into the engine. Instead of re-sending ~50 parameters every turn (where LLMs routinely drop keys like ML0 and break stroke math), you link both calls with a business_id.

Step 1: Compute the Volumetric First-Shot Baseline

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 } } }' 

Actual Engine Output (Real Physics, Zero Hallucination)

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.

Step 2: Close the Loop on Moderate Sink Marks (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" } ] }' 

Actual Tuned Output & Explainable Reasoning

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 (+27.54 MPa, 0.48 × 57.38 MPa peak injection pressure)
  • PT0: 0.0 → 1.54 s (+1.54 s, 2.2 mm wall × 0.7)
  • Stage 2 step-down: PP1 = 12.39 MPa, PT1 = 1.1 s (avoids gate overpacking and residual stress)
  • Injection time (IT): tightened from 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.

Wiring It Directly into Claude / Cursor / Dify via Streamable HTTP MCP

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).

Try It Free (No Credit Card)

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

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!