Connecting an AI Agent to MES and the Shop Floor
Office agents work with email, tickets and documents. A shop floor agent has a harder job: production orders from the MES, machine states, sensor time series and alarm logs, all living on a network that is deliberately cut off from the office. This guide covers the interfaces you can use, how to reach them safely, and where the approach stops working. Current as of November 2026.
What does connecting an AI agent to the MES actually mean?
It means giving a language model controlled read access to manufacturing data, plus a small set of tightly scoped actions. The agent reads orders, confirmations, machine states and measurements, answers questions and prepares decisions. It never runs equipment; it works at the level where shift supervisors, planners and maintenance engineers work today.
The layered model from ISA-95, published internationally as IEC 62264, is a useful map:
- Levels 0–1: the physical process, sensors and actuators.
- Level 2: monitoring and supervisory control, meaning PLCs and DCSs.
- Level 3: manufacturing operations management, where ISA-95 places the MES and systems such as SCADA.
- Level 4: business planning and logistics, typically the ERP.
In functional terms an agent lives on levels 3 and 4. It understands orders and KPIs and links them to documents such as work instructions or maintenance manuals. Data from levels 0 to 2 reaches it only indirectly, through an intermediate layer. That intermediate layer is what makes a shop floor integration different from connecting an agent to a CRM or a document store.
Questions such an agent is built for look like this: "Why has line 3 been down for 40 minutes?", "Which orders are at risk because of the tool change on machine 12?", "What did the early shift record about batch 4711?". None of them needs write access to a controller.
Which shop floor interfaces can an agent use?
A typical plant offers four data sources: the MES API, OPC UA servers on machines or gateways, an MQTT broker acting as a data hub, and a historian for time series. Which ones you use depends less on the AI than on what already runs in your plant and has someone looking after it.
The MES interface
The MES holds the business context: production orders, operations, confirmations, scrap, batches and crew assignments. Depending on the vendor, that context is exposed through web APIs (REST or SOAP), database views or scheduled exports. For an agent this is the most valuable source, because it links machine events to orders. Check the vendor documentation and talk to whoever runs the system before reading database tables directly; internal schemas change between releases.
OPC UA
OPC UA is a platform-independent, service-oriented architecture that the OPC Foundation released in 2008, standardised as the IEC 62541 series. The OPC Foundation reference site lists release 1.05.06 as the current core specification. Three properties matter for an agent:
- Information model. Values arrive as typed objects with units and structure, so the model can read "spindle speed, machine 12" rather than an anonymous register.
- Security. According to the OPC Foundation, clients and servers authenticate each other with X.509 certificates, messages can be signed and encrypted, and user rights and the visible part of the address space can be restricted.
- History. Part 11, Historical Access, specifies how clients query past values, provided the server supports it.
Besides client-server, OPC UA also defines PubSub, which the OPC Foundation describes as optimised for many-to-many configurations.
MQTT and Sparkplug
MQTT 5.0, an OASIS Standard since March 2019, is a publish/subscribe protocol: publishers send messages on topics to a broker, and subscribers receive the topics they ask for. That suits an agent, because it needs just one endpoint. The catch is that MQTT does not define payload structure. The Eclipse Foundation's Sparkplug specification (version 3.0, October 2022) closes that gap with a defined topic namespace, payload format and session state management.
The historian
A historian keeps time series for months or years: temperatures, pressures, cycle times, states. Root cause work depends on it. An agent should never pull bulk raw data into the model's context. Expose aggregated queries as tools instead, such as min, max and mean per shift, or the timestamps where a limit was exceeded.
How is a shop floor agent put together?
Four building blocks: the language model, a tool layer of narrow read functions, data access through a protected intermediate zone, and an approval step for every action. The model provides the reasoning; the tool layer provides the safety, because it decides what the agent can see and trigger in the first place.
Language model. It interprets the question, picks tools and writes the answer. Whether it runs in a public cloud or on your own hardware is a trade-off between capability, data control and operating effort; the overview of sovereign, self-hosted AI walks through the options.
Tool layer. Rather than handing the model a general database connection, define small functions such as order_status(order_id), downtime(line, from, to) or series_aggregate(tag, interval). One open standard for this is the Model Context Protocol (MCP), which standardises how tools, resources and prompts are offered to AI applications; the guide to MCP servers for AI agents covers how to build one. The specification itself warns that tools represent arbitrary code execution and says hosts must obtain explicit user consent before invoking any tool.
Data access. Tools talk to a replica or mirror of the plant data in an intermediate zone, never to machines directly (more on that below).
Approval. Anything that changes the state of production, such as rescheduling an order, raising a maintenance work order or changing a parameter, is created as a proposal and confirmed by a person.
A tool definition for such an agent might look like this:
# Read-only tool: downtime events for a line
name: line_downtime
description: "Returns downtime events with duration and reason code from the MES."
parameters:
line: { type: string, example: "L3" }
from: { type: datetime }
to: { type: datetime }
access: read_only
source: mes_replica_dmz
max_rows: 200
How do you keep IT and OT separate when an agent reads production data?
The agent runs on the IT network or in the cloud; the machines sit on the OT network. All data between them should pass through an intermediate zone, the DMZ. In SP 800-82 Rev. 3, NIST explicitly recommends preventing traffic from passing directly between corporate and OT networks.
The ISA/IEC 62443 series on industrial automation and control system security structures this with zones and conduits. ISA-62443-3-2 defines a conduit as a logical grouping of communication channels with common security requirements connecting two or more zones. For an agent, that translates into a few concrete rules:
- A zone of its own. The agent, its tool server and any data replicas do not belong in the same cell as the controllers.
- Data flows up, not down. An OPC UA aggregator or MQTT broker in the DMZ collects data from the OT side; the agent only touches that copy. NIST also lists unidirectional gateways (data diodes) as an alternative to firewalls when traffic must physically flow one way only.
- Separate identities. NIST recommends separate authentication mechanisms and credentials for corporate and OT users. Give the agent its own read-only service account, never a person's account.
- Logging. Record every tool call with timestamp, parameters and result size, so you can reconstruct what the agent saw when it made a recommendation.
This is where the shop floor differs from office systems. In a CRM, an agent is just another user, and the patterns from connecting AI agents to business systems apply. On the shop floor it is a new communication path between two networks that were separated on purpose, so it has to be designed into the existing zone model rather than bolted on.
What do companies use shop floor agents for?
Most useful applications are read-only: joining up orders, machines and documentation that a person currently pieces together from three different systems. Write cases are limited to proposals in the MES or the maintenance system that a person then confirms.
Shift handover. The agent summarises downtime, scrap and free-text notes from a shift and flags what is still open. Sources: MES confirmations, alarm logs, shift notes.
Breakdown analysis. When a line stops, the agent looks for unusual trends in the historian before the event, searches the breakdown archive for similar cases and pulls matching checks from the maintenance manual. The output is a list of hypotheses, not a diagnosis.
Order status enquiries. Sales or customer service ask where an order stands; the agent reads operations and confirmations from the MES and drafts the reply, so nobody has to walk to the line.
Maintenance proposals. From counters and condition data, the agent drafts maintenance work orders that wait for approval in the maintenance system.
If you build machines and want to offer this kind of capability at your customers' sites rather than in your own plant, AI agents for machinery manufacturers covers that angle: service, spare parts and the manufacturer's documentation. This article is about plugging into a plant's own systems. Agents for technical service often draw on the same machine data.
What do you need in place before connecting?
The key prerequisite has nothing to do with AI: production data that is consistently named, linked to orders and reachable through a documented interface. Add OT security sign-off, a named owner for every connected system, and a decision on where the language model will run.
Data
- Unique identifiers for machines, lines and tags. If one machine is "M12" in the MES, "L3_MILL_02" in the historian and "Mill 2" on its nameplate, the agent needs a mapping table.
- Timestamps in one time zone, with synchronised clocks. Otherwise MES events and historian data cannot be lined up.
- Downtime reasons as a code list, not only free text.
Systems
- A readable MES interface (API, view or export) with documentation.
- A place in the DMZ where data can be mirrored.
- A historian or time series database with a query interface.
Organisation
- OT security is involved from day one, not at go-live.
- Works councils or employee representatives are consulted early wherever data can be traced to individuals, for example confirmations carrying a personnel number. Requirements differ by country; this article is not legal advice.
- Every agent action has a named approver.
How do you roll it out step by step?
A six-step approach works well: start with one question people ask every week, and only then build interfaces. It keeps scope small, keeps the security review manageable and shows early whether your data can carry the use case.
- Pick one real question. For example: "Why did line 3 stop during last night's shift?" Write down who answers it today and which systems they open.
- Map the sources. For each part of the answer, name the source: MES for orders and downtime reasons, historian for trends, document store for manuals.
- Agree the zone design. Settle with OT security where the data replica sits, which ports are open and who manages certificates. In ISA/IEC 62443 terms: the agent infrastructure is its own zone, connected through a defined conduit.
- Build read tools. Three to five narrow functions with fixed parameters and capped result sizes. No free-form SQL generated by the model: unlike connecting an agent to a database via text-to-SQL, a fixed tool list is the safer route on the shop floor.
- Test against history. Run twenty to thirty past events with known answers through the agent and review every mismatch.
- Extend gradually. Only once read cases are reliable, add proposals with approval, such as a draft maintenance work order.
In our own operations we put step 5 before every extension: a small, fixed test set settles faster than any debate whether a new data source actually improves the answers.
What are the limits and risks?
A language model can link the wrong events, misread a time series and produce confident explanations that are simply wrong. The shop floor adds risks the office does not have: new network paths into OT, real-time constraints and decisions that affect equipment and people.
- Not real-time. An agent answers in seconds, not milliseconds. Control loops, interlocks and safety functions stay in PLCs and safety controllers.
- Not a safety system. Functional safety for machines and people must never depend on the agent.
- Correlation is not cause. A temperature rise before a stop is a pattern, not a root cause. Answers should cite the data they rest on, so experts can check them.
- Attack surface. Every new IT/OT connection is a potential attack path. Prompt injection, for instance via crafted text in shift notes, must never be able to trigger an action on equipment; that is why tools are read-only and actions need human approval.
- Data quality. Missing confirmations, inconsistent downtime reasons and drifting clocks feed straight into answer quality.
- When it does not fit: if your plant has no MES and most records start on paper, digitise production confirmations first. An agent will not fix missing data.
How do I get started with an MES agent?
Start with one question, one line and one data source, usually the MES. In parallel, agree with OT security where a read-only copy of the data may live, and decide whether the language model runs in a public cloud or on your own infrastructure.
A short checklist for the first conversation at the plant:
- Which question currently eats the most search time for supervisors, planners or maintenance?
- What interface does the MES offer, and who owns it?
- Is there already an OPC UA aggregator, MQTT broker or historian in a DMZ?
- Which data may leave the site, and which may not?
- Who approves the agent's proposals, and where is that recorded?
Once those answers are on the table, the technical integration is usually the smaller part of the work. If production data must not go to external model providers at all, sovereign AI explains the options for running models yourself. More background on agents by department and industry is in the guides section.
Frequently asked questions
Should an AI agent be allowed to write setpoints to a machine?
OPC UA makes writes technically possible, but the agent should not hold write access at the control level. It drafts a proposal, and a person confirms it in the MES or at the machine.
Do I need a new data platform before building an MES agent?
Usually not for a first use case. An existing MES interface plus a historian is often enough; a central MQTT broker becomes worthwhile once several applications need the same plant data.
Can the language model run in a public cloud when the data comes from production?
It depends on what the model sees and on your contracts and OT security policy. Many plants keep recipes, process parameters and quality data on a model they run on their own infrastructure.
How do OPC UA and MQTT differ from an agent's point of view?
OPC UA serves typed, structured data with an information model from machines or gateways. MQTT distributes messages through a broker to many consumers, but without a convention such as Sparkplug the payload structure is up to each publisher.
Sources
- ISA: ISA-95 Standard: Enterprise-Control System Integration isa.org
- OPC Foundation: Unified Architecture opcfoundation.org
- OPC Foundation: OPC UA Part 1 Overview and Concepts, Release 1.05.06 reference.opcfoundation.org
- OPC Foundation: OPC UA Part 11 Historical Access reference.opcfoundation.org
- IEC Webstore: IEC TR 62541-1 OPC Unified Architecture – Part 1 webstore.iec.ch
- OASIS: MQTT Version 5.0 docs.oasis-open.org
- Eclipse Foundation: Sparkplug Specification sparkplug.eclipse.org
- NIST SP 800-82 Rev. 3: Guide to Operational Technology (OT) Security csrc.nist.gov
- ISA: ISA/IEC 62443 Series of Standards isa.org
- ISA: ISA-62443-3-2 Preview (zones and conduits) isa.org
- Model Context Protocol: Specification modelcontextprotocol.io