Lightweight agent development method and system based on MCP protocol
By employing a method for developing intelligent agents that involves task decomposition, tool matching, and operational monitoring, we have addressed the issue of high complexity in the development of existing intelligent agent frameworks. This approach enables low-threshold, efficient intelligent agent development and management, thereby enhancing the adaptability and usability of intelligent applications.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-03-13
- Publication Date
- 2026-04-10
AI Technical Summary
Existing intelligent agent frameworks require extensive manual screening and programming of MCP tools when facing users, resulting in high professional requirements for developers, making it difficult to meet complex and diverse business needs. Furthermore, the updates and iterations of the MCP architecture are limited, making it impossible to expand in a timely manner.
By receiving user-input tasks, breaking them down, matching them with the MCP toolset, optimizing and building intelligent agents, and inserting runtime monitoring processes into the intelligent agents to verify user identity and adjust execution intensity in real time, the intelligent agents can be developed and managed automatically.
It significantly lowers the barrier to entry for developing intelligent agents, enhances the intelligence level and enterprise-level usability of intelligent applications, and automates the entire process of intelligent agents from task understanding to tool invocation, adapting to complex and ever-changing business needs.
Smart Images

Figure CN121833293A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent agent development technology, specifically a lightweight intelligent agent development method and system based on the MCP protocol. Background Technology
[0002] In recent years, large language model (LLM)-driven agent applications have become a technological hotspot. To complete complex tasks, agents often need to call various external tools or data sources to extend their capabilities, such as retrieving database information, calling third-party APIs, accessing file systems, or executing business processes. Traditionally, many agent frameworks have built-in basic tools for models to use, such as calculators, HTTP requests, and file operations. However, these built-in tools have limited functionality and cannot meet complex and diverse business needs. Furthermore, their updates are constrained by the framework's release cycle, making timely expansion difficult. To address this issue, most existing large model-based task processing processes utilize the MCP protocol. In the MCP architecture, agents only need to interface with the MCP protocol to use various tools without worrying about the different API formats of each tool, achieving decoupling and separation of responsibilities at the protocol level. This greatly simplifies the complexity of multi-tool integration, making the integration of massive amounts of tools possible. Each tool has its corresponding MCP server maintained by its vendor or community, achieving loose coupling between the tool and the agent. Tool upgrades and changes will not affect AI applications.
[0003] Existing MCP architectures cater to both users and developers, with numerous developers providing task processing tools. These vast array of MCP tools can easily build agents tailored to specific needs. However, existing agent building services still require manual selection of tools and targeted programming, which places high demands on users. Therefore, the technical problem this invention aims to solve is how to provide a demand-oriented agent generation solution based on the computing power of large models, thereby reducing the professional requirements of users and enabling agent services to reach more users. Summary of the Invention
[0004] The purpose of this invention is to provide a lightweight intelligent agent development method and system based on the MCP protocol to solve the problems mentioned in the background art.
[0005] To achieve the above objectives, the present invention provides the following technical solution: A lightweight intelligent agent development method and system based on the MCP protocol, the method comprising: The system receives a task to be processed from user input, and then breaks down the task into subtasks; wherein the subtasks use input and output information pairs. Based on the subtask, match MCP tools in the preset MCP tool library to generate a preset number of MCP tool sets; The MCP toolset is optimized, and an intelligent agent is constructed based on the optimized MCP toolset output. Insert a runtime monitoring process into the agent, verify the user's identity in real time based on the runtime monitoring process, and adjust the execution intensity of the agent synchronously.
[0006] As a further aspect of the present invention: the step of receiving a user-input task to be processed and splitting the task to be processed into subtasks includes: The system receives user input of pending tasks and locates task nodes within those tasks; the types of task nodes include input nodes and output nodes. When a task node is both an input node and an output node, it is marked as a relay task node. The task chain is determined based on the transit task nodes, and the hierarchy of each task node is determined synchronously. By comparing the input nodes of different task chains, hyperlinks are established between the same input nodes at the same level to obtain a set of task chains. The task to be processed is split into subtasks based on the task chain set.
[0007] As a further aspect of the present invention: the step of splitting the task to be processed based on the task chain set to obtain sub-tasks includes: In the task chain set, inputs and outputs are paired sequentially according to hierarchical order to obtain sub-chains; Obtain the hierarchical span and hierarchical breadth of the sub-link; the hierarchical span is the hierarchical difference between the total input and total output of the sub-link; the hierarchical breadth is the sum of the number of hyperlinks of each input node in the sub-link; Receive user-input filtering conditions, select sub-links based on the filtering conditions, and use the total input to the total output as feature labels to construct sub-tasks.
[0008] As a further aspect of the present invention: the step of generating a preset number of MCP toolsets based on the subtask matching MCP tools in a preset MCP tool library includes: Step S21: Establish a connection channel with the preset MCP tool library; Step S22: Randomly read subtasks from the subtask library corresponding to the task chain set, and match MCP tools in the MCP tool library according to their inputs and outputs; Step S23: After a successful match, remove the sub-chain corresponding to the sub-task from each task chain in the task chain set, and synchronously update the sub-task library corresponding to the task chain set. Step S24: Repeat steps S22 to S23 until the subtask library is empty, and count the matched MCP tools. Step S25: Repeat steps S22 to S24 until a preset number of times is reached, and output the preset number of MCP toolsets.
[0009] As a further aspect of the present invention: the step of optimizing the MCP toolset and constructing an intelligent agent based on the optimized MCP toolset output includes: Obtain the resource requirements and average response time for each MCP tool in the MCP toolset; the resource requirements include computational requirements and storage requirements; The complexity of the MCP tool is determined by the direct proportion of resource demand and the direct proportion of average response time. The total complexity is obtained by summing the complexity of all MCP tools in the MCP toolset; Select the MCP toolset with the lowest overall complexity as the optimal output MCP toolset; Intelligent agents are built based on the MCP toolset of optimization output.
[0010] As a further aspect of the present invention: the step of inserting a runtime monitoring process into the intelligent agent, verifying the user's identity in real time based on the runtime monitoring process, and synchronously adjusting the execution intensity of the intelligent agent includes: Insert a monitoring process into the intelligent agent to obtain the user's interaction content within a preset time period; The interactive content is converted into text and keywords are extracted to construct a word space; Based on the real-time accumulation of the user's anomaly score in the word space, a verification instruction is generated according to the anomaly score to verify the user's identity. The task quality index is obtained in real time based on the operation monitoring process, and the execution intensity of the intelligent agent is adjusted according to the task quality index; wherein, the application scheme of execution intensity includes: embedding an AI interface in the intelligent agent, and the execution intensity is used to adjust the amount of resources of the AI interface.
[0011] The present invention also provides a lightweight intelligent agent development system based on the MCP protocol, the system comprising: The task splitting module is used to receive the task to be processed input by the user, split the task to be processed into subtasks; wherein the subtasks adopt input and output information pairs; The tool matching module is used to match MCP tools based on the subtask in a preset MCP tool library and generate a preset number of MCP tool sets; The agent construction module is used to optimize the MCP toolset and construct an agent based on the optimized MCP toolset output. The operation monitoring module is used to insert operation monitoring processes into the intelligent agent, verify the user's identity in real time based on the operation monitoring processes, and synchronously adjust the execution intensity of the intelligent agent.
[0012] As a further aspect of the present invention: the task splitting module includes: The task node positioning unit is used to receive user input of tasks to be processed and to locate task nodes in the tasks to be processed; the types of task nodes include input nodes and output nodes. The relay node marking unit is used to mark a task node as a relay task node when it is both an input node and an output node. The node hierarchy determination unit is used to determine the task chain based on the relay task nodes and simultaneously determine the hierarchy of each task node. The task chain statistics unit is used to compare the input nodes of different task chains, establish hyperlinks between the same input nodes at the same level, and obtain a set of task chains. The task splitting unit is used to split the task to be processed into subtasks based on the task chain set.
[0013] As a further aspect of the present invention: the tool matching module includes: The channel establishment unit is used to establish a connection channel with the preset MCP tool library; The matching execution unit is used to randomly read subtasks from the subtask library corresponding to the task chain set, and match MCP tools in the MCP tool library according to their inputs and outputs. The link elimination unit is used to remove the sub-link corresponding to the sub-task from each task chain in the task chain set after a successful match, and to synchronously update the sub-task library corresponding to the task chain set. The first loop unit is used to repeatedly execute the matching execution unit to the link elimination unit until the subtask library is empty, and to count the matched MCP tools. The second loop unit is used to repeatedly execute the matching execution unit up to the first loop unit until a preset number of times is reached, and then output the preset number of MCP tool sets.
[0014] As a further aspect of the present invention: the intelligent agent construction module includes: The tool quantization unit is used to obtain the resource requirements and average response time of each MCP tool in the MCP toolset; the resource requirements include computing requirements and storage requirements. The complexity determination unit is used to determine the complexity of the MCP tool based on the proportionality between resource requirements and average response time. Complexity accumulation unit, used to accumulate the complexity of all MCP tools in the MCP toolset to obtain the comprehensive complexity; The optimization output unit is used to select the MCP toolset with the lowest synthesis complexity as the optimization output MCP toolset. Build execution units for constructing intelligent agents based on the MCP toolset of optimization output.
[0015] Compared with the prior art, the beneficial effects of the present invention are: This invention decomposes the task to be processed into subtasks, matches the subtasks with the MCP tool, optimizes the matching results, and generates an intelligent agent. This realizes full automation of the intelligent agent from task understanding to tool invocation. If combined with a low-code visual orchestration process, it can significantly reduce the development threshold, realize efficient development of intelligent agents, and improve the intelligence level and enterprise-level usability of intelligent applications. Attached Figure Description
[0016] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention.
[0017] Figure 1 A general flowchart of a lightweight agent development method based on the MCP protocol is shown.
[0018] Figure 2 A structural diagram of a lightweight intelligent agent development system based on the MCP protocol is shown. Detailed Implementation
[0019] To make the technical problems to be solved, the technical solutions, and the beneficial effects of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present invention and are not intended to limit the present invention.
[0020] Figure 1 This is a flowchart illustrating the overall process of a lightweight agent development method and system based on the MCP protocol. In this embodiment of the invention, a lightweight agent development method based on the MCP protocol includes: Step S100: Receive the task to be processed input by the user, and split the task to be processed into subtasks; wherein, the subtasks adopt input and output information pairs; A pending task refers to a task that an intelligent agent needs to complete. It is generally an integrated requirement, rarely a simple, fixed requirement. Even with a vast amount of MCP tool resources, it is difficult to directly find an MCP tool that matches such an integrated requirement. In layman's terms, a pending task is a comprehensive requirement. When building an intelligent agent to complete this requirement, the pending task needs to be broken down into several sub-tasks, called a sub-task set. To simplify the expression of sub-tasks, the technical solution of this invention limits sub-tasks to inputs and outputs. That is, whatever the input is, whatever the output is, any MCP tool that can map the input to the output can complete the sub-task.
[0021] Step S200: Based on the subtask, match MCP tools in the preset MCP tool library to generate a preset number of MCP tool sets; The preset MCP tool library is a database that stores a massive amount of MCP tool resources. MCP tools are matched based on the subtasks in the preset MCP tool library. This matching process is not duplicated because MCP tools themselves have attributes that describe their functions. Their functions are represented by inputs and outputs. After matching an MCP tool, an MCP tool set is obtained.
[0022] Step S300: Optimize the MCP toolset and construct an intelligent agent based on the optimized MCP toolset output; For the obtained MCP toolset, each MCP toolset is a set of tools capable of completing the task to be processed. Which MCP toolset to use as the final source for building the agent needs to be optimized first to select the best MCP toolset in a certain aspect, and then the agent is built based on the optimized MCP toolset output. It should be noted that the optimization process generally considers the total number of MCP tools and the response time of each MCP tool. The process of building the agent based on the MCP toolset is a simple tool statistics process, which is a conventional method for those skilled in the art and will not be elaborated here.
[0023] Step S400: Insert a running monitoring process into the intelligent agent, verify the user's identity in real time based on the running monitoring process, and adjust the execution intensity of the intelligent agent synchronously; Based on the established intelligent agent, it is applied to provide services to the user. At this point, the technical solution of this invention is already quite complete. However, the service process of the intelligent agent is a digital service process. With the user's permission (assuming the user has already granted information monitoring permissions), its operation can be monitored. A running monitoring process is inserted into the intelligent agent to obtain the user's usage records based on the running monitoring process, thereby verifying the user's identity in real time and determining whether their identity has changed. At the same time, the execution intensity of the intelligent agent can also be adjusted synchronously according to the usage process. The method of adjusting the execution intensity can be to adjust the performance mode of each tool. For example, a low-power, high-response-time mode can be adopted to adapt to normal usage needs.
[0024] Regarding step S100, the step of receiving the user-input task to be processed and splitting the task to be processed into subtasks includes: The system receives user input of pending tasks and locates task nodes within those tasks; the types of task nodes include input nodes and output nodes. When a task node is both an input node and an output node, it is marked as a relay task node. The task chain is determined based on the transit task nodes, and the hierarchy of each task node is determined synchronously. By comparing the input nodes of different task chains, hyperlinks are established between the same input nodes at the same level to obtain a set of task chains. The task to be processed is split into subtasks based on the task chain set.
[0025] Receiving user input for pending tasks and locating task nodes within them is a straightforward process. Pending tasks are typically workflows with clearly defined inputs and outputs for each step. Each input and output is considered a task node. Task nodes are categorized into two types: input nodes and output nodes, corresponding to input and output respectively. For subtasks in intermediate stages, their input is the output of the previous subtask, and their output is the input of the next subtask. Therefore, there will be numerous task nodes that simultaneously function as both input and output nodes; these are marked as intermediate task nodes. The task chain is determined based on these intermediate task nodes. For example, the adjacent task nodes of an intermediate task node are queried. If another intermediate task node is found, the process continues until a non-intermediate task node is encountered. After obtaining the task chain, the total input is used as the first level, and the levels of subsequent task nodes are determined accordingly.
[0026] Many subtasks are parallel, resulting in non-unique task chains. By counting all task chains, a task chain set is obtained. Furthermore, if two MCP tools have the same input, then they actually have certain commonalities. For example, they can both perform transcoding and recognition on the same type of data. In this case, the preprocessing parts of the inputs of the two MCP tools are similar. In this situation, for different task chains, the input nodes are located. If two identical input nodes are also at the same level, then a hyperlink is established between them. The two MCP tools that establish the hyperlink can interact with each other, forming a tool group.
[0027] Furthermore, the step of splitting the task to be processed into subtasks based on the task chain set includes: In the task chain set, inputs and outputs are paired sequentially according to hierarchical order to obtain sub-chains; Obtain the hierarchical span and hierarchical breadth of the sub-link; the hierarchical span is the hierarchical difference between the total input and total output of the sub-link; the hierarchical breadth is the sum of the number of hyperlinks of each input node in the sub-link; Receive user-input filtering conditions, select sub-links based on the filtering conditions, and use the total input to the total output as feature labels to construct sub-tasks.
[0028] In one example of the technical solution of this invention, the task decomposition process is described. The task decomposition process of this invention is actually a combination process. In a task chain, from the first to the second layer, from the first to the third layer, and from the second to the fourth layer, each input can be paired with its subsequent output. Each pairing method may have a corresponding MCP tool. Therefore, the paired input and output are treated as a subtask. In fact, when pairing inputs and outputs in the task chain, sub-chains are extracted from the task chain, resulting in sub-links. The hierarchical span and hierarchical breadth of the sub-links are obtained. These two parameters reflect the state of the sub-links. A relatively simple approach is to use the hierarchical span as the difference between the total input and total output of the sub-link; and the hierarchical breadth as the sum of the number of hyperlinks of each input node in the sub-link. The sub-links are then filtered based on these two parameters, and the inputs and outputs of the filtered sub-links are combined into subtasks. The filtering criteria... The selection criteria are user-inputted. For example, a hierarchy span threshold can be used as a filtering condition. This threshold is a minimum value used to select sub-links with a sufficiently large hierarchy span (sub-links not less than the hierarchy span threshold) to prevent sub-links from being too short and generating too many sub-tasks. Alternatively, a hierarchy breadth threshold can be used. This threshold can be a maximum value. If a sub-link has a large hierarchy breadth, it indicates that the input nodes within it have a high number of hyperlinks. Such input nodes are worth matching with MCP tools because the matched MCP tools can assist in processing more sub-tasks. Therefore, placing them in the same sub-link is equivalent to hiding the input nodes between them, which is not conducive to the interaction and cooperation between tools. Therefore, a maximum value is used for the hierarchy breadth threshold to select sub-links with a sufficiently small hierarchy breadth (sub-links not greater than the hierarchy breadth threshold) to prevent input nodes with a large number of hyperlinks from being hidden. Of course, both hierarchy span and hierarchy breadth thresholds can be applied simultaneously.
[0029] Regarding step S200, the step of generating a preset number of MCP toolsets based on the subtask matching MCP tools in the preset MCP tool library includes: Step S21: Establish a connection channel with the preset MCP tool library; Step S22: Randomly read subtasks from the subtask library corresponding to the task chain set, and match MCP tools in the MCP tool library according to their inputs and outputs; Step S23: After a successful match, remove the sub-chain corresponding to the sub-task from each task chain in the task chain set, and synchronously update the sub-task library corresponding to the task chain set. Step S24: Repeat steps S22 to S23 until the subtask library is empty, and count the matched MCP tools. Step S25: Repeat steps S22 to S24 until a preset number of times is reached, and output the preset number of MCP toolsets.
[0030] The above content numbers each step because it is a nested loop architecture used to obtain multiple MCP toolkits. The process of obtaining multiple MCP toolkits is itself a large loop, which is executed a preset number of times to obtain the preset number of MCP toolkits. For the generation process of each MCP toolkit, it is a small loop. Specifically, a connection channel with the preset MCP toolkit library is first established, and the MCP tool matching process is started. Since this invention uses input and output as the interface for the matching process, the matching process is not complicated and belongs to the prior art, so it will not be described in detail here. After a successful match, the sub-links corresponding to the subtasks are removed from each task chain in the task chain set (to prevent duplicate matching). At this time, the task chain is broken into new small links. Correspondingly, since the sub-links are removed, the subtasks (inputs or outputs contained in the sub-links) related to them are also removed. Therefore, the subtask library is updated accordingly. Then, subtasks are randomly read from the updated subtask library, and the above process is executed cyclically to finally obtain the MCP toolkits. The generation process of the MCP toolkits is executed cyclically to obtain the preset number of MCP toolkits.
[0031] Regarding step S300, the step of optimizing the MCP toolset and constructing an intelligent agent based on the optimized MCP toolset output includes: Obtain the resource requirements and average response time for each MCP tool in the MCP toolset; the resource requirements include computational requirements and storage requirements; The complexity of the MCP tool is determined by the direct proportion of resource demand and the direct proportion of average response time. The total complexity is obtained by summing the complexity of all MCP tools in the MCP toolset; Select the MCP toolset with the lowest overall complexity as the optimal output MCP toolset; Intelligent agents are built based on the MCP toolset of optimization output.
[0032] The above content describes the construction process of the intelligent agent. Based on a known toolset, the process of jointly assembling the MCP toolset is not complex. In the technical solution of this invention, due to the existence of hyperlinks, MCP tools with the same input can establish interactive channels and share the same input preprocessing process. Furthermore, for the optimization process of the MCP toolset, the resource requirements and average response time of each MCP tool in the toolset are obtained. The resource requirements include computational requirements and storage requirements, which are inherent attributes of the MCP tools. The MCP toolset is determined based on the proportionality between the resource requirements and the average response time. The higher the resource requirements and the shorter the average response time of a tool, the less suitable the MCP tool is considered, and the higher its complexity. For any MCP toolset containing multiple MCP tools, the complexity of all MCP tools in the toolset is accumulated to obtain the comprehensive complexity. It can be inferred that the more MCP tools there are, the more items are accumulated, and the higher the comprehensive complexity is likely to be (not necessarily). Based on this, the MCP toolset with the lowest comprehensive complexity is selected as the optimal output MCP toolset. The comprehensive complexity represents the overall suitability of each tool in the toolset; the lower the comprehensive complexity, the better the toolset is considered.
[0033] Regarding step S400, the step of inserting a runtime monitoring process into the intelligent agent, verifying the user's identity in real time based on the runtime monitoring process, and synchronously adjusting the execution intensity of the intelligent agent includes: Insert a monitoring process into the intelligent agent to obtain the user's interaction content within a preset time period; The interactive content is converted into text and keywords are extracted to construct a word space; Based on the real-time accumulation of the user's anomaly score in the word space, a verification instruction is generated according to the anomaly score to verify the user's identity. The task quality index is obtained in real time based on the operation monitoring process, and the execution intensity of the intelligent agent is adjusted according to the task quality index; wherein, the application scheme of execution intensity includes: embedding an AI interface in the intelligent agent, and the execution intensity is used to adjust the amount of resources of the AI interface.
[0034] In one example of the technical solution of this invention, the extended function based on the operation monitoring process is limited. The operation monitoring process is inserted into the intelligent agent to obtain the user's interaction content within a preset time period. The time period is a time length, and a time interval can be obtained by taking the current time as the end time. The interaction content is converted into text and keywords are extracted to construct a word space. The word space can be keywords and their frequency of occurrence (or other indicators, such as TF-IDF value). The user's abnormality is accumulated in real time based on the word space. This process can be as follows: obtain the keywords of the user's interaction content within a preset second time period, query the word frequency ratio of the keywords in the word space. If the word frequency ratio is low, it indicates that the user's usage process has changed. After the change, it is possible that the user has initiated a new task or that the user has changed. At this time, an identity verification process can be triggered to ensure the consistency of the intelligent agent's service object. The identity verification process can use conventional verification methods.
[0035] Furthermore, regarding the execution strength of the agent, an interface with a large AI model can be connected to the agent to extend the agent's service quality. However, this obviously requires additional resources. The more resources, the richer the service quality. Based on the real-time acquisition of the task quality index through the operation monitoring process, the task is used to evaluate the agent's "current task execution quality" under the MCP protocol. A feasible solution is to collect real execution data (success rate, response time, feedback rate, context stability) to determine "whether the user continues to pay attention". This determines a quality signal representing the effectiveness of the current task execution, called the task quality coefficient. When the task quality coefficient is higher, indicating better effectiveness of the current task execution, the amount of AI resources introduced can be appropriately reduced. That is, the amount of AI resources introduced is inversely proportional to the task quality coefficient.
[0036] There is a lot of real execution data. In existing interaction scenarios, commonly used indicators include tool call success rate, effective response time ratio, user interaction feedback rate, and context stability. Based on the linear architecture, these are normalized to obtain a parameter, which is the task quality coefficient mentioned above.
[0037] Figure 2 A structural diagram of a lightweight intelligent agent development system based on the MCP protocol is shown. In a preferred embodiment of the technical solution of the present invention, a lightweight intelligent agent development system based on the MCP protocol is also provided, the system 10 comprising: The task splitting module 11 is used to receive the task to be processed input by the user, split the task to be processed into subtasks; wherein the subtasks adopt input and output information pairs; The tool matching module 12 is used to match MCP tools in a preset MCP tool library based on the subtask and generate a preset number of MCP tool sets; The intelligent agent construction module 13 is used to optimize the MCP toolset and construct an intelligent agent based on the optimized MCP toolset output. The operation monitoring module 14 is used to insert an operation monitoring process into the intelligent agent, verify the user's identity in real time based on the operation monitoring process, and synchronously adjust the execution intensity of the intelligent agent.
[0038] Furthermore, the task splitting module 11 includes: The task node positioning unit is used to receive user input of tasks to be processed and to locate task nodes in the tasks to be processed; the types of task nodes include input nodes and output nodes. The relay node marking unit is used to mark a task node as a relay task node when it is both an input node and an output node. The node hierarchy determination unit is used to determine the task chain based on the relay task nodes and simultaneously determine the hierarchy of each task node. The task chain statistics unit is used to compare the input nodes of different task chains, establish hyperlinks between the same input nodes at the same level, and obtain a set of task chains. The task splitting unit is used to split the task to be processed into subtasks based on the task chain set.
[0039] Specifically, the tool matching module 12 includes: The channel establishment unit is used to establish a connection channel with the preset MCP tool library; The matching execution unit is used to randomly read subtasks from the subtask library corresponding to the task chain set, and match MCP tools in the MCP tool library according to their inputs and outputs. The link elimination unit is used to remove the sub-link corresponding to the sub-task from each task chain in the task chain set after a successful match, and to synchronously update the sub-task library corresponding to the task chain set. The first loop unit is used to repeatedly execute the matching execution unit to the link elimination unit until the subtask library is empty, and to count the matched MCP tools. The second loop unit is used to repeatedly execute the matching execution unit up to the first loop unit until a preset number of times is reached, and then output the preset number of MCP tool sets.
[0040] Furthermore, the intelligent agent construction module 13 includes: The tool quantization unit is used to obtain the resource requirements and average response time of each MCP tool in the MCP toolset; the resource requirements include computing requirements and storage requirements. The complexity determination unit is used to determine the complexity of the MCP tool based on the proportionality between resource requirements and average response time. Complexity accumulation unit, used to accumulate the complexity of all MCP tools in the MCP toolset to obtain the comprehensive complexity; The optimization output unit is used to select the MCP toolset with the lowest synthesis complexity as the optimization output MCP toolset. Build execution units for constructing intelligent agents based on the MCP toolset of optimization output.
[0041] In one example of the technical solution of this invention, when a user raises a complex request, the large model controller in the system automatically breaks down the task into a series of sub-task nodes. These nodes can be large model inference steps (e.g., having the large model analyze and summarize information), tool invocation steps (e.g., calling database queries, third-party APIs, etc.), or result integration steps (the large model aggregates multiple tool results to generate an answer). Unlike statically predefined processes, this algorithm supports dynamically determining the granularity and order of decomposition based on the context: it avoids over-segmentation leading to unnecessary overhead, and also avoids coarse merging that misses key steps. The decomposition process considers task dependencies and optimal execution paths. This framework further supports plan adjustments in multi-turn dialogues: during the dialogue, if the user adds new requests, provides new information, or is dissatisfied with intermediate results, the agent can adjust existing task chains in real time. For example, in an intelligent customer service scenario, if a user initially inquires about the product return and exchange process, the agent plans to call the FAQ knowledge base to answer; then, if the user mentions a dispute over contract details, the agent dynamically adds a "contract clause analysis" sub-task node, obtains conclusions by calling the contract review MCP tool, and then integrates the results into the reply. The entire process is automatically completed by the algorithm to expand or modify the task chain without having to replan from scratch, making the agent highly adaptable and robust to multi-turn dialogues.
[0042] Furthermore, semantic planning and retrieval components are introduced to parse and match the description information of registered MCP Servers. When the agent receives a user task, it first retrieves the most suitable set of tools / services for the current task requirements from numerous available MCP Servers through semantic analysis and generates a preliminary solution plan. Each MCP Server pre-discloses its functional description (e.g., what data or operations it provides). The agent uses a large model to semantically match the user's intent with these descriptions, automatically deciding which tools to call and in what order. This semantic planning mechanism enables the agent to dynamically select the most suitable combination of tools to solve new tasks in any domain without manual intervention. When there are thousands of available tools (in fact, thousands of tools shared by developers worldwide can be accessed in real time through the open MCP tool ecosystem), this semantic retrieval and planning capability is particularly important, significantly improving the coverage and matching accuracy of tool utilization.
[0043] In a preferred embodiment of the technical solution of this invention, the above content can also be integrated with the visual orchestration process, providing a very simple adjustment port for the generation process of the intelligent agent. The framework has a built-in MCP protocol adaptation layer, which can easily connect to mainstream large models and external tools. Through plug-in configuration, developers can connect existing large models to the framework as the brain of the intelligent agent, and encapsulate Gaode Map API, enterprise internal system interfaces, etc. as MCP tools to be connected to the toolbox of the intelligent agent. The framework provides a graphical interface for configuring and orchestrating the calling process of these models and tools, realizing the visual process design of "large model + toolchain". For example, developers can configure the process of a travel planning agent by dragging and dropping components, including calling the weather query interface, itinerary route planning service, and restaurant recommendation service, and the large model integrates and outputs the results. Unlike traditional process engines, this framework allows manual configuration to be combined with AI automatic planning: developers can specify necessary nodes or preference strategies in the visual interface, and the remaining process details are automatically completed by the intelligent agent according to semantics. This design takes into account both low-code ease of use and intelligent flexibility. During runtime, the adaptation engine is responsible for converting the requests of the large model into MCP protocol calls to the corresponding tools, and submitting the results returned by the tools to the large model, ensuring that each call conforms to the MCP specification.
[0044] In terms of security, when running the agent service in multi-tenant mode, the data, configuration, and invocation processes of each enterprise tenant are isolated from each other. Access control lists and API key mechanisms ensure that tenants can only invoke MCP services and tools within their authorized scope. For example, even if agents from different customers are deployed in the same framework, their data is stored and transmitted in isolation using tenant IDs, with encrypted transmission to prevent data crosstalk or leakage. The framework also provides a unified permission management console, allowing enterprise administrators to configure available tool sets and invocation frequency limits for each department or application, enabling fine-grained control over agent behavior. All cross-system data interactions are encrypted with SSL / TLS and an optional audit log function records the request and result summary of each MCP tool invocation to meet compliance and regulatory requirements. When executing external tool invocations, the framework filters sensitive information from the returned data to prevent large models from outputting information containing confidential content.
[0045] Furthermore, to ensure that introduced MCP tools do not become system vulnerabilities, this framework integrates a security scanning and health monitoring module for MCP servers. First, when a third-party MCP server is connected to the framework, the system automatically checks its interface specifications and code dependencies, scans for known vulnerabilities (such as security notices for dependent libraries), and verifies whether its response format conforms to the MCP protocol standard. If a high-risk vulnerability or non-compliance is detected, its connection will be blocked and an alert will be issued. Second, during operation, the monitoring module continuously tracks the running status and call behavior of each MCP server, including metrics such as response time, error rate, and returned data size. If an MCP tool exhibits abnormal behavior (such as response data containing malicious scripts), the framework will immediately take measures to isolate the tool and prompt manual intervention. Through pre-defined security policy rules, the intelligent agent provides runtime protection for connected tools, which is particularly important when using open-ecosystem MCP tools. In addition, the system regularly performs security sandbox scans on locally deployed MCP servers to ensure their operating environment is isolated, keys are properly managed, and they do not pose a threat to the host system.
[0046] The above are merely preferred embodiments of the present invention and do not limit the scope of the patent. Any equivalent structural or procedural transformations made based on the description and drawings of the present invention, or direct or indirect applications in other related technical fields, are similarly included within the scope of patent protection of the present invention.
Claims
1. A lightweight agent development method based on the MCP protocol, characterized in that, The method includes: The system receives a task to be processed from user input, and then breaks down the task into subtasks; wherein the subtasks use input and output information pairs. Based on the subtask, match MCP tools in the preset MCP tool library to generate a preset number of MCP tool sets; The MCP toolset is optimized, and an intelligent agent is constructed based on the optimized MCP toolset output. Insert a runtime monitoring process into the agent, verify the user's identity in real time based on the runtime monitoring process, and adjust the execution intensity of the agent synchronously.
2. The lightweight agent development method based on the MCP protocol according to claim 1, characterized in that, The steps of receiving user input for a task to be processed and splitting the task into subtasks include: The system receives user input of pending tasks and locates task nodes within those tasks; the types of task nodes include input nodes and output nodes. When a task node is both an input node and an output node, it is marked as a relay task node. The task chain is determined based on the transit task nodes, and the hierarchy of each task node is determined synchronously. By comparing the input nodes of different task chains, hyperlinks are established between the same input nodes at the same level to obtain a set of task chains. The task to be processed is split into subtasks based on the task chain set.
3. The lightweight agent development method based on the MCP protocol according to claim 2, characterized in that, The step of splitting the task to be processed into subtasks based on the task chain set includes: In the task chain set, inputs and outputs are paired sequentially according to hierarchical order to obtain sub-chains; Obtain the hierarchical span and hierarchical breadth of the sub-link; the hierarchical span is the hierarchical difference between the total input and total output of the sub-link; the hierarchical breadth is the sum of the number of hyperlinks of each input node in the sub-link; Receive user-input filtering conditions, select sub-links based on the filtering conditions, and use the total input to the total output as feature labels to construct sub-tasks.
4. The lightweight agent development method based on the MCP protocol according to claim 1, characterized in that, The step of generating a preset number of MCP toolsets by matching MCP tools based on the subtask in a preset MCP tool library includes: Step S21: Establish a connection channel with the preset MCP tool library; Step S22: Randomly read subtasks from the subtask library corresponding to the task chain set, and match MCP tools in the MCP tool library according to their inputs and outputs; Step S23: After a successful match, remove the sub-chain corresponding to the sub-task from each task chain in the task chain set, and synchronously update the sub-task library corresponding to the task chain set. Step S24: Repeat steps S22 to S23 until the subtask library is empty, and count the matched MCP tools. Step S25: Repeat steps S22 to S24 until a preset number of times is reached, and output the preset number of MCP toolsets.
5. The lightweight agent development method based on the MCP protocol according to claim 1, characterized in that, The steps of optimizing the MCP toolset and constructing an intelligent agent based on the optimized MCP toolset output include: Obtain the resource requirements and average response time for each MCP tool in the MCP toolset; the resource requirements include computational requirements and storage requirements; The complexity of the MCP tool is determined by the direct proportion of resource demand and the direct proportion of average response time. The total complexity is obtained by summing the complexity of all MCP tools in the MCP toolset; Select the MCP toolset with the lowest overall complexity as the optimal output MCP toolset; Intelligent agents are built based on the MCP toolset of optimization output.
6. The lightweight agent development method based on the MCP protocol according to claim 1, characterized in that, The steps of inserting a runtime monitoring process into the intelligent agent, verifying the user's identity in real time based on the runtime monitoring process, and synchronously adjusting the execution intensity of the intelligent agent include: Insert a monitoring process into the intelligent agent to obtain the user's interaction content within a preset time period; The interactive content is converted into text and keywords are extracted to construct a word space; Based on the real-time accumulation of the user's anomaly score in the word space, a verification instruction is generated according to the anomaly score to verify the user's identity. The task quality index is obtained in real time based on the operation monitoring process, and the execution intensity of the intelligent agent is adjusted according to the task quality index; wherein, the application scheme of execution intensity includes: embedding an AI interface in the intelligent agent, and the execution intensity is used to adjust the amount of resources of the AI interface.
7. A lightweight intelligent agent development system based on the MCP protocol, characterized in that, The system includes: The task splitting module is used to receive the task to be processed input by the user, split the task to be processed into subtasks; wherein the subtasks adopt input and output information pairs; The tool matching module is used to match MCP tools based on the subtask in a preset MCP tool library and generate a preset number of MCP tool sets; The agent construction module is used to optimize the MCP toolset and construct an agent based on the optimized MCP toolset output. The operation monitoring module is used to insert operation monitoring processes into the intelligent agent, verify the user's identity in real time based on the operation monitoring processes, and synchronously adjust the execution intensity of the intelligent agent.
8. The lightweight intelligent agent development system based on the MCP protocol according to claim 7, characterized in that, The task splitting module includes: The task node positioning unit is used to receive user input of tasks to be processed and to locate task nodes in the tasks to be processed; the types of task nodes include input nodes and output nodes. The relay node marking unit is used to mark a task node as a relay task node when it is both an input node and an output node. The node hierarchy determination unit is used to determine the task chain based on the relay task nodes and simultaneously determine the hierarchy of each task node. The task chain statistics unit is used to compare the input nodes of different task chains, establish hyperlinks between the same input nodes at the same level, and obtain a set of task chains. The task splitting unit is used to split the task to be processed into subtasks based on the task chain set.
9. The lightweight intelligent agent development system based on the MCP protocol according to claim 7, characterized in that, The tool matching module includes: The channel establishment unit is used to establish a connection channel with the preset MCP tool library; The matching execution unit is used to randomly read subtasks from the subtask library corresponding to the task chain set, and match MCP tools in the MCP tool library according to their inputs and outputs. The link elimination unit is used to remove the sub-link corresponding to the sub-task from each task chain in the task chain set after a successful match, and to synchronously update the sub-task library corresponding to the task chain set. The first loop unit is used to repeatedly execute the matching execution unit to the link elimination unit until the subtask library is empty, and to count the matched MCP tools. The second loop unit is used to repeatedly execute the matching execution unit up to the first loop unit until a preset number of times is reached, and then output the preset number of MCP tool sets.
10. The lightweight intelligent agent development system based on the MCP protocol according to claim 7, characterized in that, The intelligent agent construction module includes: The tool quantization unit is used to obtain the resource requirements and average response time of each MCP tool in the MCP toolset; the resource requirements include computing requirements and storage requirements. The complexity determination unit is used to determine the complexity of the MCP tool based on the proportionality between resource requirements and average response time. Complexity accumulation unit, used to accumulate the complexity of all MCP tools in the MCP toolset to obtain the comprehensive complexity; The optimization output unit is used to select the MCP toolset with the lowest synthesis complexity as the optimization output MCP toolset. Build execution units for constructing intelligent agents based on the MCP toolset of optimization output.
Citation Information
Patent Citations
Generation method and system of task execution engine, electronic equipment and program product
CN120687264A
Intelligent implementation method and device of intelligent operation assistant, equipment and medium
CN120994420A
Dynamic tool discovery and adaptive system construction method oriented to MCP intelligent agent
CN121092241A
Dynamic reasoning chain construction and dependency task arrangement method and device based on MCP intelligent agent
CN121166303A
Intelligent data calling method based on MCP protocol
CN121388077A