Large model context interaction method and system integrated with OPC UA

By introducing a session management layer and a JSON-RPC batch request service between the MCP client and the server, and directly accessing the OPC UA address space, the problem of low conversion efficiency between the MCP and OPC UA protocol stacks is solved, enabling efficient industrial equipment control and real-time communication.

CN121284055APending Publication Date: 2026-01-06UNIV OF SCI & TECH BEIJING
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511253427.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-09-03
Publication Date
2026-01-06

AI Technical Summary

Technical Problem

In existing technologies, the conversion efficiency of MCP and OPC UA protocol stacks is low, resulting in increased latency and semantic information distortion, which affects the control efficiency of LLM on industrial equipment.

Method used

By introducing a session management layer between the MCP client and server, and combining JSON-RPC batch requests and OPC UA standard request services, direct access to the OPC UA address space is achieved, simplifying protocol conversion and reducing intermediate steps.

Benefits of technology

It improves the communication efficiency and real-time performance between large models and industrial equipment, breaks down the barriers between the IT and OT fields, enhances the system's flexibility and scalability, and adapts to a wider range of industrial equipment and control systems.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121284055A_ABST
    Figure CN121284055A_ABST
Patent Text Reader

Abstract

The invention provides an OPC UA-integrated large-model context interaction method and system, and relates to the technical field of information integration, and the method comprises the steps: building a session connection; based on the session connection, the MCP client sends a model scanning request to the MCP server; in response to the model scanning request, scanning the model instance to obtain model information, and sending the model information to the MCP client; the model information is sent to a JSON processor; formatting the model information, and sending a formatting result to the large model; a user sends a request to the large model, whether a node needs to be accessed or not is judged according to the sent request, if yes, a message is generated, the user request is extracted, an extraction result is sent to the MCP client, and the request type is judged; otherwise, directly answering; processing the request according to the request type, generating response information, and sending the response information to the large model; and generating a reply according to the response information and sending the reply to the user.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of information integration technology, and in particular to a method and system for large model context interaction that integrates OPC UA. Background Technology

[0002] OPC UA is a commonly used communication protocol in industrial automation. It supports the construction of semantic information models for industrial equipment and can achieve semantic-based data communication using client / server communication modes. It provides a standardized solution for interoperability of all industrial elements and is gradually becoming the mainstream standard for industrial interconnection. MCP is a protocol used for interaction between large language models (such as GPT) and external tools or systems (such as industrial control equipment, sensors, etc.). A large model context interaction method integrating OPC UA refers to combining the MCP and OPC UA protocols, enabling large language models (such as AI models) to access and operate the information model of industrial equipment (provided through the OPC UA protocol) via the MCP protocol, thereby realizing intelligent control of industrial control systems.

[0003] However, existing technical solutions perform protocol conversion between MCP and OPC UA, enabling LLMs to indirectly access the semantic model in the OPC UA server via the MCP protocol, thus controlling industrial equipment. This protocol stack-based conversion solution is inefficient. Furthermore, the MCP server performs a certain degree of translation of the OPC UA semantic information model, which not only increases conversion latency but also easily leads to distortion of the semantic information understood by the LLM, reducing task execution efficiency. Summary of the Invention

[0004] To address the issues of low efficiency caused by processing latency introduced by protocol stack conversion in existing technical solutions, and the distortion of semantic information understood by LLM due to a certain degree of translation of the OPC UA semantic information model by the MCP server, this invention provides a method and system for large model context interaction that integrates OPC UA.

[0005] The technical solutions provided by the embodiments of the present invention are as follows: First aspect: This invention provides a method for large model context interaction integrating OPC UA, comprising: S1: The MCP client establishes a session connection with the MCP server; S2: Based on the session connection, the MCP client sends a model scan request to the MCP server; S3: The MCP server responds to the model scan request, scans the model instances in the OPC UA address space, obtains the model information, and sends the model information to the MCP client; S4: The MCP client sends the model information to the JSON processor; S5: Format the model information using a JSON processor and send the formatted results to the large model; S6: The user sends a request to the large model. Based on the request, it determines whether it needs to access a node in the OPC UA address space. If so, it generates a JSON message, extracts the user's request, sends the extraction result to the MCP client, and determines the request type. Otherwise, it directly responds. S7: Based on the request type and session connection, process the user request using different processing methods, generate response information, and send the response information to the large model; S8: Update the context of the large model based on the response information. The large model then performs inference based on the updated context information and generates a response to send to the user.

[0006] The second aspect: This invention provides a large model context interaction system integrating OPC UA, comprising: processor; The memory stores computer-readable instructions that, when executed by the processor, implement a large model context interaction method such as the integrated OPC UA of the first aspect.

[0007] Third aspect: The present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a large model context interaction method integrating OPC UA as described in the first aspect.

[0008] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: In this embodiment of the invention, the OPC UA and MCP protocol stack are integrated and reconstructed. The original MCP services are extended by adding OPC UA standard request / standard response services and JSON-RPC batch request / processing services to the protocol stack. Furthermore, certain layers of the OPC UA protocol stack are used as transport layer protocols for the MCP client / server. This enables large models to directly access semantic model information in the OPC UA address space on demand through the MCP client, simplifying protocol conversion between large models and devices, reducing intermediate steps, improving operational efficiency and real-time performance, breaking down the barriers between the IT and OT (Operational Technology) domains, promoting the integration of industrial automation and artificial intelligence, and adapting to a wider range of industrial equipment and control systems, exhibiting strong flexibility and scalability. Attached Figure Description

[0009] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0010] Figure 1 A flowchart illustrating a large model context interaction method integrating OPC UA provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the structure of an MCP protocol stack that integrates OPC UA address space access function, provided in an embodiment of the present invention. Figure 3 A schematic diagram of a visual sorting scenario based on a large model provided in an embodiment of the present invention; Figure 4 This is a schematic diagram of the structure of an OPC UA information model provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a large model context interaction system integrating OPC UA provided in an embodiment of the present invention. Detailed Implementation

[0011] The technical solution of the present invention will now be described with reference to the accompanying drawings.

[0012] In embodiments of the present invention, words such as "exemplarily," "for example," etc., are used to indicate that something is an example, illustration, or description. Any embodiment or design described as "exemplary" in the present invention should not be construed as being more preferred or advantageous than other embodiments or designs. Specifically, the use of the word "exemplary" is intended to present the concept in a concrete manner. Furthermore, in embodiments of the present invention, the meaning expressed by "and / or" can be both, or either one.

[0013] In the embodiments of this invention, the terms "image" and "picture" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning. Similarly, the terms "of," "corresponding (relevant)," and "corresponding" may sometimes be used interchangeably. It should be noted that, without emphasizing the distinction between them, they convey the same meaning.

[0014] In this embodiment of the invention, sometimes a subscript such as W1 may be written in a non-subscript form such as W1. When the difference is not emphasized, the meaning they express is the same.

[0015] To make the technical problems, technical solutions and advantages of the present invention clearer, a detailed description will be given below in conjunction with the accompanying drawings and specific embodiments.

[0016] Reference manual attached Figure 1 The diagram illustrates a flowchart of a large model context interaction method integrating OPC UA provided in an embodiment of the present invention.

[0017] Reference manual attached Figure 2 The diagram illustrates the structure of an MCP protocol stack that integrates OPC UA address space access functionality, as provided in an embodiment of the present invention.

[0018] Reference manual attached Figure 3 The diagram illustrates a visual sorting scenario based on a large model, as provided in an embodiment of the present invention.

[0019] Reference manual attached Figure 4 The diagram shows a structural schematic of an OPC UA information model provided in an embodiment of the present invention.

[0020] This invention provides a method for large model context interaction integrating OPC UA. This method can be implemented by a device integrating OPC UA, which can be a terminal or a server. The processing flow of the method for large model context interaction integrating OPC UA may include the following steps: S1: The MCP client establishes a session connection with the MCP server.

[0021] In this context, the MCP client refers to the client device or system that communicates with the MCP server, responsible for initiating requests and receiving responses. The MCP server refers to the server-side component that handles requests and manages communication sessions, receiving requests from MCP clients and returning responses. A session connection refers to the process of establishing a connection between the client and the server, ensuring that both parties can exchange information.

[0022] It should be noted that establishing a stable session connection between the MCP client and the MCP server ensures efficient and reliable data exchange between the two parties. The introduction of a session management layer further optimizes session control, guaranteeing that both parties maintain a consistent state during communication. This approach, through connection state management, not only improves communication reliability but also reduces the risk of potential communication errors and data loss.

[0023] In one possible implementation, S1 specifically refers to: Session connections are established through the session management layer of the MCP client and the MCP server.

[0024] The session management layer refers to the module that manages the state and lifecycle of sessions between the MCP client and server. It is responsible for ensuring the creation, maintenance, and termination of sessions, guaranteeing the continuity and consistency of communication.

[0025] It's worth noting that introducing a session management layer in both the MCP client and server to establish session connections significantly improves the reliability and efficiency of communication. The session management layer ensures the connection between the client and server remains active at all times and tracks state information during communication, avoiding latency and resource waste caused by frequent connection establishment and disconnection. This mechanism enables both parties to exchange data efficiently and maintain a consistent context across multiple requests, making it particularly suitable for applications requiring long-term stable connections, such as automation systems and industrial control.

[0026] S2: Based on the session connection, the MCP client sends a model scan request to the MCP server.

[0027] Among them, the model scan request is an extended MCP service request used to scan the information model in the OPC UA address space and return all nodes and their semantic relationships.

[0028] It's important to note that proactively triggering a model scan request after the session is established allows for the acquisition of the complete information model from the OPC UA address space in a single step, which is then passed to the large model. Compared to traditional node-by-node queries, this approach reduces latency caused by multiple interactions and prevents the loss of semantic information due to secondary encapsulation by the tool. Simultaneously, model scanning directly provides the hierarchical relationships and semantic connections between nodes, enabling the large model to possess a global understanding of the entire system structure from the initial stage. This "scan first, then access" mechanism significantly improves the efficiency of subsequent task decision-making and execution, allowing the large model to quickly and accurately locate the required nodes, reducing access complexity, and significantly improving the response speed and stability of the industrial intelligent agent.

[0029] In one possible implementation, S2 is followed by: The service management layer of the MCP client automatically sends model scanning requests to the JSON-RPC batch request service.

[0030] Among them, the JSON-RPC batch request service is a remote procedure call protocol based on JSON format, used to process multiple operation requests in batches. It can efficiently process multiple requests and encapsulate them into a single request. Model scan requests are combinations of multiple individual requests, typically used to send multiple operation requests at once, improving system processing efficiency.

[0031] Generate a JSON-RPC message based on the model scan request.

[0032] JSON-RPC messages refer to messages in JSON-RPC format generated based on model scan requests. JSON-RPC is a JSON-based remote procedure call protocol used to transmit requests and responses between clients and servers.

[0033] The JSON-RPC message is sent to the OPC UA transport layer, and the JSON-RPC message is encapsulated into an OPC UA data frame and sent to the MCP server.

[0034] The OPC UA transport layer is the transport layer in the OPC UA protocol, responsible for transmitting data from the MCP client to the MCP server, ensuring that data can be transmitted correctly between devices.

[0035] It should be noted that the model scan request is automatically triggered by the service management layer of the MCP client, and the scan request is uniformly encapsulated into JSON-RPC messages using the JSON-RPC batch request service. These messages are then encapsulated into data frames by the OPC UA transport layer and transmitted to the server. This mechanism avoids manual or sequential request triggering, significantly reducing interaction latency and control complexity. Simultaneously, leveraging the batch request feature, a complete scan of the OPC UA address space can be completed in a single communication, ensuring the integrity and consistency of semantic information. Compared to the traditional method of accessing the data step-by-step through multiple requests, this solution improves communication efficiency, reduces the number of protocol conversions and message parsing operations, and enables large models to obtain comprehensive model structure information in the initial stage, laying the foundation for rapid decision-making and efficient task execution.

[0036] In one possible implementation, the model scan request is specifically an opcua / model / scan request.

[0037] The opcua / model / scan request is used to scan for instances of OPC UA model information.

[0038] The `opcua / model / scan` request is a specific request type used to scan instances of the OPC UA (Open Platform UA) information model. Through this request, the system can probe and access various data and node instances within the OPC UA model. The OPC UA information model describes various data and attributes of devices, sensors, control systems, and other equipment. It provides a standardized way to represent and exchange detailed information about devices and systems. In the OPC UA information model, an instance refers to a specific object, device, or entity; it is a concrete representation in the model that contains the actual data of that object or device.

[0039] It's worth noting that by incorporating the `opcua / model / scan` request as part of a composite request, the system can scan multiple instances of the OPC UA information model simultaneously, significantly improving scanning efficiency and processing speed. The OPC UA information model provides standardized interfaces to describe the data structures of different devices and systems, while the `opcua / model / scan` request effectively extracts and scans these information model instances, helping the system quickly acquire relevant data. This reduces the need for multiple scans, saves time and computing resources through batch processing, and optimizes the data acquisition process. This is particularly important for industrial automation and equipment monitoring systems, as it enables rapid and accurate acquisition of real-time equipment data while reducing system load and network overhead, and improving the overall system's response speed and data processing capabilities.

[0040] S3: The MCP server responds to the model scan request, scans the model instances in the OPC UA address space, obtains the model information, and sends the model information to the MCP client.

[0041] The OPC UA address space is the core data structure in the OPC UA protocol, representing the semantic information model of the storage device. It includes variable nodes, method nodes, and the semantic and hierarchical relationships between nodes. Model information refers to the complete result returned after scanning, containing the IDs, attributes, methods, and semantic relationships of all nodes.

[0042] It's important to note that upon receiving a model scan request, the MCP server can directly perform a complete traversal of the OPC UA address space and return the model information to the client in one go. This approach ensures that the large model fully grasps the semantic information and hierarchical structure of the device, avoiding multiple interactions and latency caused by node-by-node queries. Simultaneously, the returned model information maintains the original semantics and hierarchical relationships of the OPC UA without additional encapsulation or secondary transformation, thus reducing the risk of semantic distortion. Through centralized scanning and return, the system significantly improves the efficiency of the large model's understanding of the device environment, providing a solid data foundation for subsequent request processing and decision-making, and enhancing the accuracy and response speed of the industrial intelligent agent in task execution.

[0043] S4: The MCP client sends the model information to the JSON processor.

[0044] The JSON processor is a module independent of the client protocol stack, responsible for shaping the OPC UA information model into a format that the larger model can understand.

[0045] It's important to note that the data returned by the server is processed step-by-step using a layered parsing mechanism: first, the OPCUA transport layer performs initial parsing of the data frame, then the JSON-RPC request service performs secondary parsing, ultimately resulting in a structured OPC UA information model. This layered design effectively reduces parsing complexity and improves system stability and maintainability. Furthermore, after receiving the parsing results, the service management layer can uniformly schedule and pass the results to the JSON processor, avoiding repeated information conversion between multiple services.

[0046] In one possible implementation, S4 specifically includes: S401: The MCP client receives the response result sent by the MCP server, wherein the response result includes data frames of the OPC UA information model.

[0047] The response result is the execution result returned by the MCP server, which is a data frame encapsulating the OPC UA information model. A data frame refers to a message unit encapsulated by the OPC UA transport layer, containing structured communication data.

[0048] S402: The data frame is parsed once through the OPC UA transport layer inside the MCP client, and the JSON-RPC message is extracted.

[0049] Among them, the OPC UA transport layer refers to the UA Binary and TCP / IP protocol layer integrated inside the MCP client, which is responsible for receiving and initially parsing data frames.

[0050] S403: The JSON-RPC message is parsed again through the JSON-RPC batch request service inside the MCP client, and the OPC UA information model is extracted as the response result.

[0051] S404: Sends the response to the service management layer inside the MCP client and sends the OPC UA information model to the JSON processor.

[0052] It's important to note that, firstly, the response received by the MCP client exists in the form of data frames. The OPC UA transport layer performs a single parsing, quickly extracting the JSON-RPC message and reducing the complexity of processing the original data. Subsequently, the JSON-RPC batch request service performs a second parsing, transforming the message into a semantically clear OPC UA information model, avoiding semantic loss or distortion. Finally, through unified scheduling by the service management layer and formatting by the JSON processor, it is ensured that the large model receives structured and organized complete model information. This design not only improves parsing efficiency and the clarity of module collaboration but also reduces redundant conversions in intermediate steps, enhancing system stability and scalability.

[0053] S5: Formats the model information using a JSON processor and sends the formatted results to the large model.

[0054] Formatting refers to the structural adjustment and semantic regularization of the original model information to ensure that its data format is consistent with the interaction interface of the large model.

[0055] It's worth noting that the formatting process of the JSON processor resolves the data mismatch issue between the OPC UA information model and the large-scale model's input interface. While the original OPC UA model information contains semantics and hierarchy, its complex structure can easily lead to parsing difficulties or semantic misinterpretations if directly transmitted to the large-scale model. The JSON processor transforms it into a JSON-compliant format easily understood by the large-scale model, preserving the semantic relationships between nodes and ensuring data consistency and readability. This allows the large-scale model to quickly understand the attributes and functions of industrial equipment, thereby making more accurate reasoning and control decisions.

[0056] S6: The user sends a request to the large model. Based on the request, it determines whether it needs to access a node in the OPC UA address space. If so, it generates a JSON message, extracts the user's request, sends the extraction result to the MCP client, and determines the request type. Otherwise, it directly responds.

[0057] In this context, "user" refers to the system operator who interacts with the large model through natural language. The large model refers to a Large Language Model (LLM) with natural language understanding, reasoning, and decision-making capabilities, serving as the system's intelligent core. The OPC UA address space is the core data structure in the OPC UA protocol, used to store the semantic information model of industrial equipment, including variable nodes, method nodes, and their hierarchical relationships.

[0058] Among them, JSON format messages refer to structured request data generated by the large model after analyzing user needs, which includes OPC UA service name and target node information, and conforms to the calling specifications of MCP clients.

[0059] The request type refers to the classification of user requests, including single requests and batch requests, which is used to determine the subsequent processing method.

[0060] It's important to note that users only need to express their requests in natural language, and the large-scale model can intelligently determine whether access to the OPC UA address space is required. If so, it generates a standardized JSON request message, clearly specifying the target node and the required operation. This step significantly reduces the complexity of user interaction with the industrial system, eliminating the need for knowledge of underlying protocols or node information. Simultaneously, the large-scale model can differentiate between single and batch requests based on their content, ensuring efficient and targeted subsequent processing. This design not only enhances the system's human-machine interface but also ensures the structured and scalable nature of requests, laying the foundation for rapid response and precise execution by industrial intelligent agents.

[0061] In one possible implementation, the user sends a request to the large model via natural language. The large model determines whether it needs to access a node in the OPC UA address space. If so, it generates a JSON message; otherwise, the large model makes inferences and decisions based on existing data or logic.

[0062] In one possible implementation, the JSON-formatted message includes the OPC UA service name and the target node information that needs to be accessed to use the OPC UA service.

[0063] In one possible implementation, the request types include: single request and batch request.

[0064] A single request is sent to the OPC UA standard request service for processing.

[0065] Batch requests are sent to the JSON-RPC batch request service for processing.

[0066] The request type refers to the different request methods selected based on requirements during communication. In this context, it is divided into single requests and batch requests, used to specify the data request method sent to the server.

[0067] A single request refers to a request that contains only a single operation or query. It is typically used in scenarios requiring immediate response, such as querying a single device or retrieving the status of a specific data point. This request is sent to the OPC UA standard request service for processing.

[0068] Batch requests refer to a request method that includes multiple operations or queries. It combines multiple requests into a single request, thereby reducing communication frequency and latency. Batch requests are sent to a JSON-RPC batch request service for processing.

[0069] The OPC UA standard request service is a service within the OPC UA protocol used to handle single requests, typically involving data access, operations, or status queries on specific nodes. The JSON-RPC batch request service is a service based on the JSON-RPC protocol used to handle batch operations of multiple requests, reducing the communication burden of multiple individual requests.

[0070] It's important to note that single requests are suitable for real-time requirements, quickly obtaining responses to individual operations and ensuring immediacy and accuracy. Batch requests, on the other hand, combine multiple requests into one, reducing network latency and server processing load, effectively improving system throughput and efficiency, and are particularly suitable for scenarios requiring multiple operations. This differentiated and selective request approach allows the system to flexibly adjust according to actual needs, handling both simple, immediate requests and complex batch tasks efficiently. Furthermore, by sending single requests to the OPC UA standard request service and batch requests to the JSON-RPC batch request service, the system's scalability and flexibility are further enhanced, ensuring that the system can quickly adapt and optimize processing under different operational requirements, reducing unnecessary communication and computational overhead.

[0071] S7: Based on the request type and session connection, process the user request using different processing methods, generate response information, and send the response information to the large model.

[0072] The request type refers to the category of access requests generated by the large model after analyzing user needs, including single requests (such as reading data from a single node) and batch requests (such as reading data from multiple nodes simultaneously or calling multiple methods). The processing method is to select different execution paths according to the request type: single requests use the OPC UA standard request service, while batch requests use the JSON-RPC batch request service.

[0073] The response information refers to the execution result returned by the MCP server after processing the user request, including node data, method call results, or status information.

[0074] It's worth noting that by combining request types with session connections, flexible processing and efficient execution of user requests are achieved. For single requests, the system can quickly generate OPC UA messages and respond directly, ensuring low latency. For batch requests, the parallel processing capabilities of JSON-RPC are leveraged to complete multiple operations at once, significantly improving efficiency. The existence of session connections ensures the security and consistency of request and response transmission, making the processing controllable and stable. Through this traffic distribution and adaptation mechanism, the system can balance the timeliness of single-point operations with the concurrency of large-scale operations, ensuring that the response information obtained by the large model is both complete and accurate.

[0075] In one possible implementation, when the request type is a single request, the processing method is as follows: The OPC UA standard request service generates an OPC UA message based on the content of a single request.

[0076] OPC UA messages refer to messages conforming to the OPC UA protocol format, used to transmit request and response data between clients and servers. They contain information related to devices, sensors, etc.

[0077] The OPC UA message is sent to the MCP server via the lower-level protocol stack.

[0078] In communication protocols, the lower-level protocol stack usually refers to the underlying protocol layer that handles data transmission. It is responsible for ensuring the transmission, encryption, and decryption of data during the process of sending data from the source to the destination.

[0079] The MCP server receives OPC UA messages and parses them.

[0080] The parsed OPC UA message is sent to the OPC UA standard response service.

[0081] Based on the parsed OPC UA message, perform operations on the specified node and generate an OPC UA response message.

[0082] The OPC UA response message is a response message generated based on the OPC UA request, containing the operation result or requested data.

[0083] The OPC UA response message is sent to the MCP client via the protocol stack.

[0084] The protocol stack refers to the multiple protocol layers for data transmission, ensuring that data can be successfully transmitted from the MCP server to the MCP client.

[0085] The OPC UA standard request service in the MCP client receives OPC UA response messages and extracts the response information from the OPC UA response messages.

[0086] The response information is sent to the service management layer of the MCP client.

[0087] The service management layer is a layer in the MCP server that is responsible for managing and scheduling service requests received by clients.

[0088] The service management layer of the MCP client sends the response message to the JSON processor, formats the response information, and feeds the formatted result back to the large model.

[0089] It's important to note that, firstly, standardized OPC UA messages are generated and sent via the OPC UA standard request service to ensure the accuracy and compatibility of the requests. Next, the MCP server processes the requests and executes operations through parsing and the OPC UA standard response service, ensuring correct responses. The protocol stack and the MCP client work together to ensure smooth data transmission between the client and server, reducing transmission latency and errors. Finally, the JSON processor formats the response information into the format required by large models, further enhancing the system's flexibility and adaptability, especially in scenarios requiring complex decision-making and reasoning. This process ensures accuracy at every stage while providing effective response formatting, enabling the system to process individual requests quickly and accurately, reducing unnecessary waste of computational resources, and improving response speed and system maintainability.

[0090] In one possible implementation, when the request type is a batch request, the processing method is as follows: The JSON-RPC bulk request service encapsulates multiple individual requests into a single JSON-RPC message.

[0091] The JSON-RPC message is sent to the MCP server via the lower-level protocol stack.

[0092] Receive JSON-RPC messages and parse them using the JSON-RPC batch processing service in the MCP server.

[0093] Based on the parsing results, multiple operation requests in the batch request are executed, and execution results are generated.

[0094] The execution result is encapsulated into a JSON-RPC response message and returned to the MCP client.

[0095] The JSON-RPC batch request service in the MCP client receives JSON-RPC response messages and extracts the response results from the JSON-RPC response messages.

[0096] The response result is sent to the service management layer of the MCP client.

[0097] The service management layer of the MCP client sends the response message to the JSON processor, performs normalization on the response result, and feeds the normalized result back to the large model.

[0098] It's worth noting that by using the JSON-RPC batch request service, multiple requests are encapsulated into a single message, reducing the frequency of sending and receiving, and improving system throughput and response speed. The batch processing service in the MCP server can efficiently parse and execute multiple operations, reducing server response time. When the execution results are returned, the MCP client extracts and transmits the response information, using a JSON processor to format the results, ensuring uniformity and making the data more suitable for further analysis and processing of large models. This method effectively improves the ability to handle a large number of concurrent requests, while simplifying the data flow process and optimizing the utilization of communication and computing resources. Ultimately, the system can handle a large number of complex operations more flexibly and efficiently, greatly improving the overall system performance, especially in high-load or large-scale data interaction scenarios.

[0099] S8: Update the context of the large model based on the response information. The large model then performs inference based on the updated context information and generates a response to send to the user.

[0100] Among them, the large model context refers to the "dialogue state and semantic memory" maintained by the large language model during the interaction process, which includes the user's historical requests, model scan results and information on the operations that have been performed. It is the knowledge background for the large model to perform reasoning.

[0101] It's important to note that by continuously injecting real-time response information from OPCUA into the semantic environment of the large model through a context update mechanism, the model can perform reasoning based on the latest state, rather than relying solely on static input. This ensures the continuity, accuracy, and scenario adaptability of the responses. Every user request and every system response is embedded in the context, allowing the large model to remember historical interactions, understand task progress, and dynamically adjust strategies in subsequent reasoning. Simultaneously, this context enhancement avoids redundant queries and information fragmentation, significantly improving efficiency and intelligence in multi-turn interaction scenarios.

[0102] Specifically, MCP can be viewed as a concrete implementation standard of a large model context interaction protocol.

[0103] In this application, JSON-RPC batch request service and OPC UA standard request service are added to the original MCP client. The service interface is uniformly provided to the outside world through the MCP service management layer. The MCP session management layer is retained, and the UA Binary protocol layer and TCP / IP protocol layer in the OPC UA protocol stack are integrated into the MCP client as a dedicated transport layer protocol stack for OPC UA model access services.

[0104] In this application, the MCP service management layer provides service interfaces to external systems. Currently, MCP supports services including tools / list and tools / call. To enable the MCP service management layer to directly call OPC UA functions, this application extends OPC UA-related services, specifically including opcua / var / read, opcua / var / write, opcua / method / call, and opcua / model / scan. Specifically, opcua / var / read is used to read data from OPC UA variable nodes; opcua / var / write is used to write data to OPC UA variable nodes; opcua / method / call is used to call OPC UA method nodes; and opcua / model / scan is used to scan OPC UA information model instances. OPC UA-related services allow both single and batch requests, and the request information should include the service name and request parameters. When the MCP service management layer receives a single request for `opcua / var / read`, `opcua / var / write`, or `opcua / method / call`, it forwards the request information to the OPC UA standard request service. When it receives a batch request (containing multiple single requests) or a `opcua / model / scan` request, it forwards the request to the JSON-RPC batch request service. After receiving the returned response information, the MCP service management layer returns it to the service requester.

[0105] The OPC UA standard request service is a standard function in OPC UA clients and is used in this application to handle single OPC UA service requests. Upon receiving a request from the MCP service management layer, an OPC UA message is generated based on the request information. For example, if the service request is `opcua / var / read` and the node ID is received, a message conforming to the OPC UA protocol specification is generated for reading data from the specified node in the OPC UA address space. The generated OPC UA message needs to be sent to the MCP session management layer, and the application waits to receive an OPC UA response message. After processing the response message, a service response is sent to the MCP service management layer. The response content should include the service name, service execution result, and return parameters.

[0106] The OPC UA protocol's request mechanism does not support batch requests. This application designs a JSON-RPC batch request service to handle multiple single service requests that need to be sent simultaneously, thereby improving request efficiency. The specific process is as follows: When a large model generates multiple OPC UA-related requests, this service leverages the batch request feature of JSON-RPC to encapsulate the multiple request information into JSON-RPC format data and send it to the MCP session management layer. After receiving the reply in JSON-RPC format data, it processes the reply and sends the service response information to the MCP service management layer. Furthermore, since scanning OPC UA information model instances cannot be completed with a single OPC UA request, the JSON-RPC batch request service is also used to handle opcua / model / scan service requests. It sends the opcua / model / scan service request information to the MCP server, and then the JSON-RPC batch processing service in the MCP server scans the specified OPC UA information model instance, encapsulates the scan results into JSON-RPC format data, and sends it back to the MCP client. The opcua / model / scan service will be executed immediately after the host establishes an MCP session. It sends the information model in the OPC UA address space to the large model, enabling it to obtain information about the currently accessible OPC UA nodes, as well as the semantic and hierarchical relationships between the nodes.

[0107] The MCP session management layer exists in both the MCP client and server, and is used to establish and maintain MCP sessions. The MCP session management layer establishes a session according to the session initialization procedures defined by MCP: the client session management layer sends a session initialization request "initialize". Upon receiving this, the server session management layer sends an initialization response, including the protocol version number and server name. Finally, the client session management layer sends an acknowledgment message "notifications / initialized", completing the session establishment process. After the session is established, it begins receiving and transmitting messages sent by upper-layer services.

[0108] This application adds an OPC UA address space, an OPC UA standard response service, and a JSON-RPC batch processing service to the original MCP server, retains the MCP session management layer, and integrates the UA Binary protocol layer and TCP / IP protocol layer in the OPC UA protocol stack into the MCP client as a dedicated transport layer protocol stack for OPC UA model access services.

[0109] The UA Binary protocol layer and TCP / IP protocol layer are the same as the protocol layers integrated in the MCP client, and are layers in the OPC UA standard protocol stack. The MCP session management layer is as described above, and works with the MCP session management of the MCP client to establish sessions and transmit messages.

[0110] The OPC UA standard response service is a standard function in the OPC UA server, used to receive OPC UA messages and perform operations based on the message content. For example, if a message is received requesting the reading of data from a specified node in the OPC UA address space, the node data is read from the data structure in the address space. After completing the operation, a response message is generated and sent back to the MCP client through the MCP session management layer and the lower protocol stack.

[0111] The JSON-RPC batch processing service receives and processes all requests within JSON-RPC messages. For multiple `opcua / var / read`, `opcua / var / write`, and `opcua / method / call` requests, the service parses the request content from each message, accesses the OPC UA address space to complete the request operation, and then encapsulates the execution results of all requests into a JSON-RPC message before sending it to the MCP session management layer. For `opcua / model / scan` requests, the service uses the model instance as the root node, traverses all child nodes layer by layer, and encapsulates the complete information model into a JSON-RPC message before sending it to the MCP session management layer. The information model should contain information about all nodes in the model, as well as the model's structural information, such as semantic relationships and hierarchical relationships between nodes.

[0112] The OPC UA address space is a data structure used in the OPC UA server to maintain the information model. This application integrates it into the MCP server, so that the MCP client can directly access the OPC UA address space information model by connecting to the MCP server.

[0113] In one specific embodiment, taking a visual sorting scenario as an example, the scenario includes a robotic arm and a machine vision device. The user inputs natural language requirements for sorting objects of a specific color into a large model. The large model makes decisions based on the user's requirements and then directly accesses the OPC UA information model of the robotic arm and machine vision module through the OPC UA-MCP fusion protocol stack. It calls the target detection function of the machine vision and the picking and placing function of the robotic arm as needed, and finally completes the visual sorting task.

[0114] Specifically, the execution process of a visual sorting scenario includes: The system consists of two parts: information collection and intelligent decision-making and execution.

[0115] Specifically, the system information acquisition process involves the following steps: After the host comes online, its built-in MCP client automatically establishes a session connection with the preset MCP server and actively sends opcua / model / scan requests to obtain the OPC UA information model integrated into the MCP server. The MCP client then hands the information model over to a JSON processor, processes it according to the data format defined by the large model, and transmits it to the large model. Through the semantically rich OPC UA information model, the large model accurately understands the attributes, capabilities, and other information of all industrial control devices in the system.

[0116] The intelligent decision-making and execution component includes task analysis, machine vision invocation, robotic arm control, and task closed-loop.

[0117] Task parsing refers to the process where, after the user inputs an instruction (such as "arrange all black objects in a row"), the large model makes a decision by calling the machine vision module to perform object detection, and then using a robotic arm to perform multiple pick-and-place operations to arrange the objects according to the user's requirements.

[0118] Machine vision calls refer to the large model sending a JSON-formatted OPC UA service request. The content is an opcua / method / call service request, and the parameters include the node ID of the object detection method in the machine vision module's information model. The JSON processor extracts the request and parameters and sends them to the MCP client. The client directly sends an opcua method call request to the MCP server, waits for the machine vision to execute the object detection method and return the detection result, and then sends the detection result back to the large model via the JSON processor.

[0119] The robotic arm control system, based on user requirements and object distribution, determines whether multiple calls to the robotic arm's pick-and-place methods are needed. Therefore, multiple `opcua / method / call` service requests are directly added to the JSON-formatted OPC UA service requests. The parameters include the node ID of the pick-and-place method, the current coordinates of the object, and its placement coordinates. The JSON processor extracts the requests and parameters and sends them to the MCP client. The client, receiving multiple OPC UA service requests simultaneously, encapsulates them into a JSON-RPC batch request message, which is then transmitted to the MCP server via the OPC UA protocol stack. The MCP server parses the request content from the JSON-RPC message and executes them one by one. It then returns the execution results to the MCP client via a JSON-RPC message, and finally sends them to the large model.

[0120] The task closure process refers to the large model integrating all historical messages to determine that the task has been completed and sending a completion notification to the user.

[0121] In specific embodiments, the large model can understand the system composition based on the device semantic information model, generate executable control decisions, and drive multiple devices to collaboratively complete tasks, ultimately achieving an end-to-end closed loop from natural language to industrial control.

[0122] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: In this embodiment of the invention, the OPC UA and MCP protocol stack are integrated and reconstructed. The original MCP services are extended by adding OPC UA standard request / standard response services and JSON-RPC batch request / response services to the protocol stack, and using some layers of the OPC UA protocol stack as the transport layer protocol for the MCP client / server. This enables large models to directly access semantic model information in the OPC UA address space on demand through the MCP client, simplifying protocol conversion between large models and devices, reducing intermediate steps, improving operational efficiency and real-time performance, breaking down the barriers between the IT and OT (Operational Technology) fields, promoting the integration of industrial automation and artificial intelligence, adapting to a wider range of industrial equipment and control systems, and possessing strong flexibility and scalability.

[0123] Reference manual attached Figure 5 The diagram shows a structural schematic of a large model context interaction system integrating OPC UA provided by the present invention.

[0124] This invention also provides a large model context interaction system 20 integrating OPC UA, applied to the aforementioned large model context interaction method integrating OPC UA, comprising: Processor 201.

[0125] The memory 202 stores computer-readable instructions that, when executed by the processor 201, implement the large model context interaction method with integrated OPC UA as described in the method embodiment.

[0126] The large model context interaction system 20 with integrated OPC UA provided by the present invention can execute the large model context interaction method with integrated OPC UA described above and achieve the same or similar technical effects. To avoid repetition, the present invention will not elaborate further.

[0127] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: In this embodiment of the invention, the OPC UA and MCP protocol stack are integrated and reconstructed. The original MCP services are extended by adding OPC UA standard request / standard response services and JSON-RPC batch request / response services to the protocol stack, and using some layers of the OPC UA protocol stack as the transport layer protocol for the MCP client / server. This enables large models to directly access semantic model information in the OPC UA address space on demand through the MCP client, simplifying protocol conversion between large models and devices, reducing intermediate steps, improving operational efficiency and real-time performance, breaking down the barriers between the IT and OT (Operational Technology) fields, promoting the integration of industrial automation and artificial intelligence, adapting to a wider range of industrial equipment and control systems, and possessing strong flexibility and scalability.

[0128] It should be understood that the processor in the embodiments of the present invention can be a central processing unit (CPU), or it can be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor can be a microprocessor or any conventional processor.

[0129] It should also be understood that the memory in the embodiments of the present invention can be volatile memory or non-volatile memory, or may include both volatile and non-volatile memory. The non-volatile memory can be read-only memory (ROM), programmable read-only memory (PROM), erasable programmable read-only memory (EPROM), electrically erasable programmable read-only memory (EEPROM), or flash memory. The volatile memory can be random access memory (RAM), which is used as an external cache. By way of example, but not limitation, many forms of random access memory (RAM) are available, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate synchronous DRAM (DDR SDRAM), enhanced synchronous DRAM (ESDRAM), synchronous linked DRAM (SLDRAM), and direct rambus RAM (DR RAM).

[0130] The above embodiments can be implemented, in whole or in part, by software, hardware (such as circuits), firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer programs are loaded or executed on a computer, all or part of the flow or function according to the embodiments of the present invention is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. Computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means. A computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more sets of available media. Available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media. Semiconductor media can be solid-state drives.

[0131] It should be understood that the term "and / or" in this article is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A existing alone, A and B existing simultaneously, or B existing alone. A and B can be singular or plural. Additionally, the character " / " in this article generally indicates an "or" relationship between the preceding and following related objects, but it can also represent an "and / or" relationship. Please refer to the context for a more accurate understanding.

[0132] In this invention, "at least one" means one or more, and "more than one" means two or more. "At least one of the following" or similar expressions refer to any combination of these items, including any combination of a single item or a plurality of items. For example, at least one of a, b, or c can represent: a, b, c, ab, ac, bc, or abc, where a, b, and c can be a single item or multiple items.

[0133] It should be understood that, in various embodiments of the present invention, the order of the above-mentioned process numbers does not imply the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.

[0134] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0135] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the devices, apparatuses, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0136] In the embodiments provided by this invention, it should be understood that the disclosed devices, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another device, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.

[0137] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0138] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0139] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0140] This invention provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the large model context interaction method integrating OPC UA as described in the method embodiment.

[0141] The present invention provides a computer-readable storage medium that can implement the steps and effects of the large model context interaction method of the integrated OPC UA in the above method embodiments. To avoid repetition, the present invention will not repeat them.

[0142] The beneficial effects of the technical solutions provided in the embodiments of the present invention include at least the following: In this embodiment of the invention, the OPC UA and MCP protocol stack are integrated and reconstructed. The original MCP services are extended by adding OPC UA standard request / standard response services and JSON-RPC batch request / response services to the protocol stack, and using some layers of the OPC UA protocol stack as the transport layer protocol for the MCP client / server. This enables large models to directly access semantic model information in the OPC UA address space on demand through the MCP client, simplifying protocol conversion between large models and devices, reducing intermediate steps, improving operational efficiency and real-time performance, breaking down the barriers between the IT and OT (Operational Technology) fields, promoting the integration of industrial automation and artificial intelligence, adapting to a wider range of industrial equipment and control systems, and possessing strong flexibility and scalability.

[0143] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

[0144] The following points need to be explained: (1) The accompanying drawings of the embodiments of the present invention only involve the structures involved in the embodiments of the present invention. Other structures can refer to the general design.

[0145] (2) For clarity, the thickness of layers or regions is enlarged or reduced in the drawings used to describe embodiments of the invention, i.e., these drawings are not drawn to scale. It is understood that when an element such as a layer, film, region or substrate is referred to as being “above” or “below” another element, the element may be “directly” located “above” or “below” the other element or there may be intermediate elements.

[0146] (3) Where there is no conflict, the embodiments of the present invention and the features in the embodiments can be combined with each other to obtain new embodiments.

[0147] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. The scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. An integrated OPC UA large model context interaction method, characterized in that, The method comprises the following steps: S1: an MCP client establishes a session connection with an MCP server; S2: based on the session connection, the MCP client sends a model scanning request to the MCP server; S3: the MCP server responds to the model scanning request, scans a model instance in an OPC UA address space, obtains model information, and sends the model information to the MCP client; S4: the MCP client sends the model information to a JSON processor; S5: the model information is formatted by the JSON processor, and the formatted result is sent to a large model; S6: a user sends a request to the large model, and determines whether a node in the OPC UA address space needs to be accessed according to the request; if yes, a JSON format message is generated, a user request is extracted, the extraction result is sent to the MCP client, and a request type is judged; otherwise, a direct answer is given; S7: according to the request type and the session connection, the user request is processed by different processing manners, response information is generated, and the response information is sent to the large model; S8: the context of the large model is updated according to the response information, the large model performs reasoning based on the updated context information, and a reply is sent to the user.

2. The integrated OPC UA macro model context interaction method according to claim 1, characterized in that, The S1 specifically comprises: The session connection is established by a session management layer of the MCP client and the MCP server.

3. The integrated OPC UA macro model context interaction method of claim 1, wherein, The S2 further comprises the following steps: The model scanning request is automatically sent to a JSON-RPC batch request service by a service management layer of the MCP client; A JSON-RPC message is generated according to the model scanning request; The JSON-RPC message is sent to an OPC UA transmission layer, and the JSON-RPC message is encapsulated as an OPC UA data frame and sent to the MCP server.

4. The integrated OPC UA macro model context interaction method of claim 3, wherein, The model scanning request is specifically an opcua / model / scan request; The opcua / model / scan request is used to scan an instance of the OPC UA model.

5. The integrated OPC UA macro model context interaction method of claim 1, wherein, The S4 specifically comprises the following steps: S401: the MCP client receives a response result sent by the MCP server, wherein the response result comprises an OPC UA information model data frame; S402: the data frame is parsed once by an OPC UA transmission layer inside the MCP client, and a JSON-RPC message is extracted; S403: the JSON-RPC message is parsed twice by a JSON-RPC batch request service inside the MCP client, and an OPC UA information model is extracted as the response result; S404: the response result is sent to a service management layer inside the MCP client, and the OPC UA information model is sent to the JSON processor.

6. The integrated OPC UA macro model context interaction method of claim 1, wherein, The content of the JSON format message specifically comprises: an OPC UA service name and target node information that needs to be accessed when using the OPC UA service.

7. The integrated OPC UA macro model context interaction method of claim 1, wherein, The request type includes: single request and batch request; The single request is used for sending to the OPC UA standard request service for processing; The batch request is used for sending to the JSON-RPC batch request service for processing.

8. The integrated OPC UA macro model context interaction method of claim 7, wherein, When the request type is a single request, the processing mode is specifically: The OPC UA standard request service generates an OPC UA message according to the content of the single request; The OPC UA message is sent to the MCP server through a lower protocol stack; The MCP server receives the OPC UA message and parses the OPC UA message; The parsed OPC UA message is sent to the OPC UA standard response service; According to the content of the parsed OPC UA message, an operation on a specified node is performed to generate an OPC UA response message; The OPC UA response message is sent to the MCP client through a protocol stack; The OPC UA standard request service in the MCP client receives the OPC UA response message and extracts response information of the OPC UA response message; The response information is sent to the service management layer of the MCP client; The service management layer of the MCP client sends the response message to the JSON processor, formats the response information, and feeds back the formatting result to the large model.

9. The integrated OPC UA macro model context interaction method of claim 7, wherein, When the request type is a batch request, the processing mode is specifically: The JSON-RPC batch request service encapsulates multiple individual requests into a JSON-RPC message; The JSON-RPC message is sent to the MCP server through a lower protocol stack; The JSON-RPC message is received and parsed by the JSON-RPC batch processing service in the MCP server; According to the parsing result, multiple operation requests in the batch request are executed to generate an execution result; The execution result is encapsulated into a JSON-RPC response message and returned to the MCP client; The JSON-RPC batch request service in the MCP client receives the JSON-RPC response message and extracts a response result in the JSON-RPC response message; The response result is sent to the service management layer of the MCP client; The service management layer of the MCP client sends the response message to the JSON processor, formats the response result, and feeds back the formatting result to the large model.

10. An integrated OPC UA large model context interaction system, characterized in that, It includes: A processor; A memory, the memory has computer readable instructions stored thereon, the computer readable instructions are executed by the processor to realize the integrated OPC UA large model context interaction method in any one of claims 1 to 9.