Model context protocol invocation method based on edge-cloud cooperation and related device
By generating rollbackable workflows using the cloud-based MCP-Client and utilizing WebSocket connections, the problem of uncontrollable task execution in cross-cloud-edge collaboration is solved, achieving task controllability and reliability, and improving the real-time nature and interactivity of task scheduling.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANG FEI ZHI NENG JI SHU YOU XIAN GONG SI
- Filing Date
- 2025-11-27
- Publication Date
- 2026-04-17
AI Technical Summary
Existing model context protocol invocation methods lack a single-step controllable execution mechanism in cross-cloud-edge collaboration scenarios, resulting in insufficient state consistency and fault tolerance. This leads to opaque, uncontrollable, and unreliable task execution processes, making it difficult to intervene and roll back in a timely manner when deviations occur during task execution.
A rollbackable workflow is generated using the cloud-based MCP-Client. Task steps are sequentially delivered step by step via WebSocket connection. If execution fails, the workflow reverts to a specified anchor point based on dependencies, dynamically replanning unexecuted steps. A rollbackable workflow data format is used for state synchronization and consistency verification.
It improves the controllability and reliability of task execution, reduces manual intervention and full retry overhead, supports cross-platform and multi-terminal edge-cloud collaboration, and enhances the real-time performance and interactivity of task scheduling.
Smart Images

Figure CN121239673B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of distributed system technology of cloud computing and edge computing, and in particular to a model context protocol invocation method and related apparatus based on edge-cloud collaboration. Background Technology
[0002] In recent years, the Model Context Protocol (MCP), as a general protocol for large models to assist in executing external tools and accessing external resources, has been applied in some intelligent agents and application platforms, providing a foundational capability for the interaction between artificial intelligence and the external environment. Existing MCP deployment and invocation models typically include local deployment and cloud deployment. In local deployment, both the MCP-Server and MCP-Client run in the user's local environment. In cloud deployment, the MCP-Server or MCP-Client runs in the cloud environment, interacting with local services through standard API interfaces or persistent connections. In complex cross-cloud-edge collaboration scenarios, regardless of whether it's local or cloud deployment, MCP invocation typically distributes a batch of task scripts at once, making it impossible to precisely control the step-by-step execution process of local tasks in the cloud. This not only prevents the cloud from dynamically adjusting subsequent execution plans based on intermediate execution results but also makes it difficult to intervene in a timely manner when deviations occur in task execution, limiting the flexibility and intelligence of task execution. Furthermore, if a step fails during local execution, manual intervention or a full task retrieval is required. This is not only inefficient and increases operational costs, but also fails to guarantee a safe and accurate rollback to a consistent state in task flows with complex dependencies. In a distributed environment with edge-cloud collaboration, factors such as network instability and heterogeneous devices can easily lead to a disconnect between the local execution state and the cloud-recorded state. Existing technologies lack a state consistency guarantee mechanism for MCP calls, and this state deviation can cause a series of problems such as incorrect execution results, duplicate task execution, or incomplete resource cleanup. Most existing MCP calls rely on HTTP short connections or simple API polling for communication. These communication modes are difficult to effectively maintain the context of task execution and cannot achieve low-latency, bidirectional, real-time instruction transmission and log feedback, thus limiting the real-time response capability and interactive experience of task scheduling. Summary of the Invention
[0003] This invention provides a model context protocol invocation method and related apparatus based on edge-cloud collaboration, which solves the defects of existing MCP invocation methods, such as lack of single-step controllable execution mechanism, difficulty in ensuring rollback workflow, insufficient state consistency and fault tolerance, and lack of real-time performance and context association of communication protocol, resulting in opaque, uncontrollable and low reliability of edge-cloud collaborative task execution process.
[0004] This invention provides a model context protocol invocation method based on edge-cloud collaboration, applicable to the cloud, including:
[0005] A rollback-capable workflow is generated through the cloud-based MCP-Client. The rollback-capable workflow describes the multiple execution steps of the task, the dependencies between the steps, and the rollback conditions in a structured data format.
[0006] The WebSocket connection established with the user terminal sends multiple execution steps in the rollback workflow sequentially to the user terminal.
[0007] The system receives the execution result of each execution step returned by the user terminal. If the execution result is an execution failure, it rolls back to the specified rollback anchor point according to the dependencies and rollback conditions between the steps in the rollback workflow, and dynamically replans the unexecuted steps based on the current state.
[0008] According to the edge-cloud collaborative model context protocol invocation method provided by the present invention, the step of generating a rollbackable workflow through the cloud-based MCP-Client includes:
[0009] Parse the task request, model context protocol configuration file, and executable file uploaded by the user terminal;
[0010] Based on the parsed task logic and dependencies, a workflow graph with nodes as the basic unit is constructed.
[0011] Each node in the workflow graph is assigned specific node attributes, which include at least: task identifier, execution parameters, status information, a list of preceding nodes, a list of succeeding nodes, and a rollback flag.
[0012] According to the edge-cloud collaborative model context protocol invocation method provided by the present invention, the construction of a workflow graph with nodes as basic units includes:
[0013] Identify the function definitions and function call relationships in the executable file;
[0014] Based on the model context protocol configuration file, determine the list of available tools and the input / output dependencies between the tools;
[0015] Based on the calling relationships between the functions and the input / output dependencies between the tools, task nodes are created, and directed edge connections are established between nodes according to the data flow and control flow to generate a workflow graph with nodes as the basic unit.
[0016] According to the edge-cloud collaborative model context protocol invocation method provided by the present invention, the step of reverting to a specified rollback anchor point based on the dependencies and rollback conditions between steps in the rollbackable workflow includes:
[0017] Identify the currently failed task node;
[0018] Based on the dependencies between steps in the rollback workflow, the list of predecessor nodes of the failed task node is traversed in reverse until the first rollback anchor node marked as rollback is located.
[0019] Starting from the rollback anchor node, along the workflow execution direction, the system's logical state and data state are rolled back to the state when the rollback anchor node was completed.
[0020] According to the edge-cloud collaborative model context protocol invocation method provided by the present invention, the dynamic replanning of unexecuted steps based on the current state includes:
[0021] Obtain the status information of the current rollback anchor node, task execution history logs, and environment variables;
[0022] Analyze the dependencies between unexecuted task nodes and failed task nodes, and identify subsequent nodes that cannot continue execution due to the failure of failed task nodes;
[0023] Based on the analysis results of the dependencies, the state information, and the environment variables, the original rollback workflow is structurally optimized. A new task execution sequence is generated based on the optimized workflow structure, and the tasks in the task execution sequence are executed starting from the rollback anchor node.
[0024] According to the edge-cloud collaborative model context protocol invocation method provided by the present invention, the structural optimization of the original rollable workflow includes: removing unexecutable task nodes, replacing them with a backup equivalent task node sequence, and adjusting at least one of the following: the execution order or parameters of the task nodes.
[0025] The model context protocol invocation method based on edge-cloud collaboration provided by the present invention further includes:
[0026] The consistency of the status information in the rollback workflow with the actual execution status of the user terminal is verified.
[0027] If the consistency check fails, the entire task process is terminated.
[0028] This invention also provides a model context protocol invocation system based on edge-cloud collaboration, comprising:
[0029] The user terminal is used to execute task steps locally and connect to the cloud MCP-Client via WebSocket to interact with the cloud MCP-Client for data exchange.
[0030] The cloud-based MCP-Client communicates with the user terminal and is configured as follows:
[0031] Receive task requests and generate rollbackable workflows;
[0032] Multiple execution steps in the rollbackable workflow are sequentially and step-by-step sent to the user terminal via a WebSocket connection.
[0033] The system receives the execution result from the user terminal and, if execution fails, rolls back to the specified rollback anchor point based on the dependencies and rollback conditions between steps in the rollback workflow, and dynamically replans the unexecuted steps based on the current state.
[0034] The present invention also provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the program to implement the model context protocol invocation method based on edge-cloud collaboration as described in any of the preceding claims.
[0035] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the model context protocol invocation method based on edge-cloud collaboration as described above.
[0036] The present invention provides a model context protocol invocation method and related apparatus based on edge-cloud collaboration. It generates a rollable workflow through a cloud-based MCP-Client. This rollable workflow describes multiple execution steps of a task, the dependencies between steps, and rollback conditions in a structured data format. A WebSocket connection is established with the user terminal to sequentially send the multiple execution steps of the rollable workflow to the user terminal one step at a time. The system receives the execution result of each execution step returned by the user terminal. If the execution result indicates failure, it rolls back to a specified rollback anchor based on the dependencies between steps and the rollback conditions in the rollable workflow. This invention identifies key points and dynamically replans unexecuted steps based on the current state. By breaking down tasks into independently executable steps and distributing them step by step, the cloud can dynamically adjust subsequent execution plans based on intermediate results. Utilizing a rollback-enabled workflow data format, it can automatically revert to a safe state when a step fails, reducing the overhead of manual intervention and full retries. Edge and cloud synchronization is achieved based on a unified workflow data format, avoiding execution deviations and data inconsistencies. WebSocket is used to ensure low-latency instruction transmission and log feedback, improving the real-time performance and interactivity of task scheduling. It can be combined with various task types, supporting cross-platform and multi-terminal edge-cloud collaboration scenarios. Attached Figure Description
[0037] To more clearly illustrate the technical solutions in this invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of this invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0038] Figure 1 This is a flowchart of the model context protocol invocation method based on edge-cloud collaboration provided in an embodiment of the present invention;
[0039] Figure 2 This is a technical architecture diagram of the model context protocol call based on edge-cloud collaboration provided in this embodiment of the invention;
[0040] Figure 3 This is a schematic diagram of the functional structure of the model context protocol invocation system based on edge-cloud collaboration provided in an embodiment of the present invention;
[0041] Figure 4 This is a functional structure diagram of the electronic device provided in an embodiment of the present invention. Detailed Implementation
[0042] To make the objectives, technical solutions, and advantages of this invention clearer, the technical solutions of this invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without creative effort are within the scope of protection of this invention.
[0043] Figure 1 A flowchart of the model context protocol invocation method based on edge-cloud collaboration provided in this embodiment of the invention is shown below. Figure 1 As shown, the model context protocol invocation method based on edge-cloud collaboration provided in this embodiment of the invention includes:
[0044] Step 101: Generate a rollbackable workflow through the cloud-based MCP-Client. The rollbackable workflow describes the multiple execution steps of the task, the dependencies between the steps, and the rollback conditions in a structured data format.
[0045] Step 102: Establish a WebSocket connection with the user terminal and sequentially send multiple execution steps in the rollback workflow to the user terminal one step at a time.
[0046] Step 103: Receive the execution result of each execution step returned by the user terminal. If the execution result is an execution failure, roll back to the specified rollback anchor point according to the dependency relationship and rollback conditions between steps in the rollback workflow, and dynamically replan the unexecuted steps based on the current state.
[0047] In traditional cross-cloud-edge collaboration scenarios, regardless of whether the deployment mode is local or cloud-based, MCP calls typically distribute a batch of task scripts at once, making it impossible to precisely control the step-by-step execution process of local tasks in the cloud. This not only prevents the cloud from dynamically adjusting subsequent execution plans based on intermediate execution results, but also makes it difficult to intervene in a timely manner when task execution deviates, limiting the flexibility and intelligence of task execution. Furthermore, if a step fails during local execution, manual intervention or a full task retry is required, which is not only inefficient and increases operational costs, but also fails to guarantee a safe and accurate rollback to a consistent state in a task flow with complex dependencies. In the distributed environment of edge-cloud collaboration, factors such as network instability and heterogeneous devices can easily cause the local execution state to be out of sync with the state recorded in the cloud. Existing technologies have not established a state consistency guarantee mechanism for MCP calls, and this state deviation may lead to a series of problems such as incorrect execution results, duplicate task execution, or incomplete resource cleanup. Most existing MCP calls rely on HTTP short connections or simple API polling methods for communication. This type of communication mode is difficult to maintain the context of task execution effectively, and cannot achieve low-latency, bidirectional real-time instruction transmission and log feedback, thus restricting the real-time response capability and interactive experience of task scheduling.
[0048] The edge-cloud collaborative model context protocol invocation method provided in this invention generates a rollable workflow through a cloud-based MCP-Client. This rollable workflow describes multiple execution steps of a task, the dependencies between steps, and rollback conditions in a structured data format. A WebSocket connection is established with the user terminal to sequentially send the multiple execution steps of the rollable workflow to the user terminal one step at a time. The method receives the execution result of each execution step returned by the user terminal. If the execution result indicates failure, the method rolls back to a specified rollback anchor point based on the dependencies between steps and the rollback conditions in the rollable workflow. Based on the current state, the unexecuted steps are dynamically replanned. This embodiment of the invention breaks down tasks into independently executable steps and distributes them step by step. The cloud can dynamically adjust the subsequent execution plan based on intermediate results. With the help of a rollback-enabled workflow data format, it can automatically roll back to a safe state when a step fails, reducing the overhead of manual intervention and full retries. The edge and cloud sides synchronize their states based on a unified workflow data format, avoiding execution deviations and data inconsistencies. WebSocket is used to ensure low-latency instruction transmission and log feedback, improving the real-time performance and interactivity of task scheduling. It can be combined with various task types to support cross-platform and multi-terminal edge-cloud collaboration scenarios.
[0049] Based on any of the above embodiments, the generation of a rollbackable workflow via the cloud-based MCP-Client includes:
[0050] Step 201: Parse the task request, model context protocol configuration file, and executable file uploaded by the user terminal;
[0051] Step 202: Based on the parsed task logic and dependencies, construct a workflow graph with nodes as the basic unit;
[0052] Step 203: Assign specific node attributes to each node in the workflow diagram. The node attributes include at least: task identifier, execution parameters, status information, a list of preceding nodes, a list of succeeding nodes, and a rollback flag.
[0053] This invention provides an embodiment that centrally manages task workflows through a cloud-based MCP-Client and describes the execution process using a rollback-capable Workflow Data Type, thereby improving the controllability and reliability of execution in a cross-cloud-edge environment. Its technical architecture is as follows: Figure 2 As shown. The static structural relationships in the architecture include:
[0054] (1) User terminal equipment: executes actual Python scripts or local tasks and is responsible for feeding back the execution results and logs to the cloud in real time.
[0055] (2) Cloud MCP-Client: responsible for receiving task requests, generating rollback workflows, issuing single-step instructions, collecting results, and performing failure rollback and replanning.
[0056] (3) Communication channel (WebSocket): used for low-latency bidirectional data transmission between the cloud and the user terminal, supporting real-time task control and status synchronization.
[0057] (4) Rollbackable Workflow Data Format: Used to uniformly describe task steps, dependencies, rollback conditions, and execution status. This format uses nodes as the basic unit, with each node containing a task identifier, execution parameters, status information, a list of related tasks, and a rollback flag. When a task fails, the cloud can quickly locate the nearest rollback anchor node based on this data format, undo the executed steps, and replan the subsequent execution path, thereby achieving single-step controllability, rollback capability, and consistent status in task orchestration. This data format can be stored in the cloud or transmitted to the terminal via the network, and is lightweight, serializable, and cross-platform applicable.
[0058] The rollbackable workflow provided in this embodiment of the invention specifically includes the following steps:
[0059] (1) Task request and file transfer: The user terminal connects via WebSocket and packages the user request task, MCP configuration file and Python executable file and sends them to the cloud MCP-Client.
[0060] (2) Cloud-based workflow generation: The cloud-based MCP-Client parses the received task information and, in conjunction with the configuration file and executable file, automatically generates the task execution workflow. The workflow is stored and described in a rollback-enabled workflow data format to ensure that the execution dependencies, rollback conditions, and status flags of each step are accurately recorded.
[0061] (3) Single-step instruction issuance and execution: The cloud-based MCP-Client sends single-step task instructions to the user terminal for execution via WebSocket. Only one task step is issued at a time, and the system waits for the user terminal to return the execution result and log.
[0062] (4) Failure rollback and workflow replanning: If the user terminal executes successfully, the cloud continues to issue the next instruction; if the execution fails, the cloud rolls back to the previous executable state according to the rollback workflow data format, and dynamically replans the remaining task steps in combination with the latest log information.
[0063] (5) Consistency guarantee: The cloud-based MCP-Client records the status information based on the rollback workflow data format, and performs synchronous verification of the edge cloud status during task execution to ensure that the cloud record is consistent with the local execution status.
[0064] In this embodiment of the invention, the construction of a workflow graph with nodes as basic units includes:
[0065] Step 301: Identify the function definitions and function call relationships in the executable file;
[0066] Step 302: Determine the list of available tools and the input / output dependencies between tools based on the model context protocol configuration file;
[0067] Step 303: Based on the calling relationships between the functions and the input / output dependencies between the tools, create task nodes and establish directed edge connections between nodes according to the data flow and control flow to generate a workflow graph with nodes as the basic unit.
[0068] Based on any of the above embodiments, the step of reverting to a specified rollback anchor point according to the dependencies and rollback conditions between steps in the rollbackable workflow includes:
[0069] Step 401: Identify the currently failed task nodes;
[0070] Step 402: Based on the dependencies between steps in the rollback workflow, traverse the list of predecessor nodes of the failed task node in reverse until the first rollback anchor node marked as rollback is located.
[0071] Step 403: Starting from the rollback anchor node, roll back the system's logical state and data state to the state when the rollback anchor node was completed, along the workflow execution direction.
[0072] Based on any of the above embodiments, the dynamic replanning of unexecuted steps based on the current state includes:
[0073] Step 501: Obtain the status information of the current rollback anchor node, task execution history logs, and environment variables;
[0074] Step 502: Analyze the dependencies between unexecuted task nodes and failed task nodes, and identify subsequent nodes that cannot continue execution due to the failure of failed task nodes;
[0075] Step 503: Based on the analysis results of the dependency relationship, the state information and the environment variables, optimize the original rollback workflow structure, generate a new task execution sequence based on the optimized workflow structure, and start executing the tasks in the task execution sequence from the rollback anchor node.
[0076] In this embodiment of the invention, the structural optimization of the original rollback workflow includes: removing unexecutable task nodes, replacing them with a backup equivalent sequence of task nodes, and adjusting at least one of the following: the execution order or parameters of the task nodes.
[0077] Based on any of the above embodiments, the model context protocol invocation method based on edge-cloud collaboration further includes:
[0078] Step 601: Verify the consistency between the status information in the rollback workflow and the actual execution status of the user terminal;
[0079] Step 602: If the consistency check fails, terminate the entire task process.
[0080] Based on any of the above embodiments, the model context protocol invocation method based on edge-cloud collaboration provided by the present invention includes:
[0081] (1) Task request sending: The user terminal connects via WebSocket and packages the user request task, MCP configuration file and Python executable file and sends them to the cloud MCP-Client.
[0082] (2) Cloud workflow generation: The cloud MCP-Client parses the received tasks, combines the configuration file and the execution file to generate an execution workflow containing multiple task nodes, and uses a rollback workflow data format to store node information, including task identifier, execution parameters, status information, previous and subsequent dependencies and rollback flags.
[0083] (3) Single-step instruction issuance: The cloud-based MCP-Client sends the execution instructions of a single task node to the user terminal via WebSocket. The user terminal executes the corresponding task locally and returns the execution status and logs.
[0084] (4) Failure rollback and workflow replanning: When the user terminal returns execution failure information, the cloud MCP-Client quickly locates the nearest rollback anchor task node according to the rollback workflow data format, cancels the relevant executed tasks, and dynamically replans the subsequent workflow based on the latest status information.
[0085] (5) Consistency verification and completion: During the task execution process, the cloud-based MCP-Client continuously verifies the consistency between the task status recorded in the cloud and the actual execution status of the user terminal to ensure the correctness and traceability of the task execution results.
[0086] This invention differs from existing technologies that batch-deploy task scripts. It employs a single-step task instruction deployment mechanism, enabling the cloud to dynamically adjust the execution plan based on real-time feedback. A rollback-capable workflow data format is introduced, allowing automatic reverting to the nearest rollback anchor point and replanning the execution path in case of task failure, improving fault tolerance and continuity. State synchronization between the cloud and user terminals based on a unified workflow data format avoids state discrepancies during cross-cloud-edge collaboration. WebSocket is used to maintain low-latency interaction between the cloud and user terminals, supporting real-time transmission of execution status, logs, and control commands, enhancing the flexibility and response speed of task scheduling.
[0087] The edge-cloud collaborative model context protocol invocation method provided in this invention uses a cloud-based MCP-Client to remotely issue commands and return results to the user terminal's local execution environment. Combined with WebSocket-based bidirectional communication and a rollback-enabled workflow data format, it enables single-step execution of tasks across cloud and edge environments, failure rollback, and consistency assurance. Its application scenarios include, but are not limited to, automated operation and maintenance, software construction and deployment, data processing pipelines, and intelligent agent tool invocation—domains requiring controlled access and reliable orchestration of local resources.
[0088] Figure 3This is a schematic diagram of the structure of the edge-cloud collaborative model context protocol invocation system provided in an embodiment of the present invention, as shown below. Figure 3 As shown, the model context protocol invocation system based on edge-cloud collaboration provided in this embodiment of the invention includes:
[0089] The user terminal is used to execute task steps locally and connect to the cloud MCP-Client via WebSocket to interact with the cloud MCP-Client for data exchange.
[0090] The cloud-based MCP-Client communicates with the user terminal and is configured as follows:
[0091] Receive task requests and generate rollbackable workflows;
[0092] Multiple execution steps in the rollbackable workflow are sequentially and step-by-step sent to the user terminal via a WebSocket connection.
[0093] The system receives the execution result from the user terminal and, if execution fails, rolls back to the specified rollback anchor point based on the dependencies and rollback conditions between steps in the rollback workflow, and dynamically replans the unexecuted steps based on the current state.
[0094] The edge-cloud collaborative model context protocol invocation system provided in this invention generates a rollbackable workflow through a cloud-based MCP-Client. This rollbackable workflow describes multiple execution steps of a task, the dependencies between steps, and rollback conditions in a structured data format. A WebSocket connection is established with the user terminal to sequentially send the multiple execution steps of the rollbackable workflow to the user terminal one step at a time. The system receives the execution result of each execution step returned by the user terminal. If the execution result indicates failure, it rolls back to a specified rollback anchor point based on the dependencies between steps and the rollback conditions in the rollbackable workflow. Based on the current state, the unexecuted steps are dynamically replanned. This embodiment of the invention breaks down tasks into independently executable steps and distributes them step by step. The cloud can dynamically adjust the subsequent execution plan based on intermediate results. With the help of a rollback-enabled workflow data format, it can automatically roll back to a safe state when a step fails, reducing the overhead of manual intervention and full retries. The edge and cloud sides synchronize their states based on a unified workflow data format, avoiding execution deviations and data inconsistencies. WebSocket is used to ensure low-latency instruction transmission and log feedback, improving the real-time performance and interactivity of task scheduling. It can be combined with various task types to support cross-platform and multi-terminal edge-cloud collaboration scenarios.
[0095] Figure 4 An example is a schematic diagram of the physical structure of an electronic device, such as... Figure 4As shown, the electronic device may include: a processor 410, a communication interface 420, a memory 430, and a communication bus 440, wherein the processor 410, the communication interface 420, and the memory 430 communicate with each other through the communication bus 440. The memory 430 includes computer programs, an operating system, and acquired data. The processor 410 can call logical instructions in the memory 430 to execute a model context protocol invocation method based on edge-cloud collaboration. This method includes: generating a rollback workflow through a cloud-based MCP-Client, wherein the rollback workflow describes multiple execution steps of a task, dependencies between steps, and rollback conditions in a structured data format; establishing a WebSocket connection with a user terminal to sequentially send multiple execution steps in the rollback workflow to the user terminal; receiving the execution result of each execution step returned by the user terminal; if the execution result is an execution failure, rolling back to a specified rollback anchor point according to the dependencies between steps and rollback conditions in the rollback workflow, and dynamically replanning the unexecuted steps based on the current state.
[0096] Furthermore, the logical instructions in the aforementioned memory 430 can be implemented as software functional units and, when sold or used as independent products, can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to related technologies, or a portion 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 described in the various embodiments of the present 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.
[0097] On the other hand, the present invention also provides a non-transitory computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the model context protocol invocation method based on edge-cloud collaboration provided by the above methods. The method includes: generating a rollback workflow through a cloud-based MCP-Client, wherein the rollback workflow describes multiple execution steps of a task, dependencies between steps, and rollback conditions in a structured data format; establishing a WebSocket connection with a user terminal to sequentially send the multiple execution steps in the rollback workflow to the user terminal one step at a time; receiving the execution result of each execution step returned by the user terminal; if the execution result is an execution failure, rolling back to a specified rollback anchor point according to the dependencies between steps and the rollback conditions in the rollback workflow, and dynamically replanning the unexecuted steps based on the current state.
[0098] The system embodiments described above are merely illustrative. 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 modules can be selected to achieve the purpose of this embodiment according to actual needs. Those skilled in the art can understand and implement this without any creative effort.
[0099] Through the above description of the embodiments, those skilled in the art can clearly understand that each embodiment can be implemented by means of software plus necessary general-purpose hardware platforms, and of course, it can also be implemented by hardware. Based on this understanding, the above technical solutions, in essence or the parts that contribute to the related technology, can be embodied in the form of software products. This computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, magnetic disk, optical disk, etc., and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute the methods described in the various embodiments or some parts of the embodiments.
[0100] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A model context protocol invocation method based on edge-cloud collaboration, characterized in that, Available in the cloud, including: A rollback-capable workflow is generated through the cloud-based MCP-Client. The rollback-capable workflow describes the multiple execution steps of the task, the dependencies between the steps, and the rollback conditions in a structured data format. The process of generating a rollbackable workflow via the cloud-based MCP-Client includes: parsing the task request, model context protocol configuration file, and executable file uploaded by the user terminal; constructing a workflow graph with nodes as the basic unit based on the parsed task logic and dependencies; and assigning specific node attributes to each node in the workflow graph, wherein the node attributes include at least: task identifier, execution parameters, status information, a list of preceding nodes, a list of succeeding nodes, and a rollback flag. The WebSocket connection established with the user terminal sends multiple execution steps in the rollback workflow sequentially to the user terminal. Receive the execution result of each execution step returned by the user terminal. If the execution result is an execution failure, roll back to the specified rollback anchor point according to the dependency relationship and rollback condition between the steps in the rollback workflow, and dynamically replan the unexecuted steps based on the current state. The dynamic replanning of unexecuted steps based on the current state includes: Obtain the status information of the current rollback anchor node, task execution history logs, and environment variables; Analyze the dependencies between unexecuted task nodes and failed task nodes, and identify subsequent nodes that cannot continue execution due to the failure of failed task nodes; Based on the analysis results of the dependencies, the state information, and the environment variables, the original rollback workflow is structurally optimized. A new task execution sequence is generated based on the optimized workflow structure, and the tasks in the task execution sequence are executed starting from the rollback anchor node.
2. The model context protocol invocation method based on edge-cloud collaboration according to claim 1, characterized in that, The construction of a workflow graph with nodes as the basic unit includes: Identify the function definitions and function call relationships in the executable file; Based on the model context protocol configuration file, determine the list of available tools and the input / output dependencies between the tools; Based on the calling relationships between the functions and the input-output dependencies between the tools, task nodes are created, and directed edge connections are established between nodes according to the data flow and control flow to generate a workflow graph with nodes as the basic unit.
3. The model context protocol invocation method based on edge-cloud collaboration according to claim 1, characterized in that, The step of reverting to a specified rollback anchor point based on the dependencies and rollback conditions between steps in the rollback workflow includes: Identify the currently failed task node; Based on the dependencies between steps in the rollback workflow, the list of predecessor nodes of the failed task node is traversed in reverse until the first rollback anchor node marked as rollback is located. Starting from the rollback anchor node, along the workflow execution direction, the system's logical state and data state are rolled back to the state when the rollback anchor node was completed.
4. The model context protocol invocation method based on edge-cloud collaboration according to claim 1, characterized in that, The structural optimization of the original rollback workflow includes at least one of the following: removing unexecutable task nodes, replacing them with an equivalent sequence of backup task nodes, and adjusting the execution order or parameters of the task nodes.
5. The model context protocol invocation method based on edge-cloud collaboration according to claim 1, characterized in that, Also includes: The consistency of the status information in the rollback workflow with the actual execution status of the user terminal is verified. If the consistency check fails, the entire task process is terminated.
6. A model context protocol invocation system based on edge-cloud collaboration, characterized in that, include: The user terminal is used to execute task steps locally and connect to the cloud MCP-Client via WebSocket to interact with the cloud MCP-Client for data exchange. The cloud-based MCP-Client communicates with the user terminal and is configured as follows: Receive a task request and generate a rollback workflow; the rollback workflow describes the multiple execution steps of the task, the dependencies between the steps, and the rollback conditions in a structured data format. The process of generating a rollbackable workflow includes: parsing the task request, model context protocol configuration file, and executable file uploaded by the user terminal; constructing a workflow graph with nodes as the basic unit based on the parsed task logic and dependencies; and assigning specific node attributes to each node in the workflow graph, wherein the node attributes include at least: task identifier, execution parameters, status information, a list of preceding nodes, a list of succeeding nodes, and a rollback flag. Multiple execution steps in the rollbackable workflow are sequentially and step-by-step sent to the user terminal via a WebSocket connection. Receive the execution result fed back by the user terminal, and when the execution fails, roll back to the specified rollback anchor point according to the dependency relationship and rollback condition between the steps in the rollback workflow, and dynamically replan the unexecuted steps based on the current state; The dynamic replanning of unexecuted steps based on the current state includes: Obtain the status information of the current rollback anchor node, task execution history logs, and environment variables; Analyze the dependencies between unexecuted task nodes and failed task nodes, and identify subsequent nodes that cannot continue execution due to the failure of failed task nodes; Based on the analysis results of the dependencies, the state information, and the environment variables, the original rollback workflow is structurally optimized. A new task execution sequence is generated based on the optimized workflow structure, and the tasks in the task execution sequence are executed starting from the rollback anchor node.
7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the program, it implements the model context protocol invocation method based on edge-cloud collaboration as described in any one of claims 1 to 5.
8. A non-transitory readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the model context protocol invocation method based on edge-cloud collaboration as described in any one of claims 1 to 5.
Citation Information
Patent Citations
Transaction processing method and device, terminal equipment and storage medium
CN117608767A
Method and system for intelligent capacity planning in hybrid cloud environment
CN120353610A