Intelligent DevOps task arrangement and execution method and system based on MCP

By combining the MCP protocol and a large language model, intelligent orchestration and execution of DevOps tasks are achieved, solving the problems of low efficiency in cross-system operations and difficulty in tool integration, and improving the reliability and scalability of automated processes.

CN121434401APending Publication Date: 2026-01-30SHANDONG INSPUR SCI RES INST CO LTD

Patent Information

Application Number
CN202511552210.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-28
Publication Date
2026-01-30

AI Technical Summary

Technical Problem

In existing DevOps technologies, cross-system operations are inefficient and prone to errors. Furthermore, large language models and heterogeneous DevOps tools lack a unified, secure, and controllable integration standard, making it difficult to automate complex end-to-end tasks and monitor the entire process.

Method used

The MCP protocol is used to connect the client to the server of multiple DevOps functional modules. A large language model is integrated, and task decomposition and tool orchestration are performed through natural language commands to generate structured call plans. Real-time monitoring and rollback operations are also performed to achieve cross-tool coordination and invocation.

Benefits of technology

It improves the automation efficiency and reliability of DevOps tasks, lowers the professional threshold for operation and maintenance, avoids human error, and achieves seamless cross-platform operation and system resilience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121434401A_ABST
    Figure CN121434401A_ABST
Patent Text Reader

Abstract

The invention relates to the field of DevOps intelligent execution, in particular to an MCP-based DevOps task intelligent arrangement and execution method and system, and the method comprises the steps: obtaining a tool function of each MCP server to form a global tool library; receiving a natural language task instruction of a user, and inputting the natural language task instruction into the large language model; performing task decomposition on the natural language task instruction to generate a structured tool calling plan; the client side executes the structured tool calling plan and calls target tool functions on the corresponding MCP server in sequence or in parallel through the MCP according to the execution logic and the dependency relationship; monitoring execution of each tool function, determining a subsequent process or triggering a preset rollback operation according to an execution state, and feeding back a final execution result to the large language model; and generating a natural language abstract containing the overall task execution state based on the execution result, and outputting the natural language abstract to a user. And cross-environment seamless operation automation is realized.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the field of DevOps intelligent execution, in particular to a DevOps task intelligent scheduling and execution method and system based on MCP. BACKGROUND

[0002] In today's enterprise software development and operation practice, the complexity of system architecture and the scale of services are growing exponentially. To cope with the dual challenges of rapid iteration and high reliability, the DevOps culture emphasizes the deep integration of development and operation, relying on continuous integration / continuous deployment (CI / CD) and other automated processes to improve delivery efficiency. However, in actual implementation, the mainstream implementation scheme still has limitations.

[0003] Firstly, from code version management, pipeline construction, container orchestration to infrastructure management, each link has independent automation tools, but cross-system operations require operations personnel to switch between different consoles and write and maintain a large number of scripts, API call codes or configuration files. This way not only is inefficient, but also is prone to configuration errors or operation mistakes due to human negligence. In complex end-to-end processes, the error rate is high and the cost of troubleshooting is high. Secondly, with the breakthrough of large language model (LLM) technology, a new paradigm of simplifying operations using natural language interaction has emerged. However, there is a lack of unified, secure and controllable integration standard between the large language model and the numerous heterogeneous DevOps tools in the back end. Existing solutions are mostly point-to-point custom development, resulting in tight coupling between the model and the tool, poor scalability.

[0004] In this context, Model Context Protocol (MCP) as a new emerging open standard provides a standardized interface for LLM and external tool resource calls. Its potential lies in the hope of connecting the planning and reasoning capabilities of the model with the vast tool ecosystem in the DevOps field safely. However, the application of MCP protocol is still in its early stages, how to deeply integrate it with the specific needs of the DevOps field, design a set of intelligent systems that can understand complex end-to-end tasks, automatically perform task decomposition and tool scheduling, and have full-process monitoring and self-healing capabilities, is still a technical problem. SUMMARY

[0005] To solve the above problems, the present application provides a DevOps task intelligent scheduling and execution method and system based on MCP.

[0006] In a first aspect, the present application provides a DevOps task intelligent scheduling and execution method based on MCP, comprising: S1. Establish connections between the client and multiple MCP servers corresponding to different DevOps functional modules, and obtain the utility functions of each MCP server to form a global tool library; the client integrates a large language model; S2. Receive the user's natural language task instruction, which represents an end-to-end task involving multiple DevOps phases; input the natural language task instruction and the information of the global tool library into the large language model; S3, the large language model, acts as a planner to decompose natural language task instructions, identify at least two sub-tasks belonging to different DevOps stages, match target tool functions for each sub-task based on the global tool library, and determine the execution logic and dependencies between target tool functions to generate a structured tool call plan. S4. The client executes the structured tool invocation plan and, based on the execution logic and dependencies, sequentially or in parallel invokes the target tool functions on the corresponding MCP server through the MCP protocol. S5. The client monitors the execution of each utility function and determines the subsequent process or triggers a preset rollback operation based on the execution status, and feeds back the final execution result to the large language model. S6. The large language model generates a natural language summary containing the overall execution status of the task based on the execution result and outputs it to the user.

[0007] As a further limitation of the technical solution of the present invention, step S1 includes: S11. The client reads the configuration file to obtain the startup configuration information of multiple MCP servers to be connected. The startup configuration information includes at least the server type, startup command, and connection parameters. S12. The client starts multiple MCP server processes concurrently according to the startup configuration information, and establishes MCP session connections with each MCP server through standard input / output channels or HTTP protocol. S13. After establishing a session connection, the client sends a tool list request to each MCP server and receives metadata of the exposed tool functions returned by each MCP server. The metadata includes the tool name, function description and calling parameter format. S14. The client aggregates the metadata of all utility functions returned by the MCP server and constructs the global utility library.

[0008] By leveraging the tool's ability to dynamically discover and aggregate multiple MCP servers through the client, when adding new functional modules to the system, only the corresponding MCP server needs to be deployed and registered, without modifying the client or core planning logic, thus improving the system's scalability and maintainability.

[0009] As a further limitation of the technical solution of the present invention, step S2 includes: S21. Construct a prompt word template, the prompt word template including: The system role definition section is used to limit the identity of the large language model to DevOps domain experts; The tool library description section is used to embed metadata for all tool functions in the global tool library; The task instruction section is used to fill in the natural language task instructions input by the user; The output format instruction section is used to require the large language model to output the structured tool call plan strictly according to the predetermined structured format; S22. Fill the tool library description part with the information of the global tool library, fill the task instruction part with the natural language task instruction, and assemble them into the final prompt word; S23. Input the final prompt word into the application programming interface of the large language model to trigger the large language model to perform planning operations.

[0010] The design prompt word templates effectively guide the large language model to work within the correct domain context and strict output specifications, resulting in a structured tool call plan that is machine-readable and logically clear.

[0011] As a further limitation of the technical solution of the present invention, in S3, the large language model acts as a planner and performs the following operations: S31. Based on the understanding of DevOps workflow, the natural language task instructions are parsed into an ordered sequence of subtasks, wherein each subtask belongs to a different DevOps stage, and the output of the previous subtask is identified as the potential input of the next subtask. S32. Perform semantic similarity calculation between the target of the subtask and the functional description of each tool in the global tool library, and select at least one functionally matching target tool function for each subtask. S33. Based on the order of the subtask sequence and the input and output parameters of each target tool function, automatically infer the execution logic and dependencies between each tool function. The execution logic includes serial, parallel, or condition-triggered execution, and the dependencies include data dependencies and control dependencies. S34. Assemble the subtask sequence, the matched target utility functions, and the corresponding execution logic and dependencies into a machine-readable structured document, namely a structured tool call plan. The plan lists the sequence of utility functions to be called, the call parameters of each function, and the dependency identifiers between functions.

[0012] By decomposing tasks, semantic matching, and dependency inference, the large language model can deeply understand the internal logic of DevOps tasks, transforming ambiguous user instructions into precise plans with clear execution sequences and dependencies, thus solving the problem that traditional automation tools cannot handle complex, multi-stage workflow planning.

[0013] As a further limitation of the technical solution of the present invention, in S4, the client executes the structured tool invocation plan, and the specific steps are as follows: S41. Analyze the structured tool call plan, and construct a directed acyclic graph in memory based on the execution logic and dependencies, where nodes are the target tool functions to be called and their parameters, and edges are the dependencies between functions; S42. Perform topological sorting on the directed acyclic graph to generate a task queue; the task queue contains multiple parallel task groups arranged sequentially, and each parallel task group contains one or more utility functions that can be executed in parallel. S43. Traverse the task queue. For each tool function in the task queue, encapsulate the tool name and calling parameters into a standard JSON-RPC request according to the requirements of the MCP protocol, and send it to the corresponding MCP server through the established MCP session connection. S44. Receive the JSON-RPC response returned by each MCP server, parse the execution result of the utility function, and pass the result as an input parameter to subsequent utility function calls that depend on this result.

[0014] By applying directed acyclic graphs (DAGs) and topology sorting algorithms to execution scheduling, parallel opportunities in tasks can be intelligently identified, maximizing execution efficiency. Simultaneously, by maintaining execution status markers and delivering real-time results, accurate process progression and data consistency are ensured.

[0015] As a further limitation of the technical solution of the present invention, in S5, the client performs the following steps: S51. Concurrently call all utility functions within a parallel task group, and maintain a status flag for each utility function call, the status flag including execution in progress, success, and failure; S52. Check the return result of each utility function call; If a utility function call fails, the subsequent execution of the entire task queue will be immediately suspended, and a pre-defined rollback operation will be triggered. If all utility function calls within a parallel task group succeed, the next parallel task group will be started and executed according to the order of the task queue. S53. After the entire structured tool call plan is completed or aborted, aggregate the execution status and result output of all tool function calls to generate a unified execution report. S54. The execution report is used as the final execution result and fed back to the large language model.

[0016] As a further limitation of the technical solution of the present invention, the triggering of the preset rollback operation specifically includes: S521. When a failure of a utility function call is detected, the client inputs the current failure status of the task and the execution results of the sequence of successfully executed utility functions as context information into the large language model. S522. Based on the context information, the large language model generates a rollback tool call plan specifically for rollback, the rollback tool call plan containing one or more rollback tool functions for undoing successful operations; S523. The client receives and executes the rollback tool call plan, and restores the system state to the state before the execution of this task or a consistent intermediate state by calling the corresponding rollback tool function on the MCP server.

[0017] As a further limitation of the technical solution of the present invention, in S522, the step of generating the rollback tool call plan for the large language model includes: S522a. Analyze the context information, identify the sequence of tool function operations that have been successfully executed and need to be undone, and determine the inverse dependencies between the tool function operations; S522b. Based on the global tool library, for each operation that needs to be undone, a corresponding rollback tool function is semantically matched; wherein, the rollback operation of a tool function is determined by one of the following methods: Match a standalone rollback tool with a function description of undoing an operation; Alternatively, match and combine one or more general, basic tools that enable state recovery; S522c: Based on the execution order of the identified operations and the logic of changes in system state, the execution order of the rollback operation is inferred. This execution order is the reverse or partially reverse of the original execution order. S522d assembles the operations that need to be rolled back, the matching rollback utility functions, and the inferred execution order of the rollback operations into a machine-readable rollback utility call plan.

[0018] By monitoring the execution status of each utility function in real time and immediately triggering an intelligent rollback plan dynamically generated by a large language model upon failure, the system can be automatically restored to a safe point. This improves the fault tolerance of automated processes and the overall resilience of the system, avoiding situations where a single point of failure leads to the collapse of the entire process and requires emergency manual intervention.

[0019] As a further limitation of the technical solution of the present invention, in S6, the step of generating and outputting natural language summaries by the large language model includes: S61. Extract key information points from the final execution result. The key information points include: the final state of the task, the successfully completed subtasks, the subtasks that failed to execute and the reasons for the failure, and the output data generated by the tool function. S62. Based on the extracted key information points, generate a natural language summary containing at least two of the following dimensions: Status Overview: Summarize the overall success or failure of the task in one sentence; Execution timeline: Briefly describe the steps completed in chronological order; Exception focusing: If failures occur, explain the location and cause of the failures; Result delivery: Clearly present the final product or system state changes that the user is concerned about; S63. When a task fails, attach actionable suggestions to the summary for problem localization or manual repair. S64. Output the generated summary content to the user interface.

[0020] The system ultimately reports the results to users in a structured, multi-dimensional natural language summary, enabling operations and maintenance personnel to quickly grasp the overall status of the task, especially to quickly locate the root cause in the event of a failure, thereby improving the transparency of operations and maintenance and the efficiency of post-event decision-making.

[0021] Secondly, the present invention also provides a DevOps task intelligent orchestration and execution system based on MCP, used to implement the method described in the first aspect, including: The planning engine module, deployed on the client, integrates a large language model and is configured to: receive natural language task instructions from users; access the global tool library; act as a planner to perform task decomposition, tool matching, and dependency inference to generate a structured tool invocation plan; and generate a natural language summary based on the execution results. The service integration module, deployed on the client, is configured to: establish connections with multiple MCP servers and manage sessions; obtain utility function metadata from each MCP server to build and maintain the global utility library; and execute the structured tool invocation plan, including invoking utility functions, monitoring execution status, and triggering rollback operations. Multiple DevOps function servers run as MCP servers, each server corresponding to a DevOps function module, and is configured to expose one or more utility functions to the service integration module.

[0022] As a further limitation of the technical solution of the present invention, the service integration module includes: The connection management unit is configured to read the configuration file, concurrently start multiple MCP server processes, and establish and maintain MCP session connections with each server via a channel or HTTP protocol. The tool discovery unit is configured to request and receive metadata of the tool functions from each MCP server, and aggregate and build the global tool library. The plan execution unit is configured to parse the structured tool call plan, construct a directed acyclic graph, perform topological sorting to generate a task queue, and traverse the queue to call tool functions through the MCP protocol. The status monitoring unit is configured to maintain the status flags of each utility function call, check the return results, and decide whether to continue execution, abort, or trigger a rollback based on the results.

[0023] As a further limitation of the technical solution of the present invention, the planning engine module includes: The prompt assembly unit is configured to assemble information from the global tool library and natural language task instructions into the final prompt based on a preset prompt template; The planner unit, driven by the large language model, is configured to process the final prompt word to perform task decomposition, semantic matching, dependency inference, and plan assembly. The rollback planning unit, driven by the large language model, is configured to generate a rollback tool invocation plan based on the failure context; The summary generation unit, driven by the large language model, is configured to extract key information from the execution results and generate a multi-dimensional natural language summary.

[0024] As a further limitation of the technical solution of the present invention, the multiple DevOps function servers include: The version control MCP server exposes utility functions for manipulating code repositories; The Continuous Integration and Continuous Deployment (MCP) server exposes utility functions for operating the CI / CD pipeline. The Container Orchestration MCP server exposes utility functions for operating containerized clusters.

[0025] As can be seen from the above technical solutions, this application has the following advantages: By using a large language model as the core planner, it can understand the complex task intentions expressed by users in natural language, involving multiple DevOps stages, and automatically decompose, plan, and execute them. Through the MCP protocol, various heterogeneous DevOps tools are uniformly abstracted and integrated, constructing a global tool library. This enables the large language model to coordinate and call across tools in a unified context, fundamentally solving the problems of low compatibility and difficulty in collaboration between different automation modules, and achieving seamless cross-platform and cross-environment operation automation.

[0026] Operations personnel no longer need to memorize complex commands, API parameters, or script syntax; they can trigger a complete automated process simply by describing the task objective in natural language. This lowers the professional barrier and effectively avoids operational failures caused by manual operation and script writing errors, thereby improving system reliability and stability. Attached Figure Description

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

[0028] Figure 1 This is a flowchart illustrating the method provided in an embodiment of the present invention.

[0029] Figure 2 A block diagram of a system provided in an embodiment of the present invention. Detailed Implementation

[0030] To make the purpose, features, and advantages of this application more apparent and understandable, specific embodiments and accompanying drawings will be used to clearly and completely describe the technical solution protected by this application. Obviously, the embodiments described below are only some embodiments of this application, and not all embodiments. Based on the embodiments in this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0031] Unless otherwise defined, all technical and scientific terms used in this application have the same meaning as commonly understood by one of ordinary skill in the art to which this invention pertains. The terminology used in this application and in the specification of this invention is for the purpose of describing particular embodiments only and is not intended to be limiting of the invention.

[0032] like Figure 1 As shown, this embodiment of the invention provides a DevOps task intelligent orchestration and execution method based on MCP, including: S1. Establish connections between the client and multiple MCP servers corresponding to different DevOps functional modules, and obtain the utility functions of each MCP server to form a global tool library; the client integrates a large language model; Employing a client-server model, each DevOps module (such as code repository, CI / CD pipeline, container orchestration, etc.) runs as an MCP server, exposing its functionality to the MCP client (i.e., the AI ​​assistant program). MCP uses the JSON-RPC protocol (with stdio communication locally) as the transmission method and provides a formal Python SDK to support client and server development. Through this architecture, users can issue operation requests to a large language model using natural language, and the model then calls various tool modules through the standardized MCP interface to complete the task.

[0033] Develop using Python and configure a virtual environment. First, create a Python project directory and enter it. You can use `python -m venv` or the tools `uv init` and `uv venv` to create a virtual environment. After activating the virtual environment, install the Python libraries related to the MCP protocol and the LLM interface library using a package manager, for example, `pip install mcp anthropicpython-dotenv`. After installation, create a configuration file (.env) to store the API key for the large language model, ensuring that the credentials can be read when calling the model interface.

[0034] Choose a suitable large language model as the AI ​​assistant and call it via the corresponding Python SDK or HTTP interface. Use Anthropic's Python library or OpenAI's library to call the API within the program. Ensure key security by loading the API key from the .env file. Implement a dialogue loop: the front end receives the user's natural language request, passes it as input to the model, and provides a list of available tools so the model can choose which tool to invoke based on the context.

[0035] Implement the client using the MCP Python SDK. Establish a session with the MCP server using the `ClientSession` class and connect via `stdio_client` or HTTP. For example, you can write an asynchronous function `connect_to_server(server_script_path)` that calls the corresponding command (Python or Node.js) based on the passed-in script path to start the MCP server process, and initialize the session using `ClientSession(self.stdio, self.write)`. After connecting, call `session.initialize()` to activate the protocol and `session.list_tools()` to retrieve a list of all tools exposed by the server. During client initialization, call this connection method for each target MCP server to collect all relevant tools into a list for subsequent communication.

[0036] Based on requirements, determine the necessary DevOps functionalities to support, such as version control (Git / GitHub / GitLab), CI / CD pipelines (Jenkins, GitHub Actions, etc.), container images and orchestration (Docker, Kubernetes, etc.), and Infrastructure as Code (Terraform / Pulumi). For these modules, existing MCP servers can be prioritized to accelerate development. For example, existing open-source MCP servers support Git / GitHub, GitLab and Gitea, as well as Azure DevOps; for CI / CD, there are existing GitHub Actions MCP services and Azure DevOps Pipelines integrations. For container orchestration, MCP servers designed for Kubernetes can be used for integration; for infrastructure management, MCP servers supporting Terraform / Pulumi can be used. Based on these references, implement the corresponding MCP servers or integrate existing servers to provide a unified context and operation interface for the AI ​​assistant.

[0037] This step specifically includes: S11. The client reads the configuration file to obtain the startup configuration information of multiple MCP servers to be connected. The startup configuration information includes at least the server type, startup command, and connection parameters. S12. The client starts multiple MCP server processes concurrently according to the startup configuration information, and establishes MCP session connections with each MCP server through standard input / output channels or HTTP protocol. S13. After establishing a session connection, the client sends a tool list request to each MCP server and receives metadata of the exposed tool functions returned by each MCP server. The metadata includes the tool name, function description and calling parameter format. S14. The client aggregates the metadata of all utility functions returned by the MCP server and constructs the global utility library.

[0038] S2. Receive the user's natural language task instruction, which represents an end-to-end task involving multiple DevOps phases; input the natural language task instruction and the information of the global tool library into the large language model; this step specifically includes: S21. Construct a prompt word template, the prompt word template including: The system role definition section is used to limit the identity of the large language model to DevOps domain experts; The tool library description section is used to embed metadata for all tool functions in the global tool library; The task instruction section is used to fill in the natural language task instructions input by the user; The output format instruction section is used to require the large language model to output the structured tool call plan strictly according to the predetermined structured format; S22. Fill the tool library description part with the information of the global tool library, fill the task instruction part with the natural language task instruction, and assemble them into the final prompt word; S23. Input the final prompt word into the application programming interface of the large language model to trigger the large language model to perform planning operations.

[0039] S3. The large language model acts as a planner, decomposing the natural language task instructions and identifying at least two subtasks belonging to different DevOps phases. Based on a global tool library, it matches target tool functions for each subtask and determines the execution logic and dependencies between these target tool functions to generate a structured tool invocation plan. The large language model, as the planner, performs the following operations: S31. Based on the understanding of DevOps workflow, the natural language task instructions are parsed into an ordered sequence of subtasks, wherein each subtask belongs to a different DevOps stage, and the output of the previous subtask is identified as the potential input of the next subtask. S32. Perform semantic similarity calculation between the target of the subtask and the functional description of each tool in the global tool library, and select at least one functionally matching target tool function for each subtask. S33. Based on the order of the subtask sequence and the input and output parameters of each target tool function, automatically infer the execution logic and dependencies between each tool function. The execution logic includes serial, parallel, or condition-triggered execution, and the dependencies include data dependencies and control dependencies. S34. Assemble the subtask sequence, the matched target utility functions, and the corresponding execution logic and dependencies into a machine-readable structured document, namely a structured tool call plan. The plan lists the sequence of utility functions to be called, the call parameters of each function, and the dependency identifiers between functions.

[0040] S4. The client executes the structured tool invocation plan, and according to the execution logic and dependencies, calls the target tool functions on the corresponding MCP server sequentially or in parallel via the MCP protocol; the specific steps of the client executing the structured tool invocation plan are as follows: S41. Analyze the structured tool call plan, and construct a directed acyclic graph in memory based on the execution logic and dependencies, where nodes are the target tool functions to be called and their parameters, and edges are the dependencies between functions; S42. Perform topological sorting on the directed acyclic graph to generate a task queue; the task queue contains multiple parallel task groups arranged sequentially, and each parallel task group contains one or more utility functions that can be executed in parallel. S43. Traverse the task queue. For each tool function in the task queue, encapsulate the tool name and calling parameters into a standard JSON-RPC request according to the requirements of the MCP protocol, and send it to the corresponding MCP server through the established MCP session connection. S44. Receive the JSON-RPC response returned by each MCP server, parse the execution result of the utility function, and pass the result as an input parameter to subsequent utility function calls that depend on this result.

[0041] It should be noted here that the steps in S42 include: S421. Initialize an empty task queue, identify all nodes with an in-degree of zero in the directed acyclic graph, and add the identified nodes to a ready set. S422. Repeat the following steps until the ready set is empty: S422a. Take all nodes in the current ready set as a parallel task group and append the parallel task group to the tail of the task queue. S422b: Clear the current ready set; S422c. Simulate the execution of each node in the parallel task group and traverse each direct successor node of the node, decrementing the in-degree value of the direct successor node by one. S422d. During the traversal, check each direct successor node whose in-degree value has been updated. If the in-degree value is reduced to zero, add the direct successor node to the ready set. S423. Output the generated task queue.

[0042] S5. The client monitors the execution of each utility function and determines the subsequent process or triggers a preset rollback operation based on the execution status, feeding back the final execution result to the large language model; in this step, the client performs the following steps: S51. Concurrently call all utility functions within a parallel task group, and maintain a status flag for each utility function call, the status flag including execution in progress, success, and failure; S52. Check the return result of each utility function call; If a utility function call fails, the subsequent execution of the entire task queue will be immediately suspended, and a pre-defined rollback operation will be triggered. If all utility function calls within a parallel task group succeed, the next parallel task group will be started and executed according to the order of the task queue. S53. After the entire structured tool call plan is completed or aborted, aggregate the execution status and result output of all tool function calls to generate a unified execution report. S54. The execution report is used as the final execution result and fed back to the large language model.

[0043] The triggering of the preset rollback operation specifically includes: S521. When a failure of a utility function call is detected, the client inputs the current failure status of the task and the execution results of the sequence of successfully executed utility functions as context information into the large language model. S522. Based on the context information, the large language model generates a rollback tool invocation plan specifically for rollback, the rollback tool invocation plan containing one or more rollback tool functions for undoing successful operations; the steps of the large language model generating the rollback tool invocation plan include: S522a. Analyze the context information, identify the sequence of tool function operations that have been successfully executed and need to be undone, and determine the inverse dependencies between the tool function operations; S522b. Based on the global tool library, for each operation that needs to be undone, a corresponding rollback tool function is semantically matched; wherein, the rollback operation of a tool function is determined by one of the following methods: Match a standalone rollback tool with a function description of undoing an operation; Alternatively, match and combine one or more general, basic tools that enable state recovery; S522c: Based on the execution order of the identified operations and the logic of changes in system state, the execution order of the rollback operation is inferred. This execution order is the reverse or partially reverse of the original execution order. S522d assembles the operations that need to be rolled back, the matching rollback utility functions, and the inferred execution order of the rollback operations into a machine-readable rollback utility call plan.

[0044] S523. The client receives and executes the rollback tool call plan, and restores the system state to the state before the execution of this task or a consistent intermediate state by calling the corresponding rollback tool function on the MCP server.

[0045] S6. The large language model generates a natural language summary containing the overall execution status of the task based on the execution result and outputs it to the user. This step, in which the large language model generates and outputs the natural language summary, includes: S61. Extract key information points from the final execution result. The key information points include: the final state of the task, the successfully completed subtasks, the subtasks that failed to execute and the reasons for the failure, and the output data generated by the tool function. S62. Based on the extracted key information points, generate a natural language summary containing at least two of the following dimensions: Status Overview: Summarize the overall success or failure of the task in one sentence; Execution timeline: Briefly describe the steps completed in chronological order; Exception focusing: If failures occur, explain the location and cause of the failures; Result delivery: Clearly present the final product or system state changes that the user is concerned about; S63. When a task fails, attach actionable suggestions to the summary for problem localization or manual repair. S64. Output the generated summary content to the user interface.

[0046] It should be noted that the DevOps functional modules include version control, CI / CD pipeline, container image and orchestration, and infrastructure management modules.

[0047] Version control module implementation: After selecting a code repository management tool, implement its MCP server-side functionality. For example, when integrating with Git / GitHub, an existing MCP server can be used to support local repository operations, or the official GitHub MCP server service can be used to manage remote repositories, pull requests, and issues. If a custom implementation is needed, an MCP server script can be written in Python, encapsulating Git command-line operations as utility functions. Utilities are defined using the `@mcp.tool` decorator, and their functions and parameters are described in the annotations. For example, utility functions such as `list_repos`, `get_branches`, `create_pr`, and `merge_pr` can be defined to support common repository operations. After starting this MCP server, clients can call these tools to perform version control tasks via the MCP protocol.

[0048] CI / CD pipeline module implementation: Enables MCP integration for continuous integration / continuous delivery services. For example, an MCP server plugin can be installed on Jenkins, making Jenkins act as an MCP server. This plugin automatically exposes Jenkins job triggering, build status querying, deployment, and other functions as MCP tools. For cloud pipelines such as GitHub Actions and GitLab CI, existing MCP integration projects can be used to wrap pipeline operations as callable interfaces. During implementation, ensure that pipeline tasks can be executed through tool calls: for example, define tool functions to trigger new builds, query the status of the last build, and deploy to the target environment. AI assistants will be able to automatically trigger or manage CI / CD pipelines using natural language commands and these tools.

[0049] Container orchestration module implementation: For container images and orchestration platforms (such as Kubernetes and Docker Swarm), an MCP server is implemented to support deployment and management functions. For example, third-party or community MCP servers can be used to allow AI assistants to control Kubernetes clusters through chat models. Existing kubectl-mcp-server allows models to directly communicate with Kubernetes and execute commands, while other MCP servers can securely execute commands such as kubectl, helm, and argocd. For Docker container deployments, utility functions can also be defined to perform operations such as image building, pushing to image repositories, and starting containers. By registering these container management functions as MCP tools, user natural language requests can drive cluster or container environment management operations.

[0050] Infrastructure Management Module Implementation: If needed, Infrastructure as Code (IaC) tools can be integrated into the platform. The community already has various Terraform or Pulumi MCP server implementations, such as servers supporting Terraform Cloud and local Terraform operations. During development, appropriate libraries or command-line methods can be selected to encapsulate IaC operations on the Python MCP server side. Utility functions may include `plan_infrastructure`, `apply_infrastructure`, and `destroy_infrastructure`, used to automatically generate plans, apply changes, or destroy resources. The AI ​​assistant can invoke these tools during conversations to complete resource orchestration and configuration management tasks.

[0051] The functionality of each module described above is exposed to the model as MCP tools. When using the Python MCP SDK, functions are marked as tools in the server-side code using the `@mcp.tool` decorator. The decorator annotation sets the tool's name, title, and prompt information (e.g., whether it's read-only, destructive, etc.). When implementing the function, the specific operational logic (such as calling system commands or SDK operations) is placed within the function body. Once the MCP server starts, these tools are reported to the client, and the model can select them as needed.

[0052] Each server program is started sequentially, and the client establishes a connection. The client code can call the aforementioned `connect_to_server` method or similar logic to start the server program as a child process. After starting, `session.initialize()` needs to be called to perform a handshake and synchronize the protocol state, and then `session.list_tools()` is called to collect all available tools for the server. The names, descriptions, and input patterns of these tools are recorded to build a global tool table.

[0053] The process transforms user input into a model call and processes the results returned by the model. Upon receiving a user's text query, the client encapsulates it as a message and sends it to the model, simultaneously appending a previously collected list of tools to the model call request, allowing the model to learn about available tools.

[0054] Analyze the model's response. If the response contains a request to invoke a tool, extract the tool name and input parameters, and execute the corresponding tool call using the MCP session. Specifically, call `await session.call_tool(tool_name, tool_args)` to execute the server-side tool function. After obtaining the execution result, re-inject the result into the dialogue context to provide feedback to the model. This typically requires calling the model interface again for subsequent inference.

[0055] The results of the tool's execution are used as new inputs to continue the dialogue with the model. The model may call multiple tools consecutively, and the results should be fed back after each call, until the model completes the task and returns the final text output.

[0056] Once the model generates a plain text response that no longer contains tool calls, the system presents it to the user as the final answer. At this point, the dialogue may have completed a DevOps operation, and the user can see a description or confirmation of the result. The system should integrate all useful information from the dialogue and provide clear feedback to the user. This process is repeated when the user makes a new request, allowing for multiple rounds of interaction. The system should preserve the dialogue context, enabling the model to remember previous operations and results. Each loop re-evaluates the list of available tools, invokes the model, and processes tool calls until the user exits or the task is completed.

[0057] In implementation, potential errors should be considered. For example, if a tool fails to execute or the model misunderstands its operation, appropriate error messages should be provided, and users or the model should be allowed to perform a rollback. During deployment, a rollback tool can be designed to restore the previous state when the user or model determines that a rollback is necessary. Through appropriate error handling and rollback tools, the system's robustness and recoverability in abnormal situations can be ensured.

[0058] Supports future expansion with new DevOps modules; simply add relevant tools by referring to existing MCP servers in the community. New tools can be integrated as MCP servers without requiring large-scale modifications to the client.

[0059] like Figure 2 As shown, this embodiment of the invention also provides a DevOps task intelligent orchestration and execution system based on MCP, used to implement the methods described in the above embodiments, including: The planning engine module, deployed on the client, integrates a large language model and is configured to: receive natural language task instructions from the user; access the global tool library; act as a planner to perform task decomposition, tool matching, and dependency inference to generate a structured tool invocation plan; and generate a natural language summary based on the execution results. The planning engine module includes: The prompt assembly unit is configured to assemble information from the global tool library and natural language task instructions into the final prompt based on a preset prompt template; The planner unit, driven by the large language model, is configured to process the final prompt word to perform task decomposition, semantic matching, dependency inference, and plan assembly. The rollback planning unit, driven by the large language model, is configured to generate a rollback tool invocation plan based on the failure context; The summary generation unit, driven by the large language model, is configured to extract key information from the execution results and generate a multi-dimensional natural language summary.

[0060] The service integration module, deployed on the client, is configured to: establish connections with multiple MCP servers and manage sessions; acquire utility function metadata from each MCP server to build and maintain the global utility library; execute the structured tool invocation plan, including invoking utility functions, monitoring execution status, and triggering rollback operations; the service integration module includes: The connection management unit is configured to read the configuration file, concurrently start multiple MCP server processes, and establish and maintain MCP session connections with each server via a channel or HTTP protocol. The tool discovery unit is configured to request and receive metadata of the tool functions from each MCP server, and aggregate and build the global tool library. The plan execution unit is configured to parse the structured tool call plan, construct a directed acyclic graph, perform topological sorting to generate a task queue, and traverse the queue to call tool functions through the MCP protocol. The status monitoring unit is configured to maintain the status flags of each utility function call, check the return results, and decide whether to continue execution, abort, or trigger a rollback based on the results.

[0061] Multiple DevOps function servers, running as MCP servers, each server corresponding to a DevOps function module, are configured to expose one or more utility functions to the service integration module. The multiple DevOps function servers include: The version control MCP server exposes utility functions for manipulating code repositories; The Continuous Integration and Continuous Deployment (MCP) server exposes utility functions for operating the CI / CD pipeline. The Container Orchestration MCP server exposes utility functions for operating containerized clusters.

[0062] The above description of the disclosed embodiments enables those skilled in the art to make or use the invention. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the invention. Therefore, the invention is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. A method for intelligent orchestration and execution of DevOps tasks based on MCP, characterized in that, Comprise: S1, a client and a plurality of MCP servers corresponding to different DevOps function modules are connected, and tool functions of each MCP server are obtained to form a global tool library; the client integrates a large language model; S2, receiving a user's natural language task instruction, the natural language task instruction represents an end-to-end task involving multiple DevOps stages; the natural language task instruction and the information of the global tool library are input into the large language model; S3, the large language model as a planner, task decomposition is performed on the natural language task instruction, and at least two subtasks belonging to different DevOps stages are identified; Based on the global tool library, the target tool function is matched for each subtask, and the execution logic and dependency relationship between the target tool functions are determined to generate a structured tool calling plan; S4, the client executes the structured tool calling plan, and according to the execution logic and dependency relationship, the target tool function on the MCP server is called through the MCP protocol in sequence or in parallel; S5, the client monitors the execution of each tool function, and decides the subsequent process or triggers the preset rollback operation according to the execution state, and feeds back the final execution result to the large language model; S6, the large language model generates a natural language summary containing the task overall execution state based on the execution result, and outputs it to the user. 2.The MCP-based DevOps task intelligent scheduling and execution method of claim 1, wherein, The steps of S1 include: S11, the client reads the configuration file to obtain the start configuration information of the plurality of MCP servers to be connected, and the start configuration information at least includes the server type, the start command and the connection parameter; S12, the client starts the plurality of MCP server processes according to the start configuration information, and establishes the MCP session connection with each MCP server through the standard input and output channel or the HTTP protocol; S13, after establishing the session connection, the client sends a tool list request to each MCP server, and receives the metadata of the tool functions exposed to the outside returned by each MCP server, and the metadata includes the name, function description and calling parameter format of the tool; S14, the client aggregates the metadata of the tool functions returned by all MCP servers to construct the global tool library. 3.The MCP-based DevOps task intelligent scheduling and execution method of claim 2, wherein, The steps of S2 include: S21, a prompt word template is constructed, which includes: The system role definition part is used to limit the identity of the large language model as a DevOps field expert; The tool library description part is used to embed the metadata of all tool functions in the global tool library; The task instruction part is used to fill in the natural language task instruction input by the user; The output format instruction part is used to require the large language model to strictly output the structured tool calling plan in a predetermined structured format; S22, the information of the global tool library is filled into the tool library description part, and the natural language task instruction is filled into the task instruction part to assemble a final prompt word; S23, the final prompt word is input into the application program interface of the large language model to trigger the large language model to perform planning operation.

4. The MCP-based DevOps task intelligent scheduling and execution method of claim 3, wherein, In S3, the large language model as a planner performs the following operations: S31, based on the understanding of the DevOps field workflow, the natural language task instruction is parsed into an ordered subtask sequence, wherein each subtask belongs to a different DevOps stage, and the output of a previous subtask is identified as the potential input of a subsequent subtask; S32, semantic similarity calculation is performed between the target of each subtask and the function description of each tool in the global tool library, and at least one function-matched target tool function is selected for each subtask; S33, based on the order of the subtask sequence and the input and output parameters of each target tool function, the execution logic and dependency relationship between the tool functions are automatically inferred, the execution logic includes serial, parallel or conditional triggering, and the dependency relationship includes data dependency and control dependency; S34, the subtask sequence, the matched target tool function, and the corresponding execution logic and dependency relationship are assembled into a machine-readable structured document, i.e., a structured tool calling plan, which lists the sequence of tool functions to be called, the calling parameters of each function, and the dependency relationship between functions. 5.The MCP-based DevOps task intelligent scheduling and execution method of claim 4, wherein, In S4, the client executes the structured tool calling plan, and the specific steps are as follows: S41, parse the structured tool calling plan, and construct a directed acyclic graph in memory according to the execution logic and dependency relationship, wherein the nodes are the target tool functions and parameters to be called, and the edges are the dependency relationship between functions; S42, topological sorting is performed on the directed acyclic graph to generate a task queue; the task queue sequentially arranges a plurality of parallel task groups, and each parallel task group contains one or more tool functions that can be executed in parallel; S43, traverse the task queue, and for each tool function in the task queue, encapsulate the tool name and calling parameters into a standard JSON-RPC request according to the requirements of the MCP protocol, and send it to the corresponding MCP server through the established MCP session connection; S44, receive the JSON-RPC response returned by each MCP server, parse the execution result of the tool function, and pass the result as an input parameter to the subsequent tool function call that depends on the result. 6.The MCP-based DevOps task intelligent scheduling and execution method of claim 5, wherein, In S5, the client performs the following steps: S51, concurrently call all tool functions in a parallel task group, and maintain a state identifier for each tool function call, the state identifier includes executing, success, and failure; S52, check the return result of each tool function call; If a tool function call fails, the subsequent execution of the entire task queue is immediately aborted, and a preset rollback operation is triggered; If all tool function calls in a parallel task group are successful, the next parallel task group is started according to the order of the task queue; S53, when the entire structured tool calling plan is executed or aborted, the execution state and result of all tool function calls are aggregated to generate a unified execution report; S54, the execution report is fed back to the large language model as the final execution result.

7. The MCP-based DevOps task intelligent scheduling and execution method of claim 6, wherein, The preset rollback operation specifically includes: S521, when the tool function call fails, the client inputs the current failure state of the task and the execution results corresponding to the successfully executed tool function sequence as context information into the large language model; S522, the large language model generates a rollback tool call plan based on the context information, and the rollback tool call plan includes one or more rollback tool functions for undoing the successful operations; S523, the client receives and executes the rollback tool call plan, and restores the system state to the state before the task execution or a consistent intermediate state by calling the rollback tool functions on the corresponding MCP server. 8.The MCP-based DevOps task intelligent scheduling and execution method of claim 7, wherein, In S522, the step of generating the rollback tool call plan by the large language model includes: S522a, analyzing the context information, identifying the tool function operation sequence that has been successfully executed and needs to be undone, and determining the reverse dependency relationship between the tool function operations; S522b, based on the global tool library, for each operation that needs to be undone, the corresponding rollback tool function is semantically matched; wherein the rollback operation of a tool function is determined by one of the following ways: Matching an independent rollback tool whose function description is to undo the operation; Or, matching and combining one or more general basic tools that can restore the state; S522c, based on the execution order of the identified operations and the change logic of the system state, the execution order of the rollback operation is inferred, which is in reverse or partially reverse relationship with the original execution order; S522d, the operations that need to be rolled back, the matched rollback tool functions, and the inferred execution order of the rollback operations are assembled into a machine-readable rollback tool call plan. 9.The MCP-based DevOps task intelligent scheduling and execution method of claim 8, wherein, In S6, the steps of generating and outputting the natural language summary by the large language model include: S61, extracting key information points from the final execution result, including: the final state of the task, the successfully completed subtasks, the failed subtasks and the failure reasons, and the output data generated by the tool functions; S62, based on the extracted key information points, a natural language summary is generated, which includes at least two dimensions: State overview: summarize the overall success or failure of the task in one sentence; Execution context: briefly describe the completed steps in chronological order; Abnormal focus: if there is a failure, explain the location and reason of the failure; Result delivery: clearly present the final product or system state change that the user is interested in; S63, when the task execution fails, an actionable suggestion for problem positioning or manual repair is added to the summary; S64, output the generated summary content to the user interface. 10.A system for intelligent orchestration and execution of DevOps tasks based on MCP, characterized in that, The system for implementing the method of any one of claims 1-9 comprises: A planning engine module deployed on the client, integrated with a large language model, configured to: receive natural language task instructions from the user; access the global tool library; as a planner, perform task decomposition, tool matching, and dependency inference to generate a structured tool call plan; generate a natural language summary based on the execution result; a service integration module deployed on the client, configured to: establish connections with and manage sessions of a plurality of MCP servers; obtain tool function metadata of each MCP server to build and maintain the global tool library; execute the structured tool invocation plan, including invoking tool functions, monitoring execution status, triggering rollback operations; a plurality of DevOps function servers, operating as MCP servers, each corresponding to a DevOps function module, configured to expose one or more tool functions to the service integration module.

Citation Information

Patent Citations

  • Method, device, equipment and product for executing task

    CN120013493A

  • Cloud environment intelligent operation and maintenance method and system based on MCP protocol

    CN120639769A

  • Cloud mobile phone control system based on large language model

    CN120658720A

  • Database installation and deployment method based on MCP protocol

    CN120743299A

  • Intelligent DevOps assembly line generation system based on natural language description

    CN120832150A

Cited By

  • Intelligent simulation method, device and equipment for offshore wind power simulation operation and maintenance and medium

    CN122113195A

  • Browser-based human-computer collaborative multi-agent graphical programming system and method

    CN122284983A