An intelligent data calling method based on MCP protocol
By introducing confidence assessment of key entities and intents in data retrieval in the financial field, filtering and sorting subtask execution sequences, and performing semantic-level tool selection, the problem of low execution sequence quality and inaccurate tool retrieval in existing technologies is solved, realizing an efficient and automated data retrieval process.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- 廊坊银行股份有限公司
- Filing Date
- 2025-10-24
- Publication Date
- 2026-05-19
AI Technical Summary
Existing technologies in the financial sector fail to effectively integrate confidence information from the intent and entity recognition stages when calling data, resulting in low execution sequence quality and poor anti-interference capabilities. At the same time, the lack of an intelligent routing mechanism that deeply understands the semantics of the task means that the accuracy and efficiency of tool calls cannot meet the requirements of enterprise-level applications.
By using an intelligent data retrieval method based on the MCP protocol, confidence judgment of key entities and user intent is introduced to filter and sort the execution sequence of subtasks, and the data source tools are accurately selected based on the subtask description, thereby achieving semantic-level tool discovery and retrieval.
It improves the robustness and accuracy of task execution, reduces resource waste, increases the accuracy and flexibility of tool invocation, and realizes a fully automated closed loop from user commands to data query results, significantly improving the overall efficiency of data retrieval and processing.
Smart Images

Figure CN121388077B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of intelligent data retrieval technology, specifically relating to an intelligent data retrieval method based on the MCP protocol. Background Technology
[0002] With the deep integration of artificial intelligence technology into core business areas such as financial risk control and customer assessment, extracting information from massive amounts of multi-source data and generating decision reports through natural language interaction has become a key path to improve business efficiency. In this application context, business personnel expect to be able to drive the system to automatically complete complex data query and analysis tasks in the most natural way possible (e.g., [the system can then]).
[0003] To achieve this goal, existing technologies typically follow a phased processing flow: first, natural language processing techniques are used to identify the intent and extract entities from user requests; then, the identified tasks are assigned to the corresponding data interfaces or tools for execution. However, this traditional paradigm exposes several technical problems that urgently need to be solved when dealing with complex scenarios in the financial sector that require high accuracy and efficiency.
[0004] First, during the task planning phase, the identification results are uncertain due to the ambiguity of natural language and the complexity of financial terminology. Existing solutions typically use all identification results directly for subsequent processing without filtering, sorting, or verifying them based on confidence levels. This approach directly leads to the subsequent execution sequence potentially containing redundant, erroneous, or low-priority subtasks, wasting valuable computational resources and potentially leading to biased final conclusions due to the execution of incorrect tasks.
[0005] Secondly, during the task execution phase, to obtain the required data, the system needs to interface with various heterogeneous data sources, including various vendor APIs, internal databases, document systems, and even real-time data streams. Developing customized interfaces for each data source brings huge development and maintenance costs. Although the emergence of the MCP protocol provides a unified encapsulation standard for data source tools, reducing integration complexity to some extent, how to dynamically and accurately select the most suitable tool for a specific subtask from a large number of encapsulated MCP tools has become a new technical bottleneck.
[0006] In summary, the prominent technical problems of the existing technology are as follows: First, it fails to effectively integrate the confidence information generated in the intent and entity recognition stage into the task planning and decision-making process, resulting in low quality of execution sequence generation and poor anti-interference ability; Second, when faced with numerous data tools based on the MCP protocol, it lacks an intelligent routing mechanism that can deeply understand the semantics of the task, resulting in the accuracy and efficiency of tool invocation failing to meet the requirements of enterprise-level applications. Summary of the Invention
[0007] This invention provides an intelligent data retrieval method based on the MCP protocol to solve one or more of the above-mentioned technical problems.
[0008] The technical solution adopted in this invention is as follows:
[0009] A smart data retrieval method based on the MCP protocol includes:
[0010] In response to a user's natural language request, intent recognition and key entity extraction are performed to obtain multiple user intents and at least one key entity;
[0011] Based on the confidence level of the key entities, a judgment is made to filter user intents according to the confidence level of the user intent, resulting in an execution sequence containing multiple sub-tasks.
[0012] Based on the description of the sub-task, at least one target data source tool is determined from multiple data source tools encapsulated based on the MCP protocol, to perform data query based on the key entity, obtain query results, and generate a final response.
[0013] The intelligent data retrieval method based on the MCP protocol disclosed in this invention also has the following additional technical features:
[0014] The judgment is based on the confidence level of the key entities, specifically as follows:
[0015] Identify the category level of at least one of the key entities.
[0016] The confidence level of at least one of the key entities is adjusted according to the category level, and the adjustment direction is positively correlated with the category level;
[0017] Based on the adjusted confidence level, at least one of the key entities is screened from largest to smallest to determine one of the key entities.
[0018] The judgment based on the confidence level of the key entities also includes:
[0019] When the confidence level of a determined key entity is greater than or equal to the entity confidence threshold, the subsequent execution sequence generation step is executed.
[0020] User intents are filtered based on their confidence level, resulting in an execution sequence containing multiple subtasks, specifically:
[0021] Based on multiple user intents, analyze the dependencies between user intents, and set dependency weights for each dependency according to its dependency level.
[0022] Based on the dependency weights, the confidence level corresponding to the user intent is adjusted;
[0023] Based on the adjusted confidence level, filter multiple user intents from largest to smallest;
[0024] Based on the multiple user intents selected and their dependencies, the user intents that the selected user intents depend on are then selected.
[0025] Based on the selected user intents, multiple sub-tasks are obtained.
[0026] The execution sequence is specifically as follows:
[0027] Based on the adjusted confidence levels, the selected user intents are ranked from highest to lowest.
[0028] Based on the sorting, the dependencies between user intents and subsequent user intents are compared sequentially from the beginning to the end in order to adjust the sorting.
[0029] If no user intent is found that requires reordering, then multiple subtasks are executed in this order.
[0030] Arranging multiple subtasks into an execution sequence in this order also includes:
[0031] When the number of iterations in the dependency comparison loop reaches a certain threshold, and there is still user intent requiring sorting adjustments, then...
[0032] The number of user intent adjustments corresponding to a single dependency comparison loop is counted. Based on the number of user intent adjustments from smallest to largest, an order is determined to form an execution sequence of multiple subtasks.
[0033] If there are multiple dependency comparison loops, and the number of user intent adjustments is minimized, then a sorting order is determined based on the number of dependency comparison loops from smallest to largest to form an execution sequence for multiple subtasks.
[0034] The loop threshold is set based on the confidence level of the key entity and is positively correlated with the confidence level of the key entity.
[0035] Based on the description of the sub-task, at least one target data source tool is determined from multiple data source tools encapsulated based on the MCP protocol, specifically as follows:
[0036] The description of the subtask is converted into a first semantic vector;
[0037] The similarity between the first semantic vector and the second semantic vector corresponding to the descriptions of multiple pre-stored data source tools is obtained;
[0038] Adjustments are made based on the similarity to select the at least one target data source tool from the plurality of data source tools.
[0039] Adjustments are made based on the aforementioned similarity, specifically as follows:
[0040] The similarity is adjusted based on the confidence level corresponding to the user's intent, with the adjustment direction being positively correlated with the confidence level, to obtain a comprehensive similarity.
[0041] When the overall similarity is greater than or equal to the similarity threshold, the corresponding data source tool is selected as the target data source tool.
[0042] The similarity threshold is adjusted based on the confidence level of the key entity and is positively correlated with the confidence level of the key entity.
[0043] The present invention also discloses a computer-readable storage medium having a computer program stored thereon.
[0044] When the computer program is executed by the processor, it implements the intelligent data retrieval method based on the MCP protocol.
[0045] This invention further discloses an electronic device, including a memory and a processor, wherein the memory stores a computer program.
[0046] When the processor executes the computer program, it implements the intelligent data retrieval method based on the MCP protocol.
[0047] Due to the adoption of the above technical solution, the beneficial effects achieved by this invention are as follows:
[0048] 1. This invention establishes a hierarchical, credibility-based decision-making mechanism by introducing a judgment based on the confidence level of key entities as a prerequisite for user intent filtering. This effectively filters out low-quality or invalid intents generated due to natural language ambiguity or model recognition errors, thereby generating a more refined and reliable subtask execution sequence. Traditional processing directly converts all identified intents into tasks, which carries the risk of executing redundant or erroneous tasks. This solution, through confidence level judgment and intent filtering, achieves denoising and focusing of the original recognition results, avoiding the waste of system resources on executing low-credibility task paths, and improving the robustness of the entire task execution process and the accuracy of the final result.
[0049] Furthermore, this method does not use fixed rules or keywords, but rather determines the target data source tool based on the description of the subtask. This means that routing decisions are made based on a semantic understanding of the task itself. A semantic-level tool discovery mechanism is introduced on top of the unified tool interface based on the MCP protocol. This enables the system to understand semantically similar but differently focused subtasks and potentially route them to the most suitable specialized tools, significantly improving the accuracy and flexibility of tool invocation. It can handle complex, varied, and colloquial user needs, overcoming the limitations of rigid routing strategies based on keyword matching in terms of understanding capabilities.
[0050] Moreover, this invention constructs a highly automated and intelligent closed loop from natural language input to final response output. This significantly reduces the need for manual intervention and configuration, achieving fully automated conversion from user commands to data query results. Consequently, it substantially improves the overall efficiency of data retrieval and processing in scenarios such as financial risk control and report generation.
[0051] In summary, improving the reliability of system decision-making, enhancing the intelligence of tool invocation, and automating processes have solved the two major problems of low task planning quality and inaccurate tool invocation. Attached Figure Description
[0052] The accompanying drawings, which are included to provide a further understanding of the invention and form part of this invention, illustrate exemplary embodiments of the invention and are used to explain the invention, but do not constitute an undue limitation of the invention. In the drawings:
[0053] Figure 1 This is a flowchart illustrating the intelligent data retrieval method based on the MCP protocol according to one embodiment of the present invention. Detailed Implementation
[0054] To more clearly illustrate the overall concept of the present invention, a detailed description will be provided below with reference to the accompanying drawings and examples.
[0055] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and therefore the scope of protection of the invention is not limited to the specific embodiments disclosed below.
[0056] like Figure 1 As shown, a smart data retrieval method based on the MCP protocol includes:
[0057] S100: In response to a user's natural language request, perform intent recognition and key entity extraction to obtain multiple user intents and at least one key entity.
[0058] This step is the starting point and foundation of the entire intelligent data retrieval process. Its main purpose is to accurately transform the user's unstructured and ambiguous natural language requests into explicit signals that the computer system can understand and process in a structured way. Specifically, its objectives include:
[0059] Understand the core objective (intent) of user commands and analyze what the user wants to do, such as querying data, generating reports, or sending emails;
[0060] Lock down the specific object (key entity) of the command operation, identify the core operation object and information elements involved in the command, such as the specific company name, the data dimensions to be queried (such as business registration information, risk information), and the target email address, etc.
[0061] It provides raw data for subsequent confidence-based decision-making, not only outputting the identified intents and entities themselves, but also assigning them initial confidence scores, providing crucial decision-making basis for subsequent steps of screening, sorting and optimization.
[0062] This step relies on the powerful natural language understanding capabilities of the large language model. Specifically, the natural language understanding process receives the user's input natural language request text (e.g., "Please search for the business registration information, operational information, and risk data of company XX, and generate an assessment report to be sent to the specified email address"). The pre-trained large language model is then invoked to perform deep semantic analysis and understanding of the input text. This model has been trained on massive amounts of text and domain-specific (e.g., finance) corpora, possessing strong generalization capabilities.
[0063] Parallel recognition and extraction: Based on the above understanding, the system executes two core tasks in parallel: intent recognition and intent extraction. The model analyzes the main idea of the user request and identifies one or more user intents contained within it. For example, from the example above, three clear user intents can be parsed: data acquisition (corresponding to searching for information), report generation (corresponding to generating an evaluation report), and email sending (corresponding to sending to an email address). Each identified intent is assigned a confidence score, which reflects the probability that the model correctly identifies that intent.
[0064] Key entity extraction involves the model simultaneously extracting key information entities from the text necessary to execute the aforementioned intent. For example, from the sample, the following can be extracted: {Entity Type: Company Name, Entity Value: XX Company}, {Entity Type: Data Dimension, Entity Value: Business Registration Information}, {Entity Type: Data Dimension, Entity Value: Operating Information}, {Entity Type: Data Dimension, Entity Value: Risk Data}, {Entity Type: Task Output, Entity Value: Assessment Report}, {Entity Type: Contact Information, Entity Value: Specified Email Address}. Similarly, each extracted entity is accompanied by a confidence score.
[0065] The identified and extracted results are then structured and encapsulated into a clear, machine-readable data object, which serves as the output of this step. This object typically contains a list of user intents and a list of key entities. Each intent in the user intent list includes a name and a confidence level. Each entity in the key entity list includes a type, a value, and a confidence level.
[0066] By leveraging large language models for deep semantic analysis, this step effectively understands users' colloquial and diverse expressions, overcoming the shortcomings of traditional rule-based or simple keyword matching methods, such as poor flexibility and susceptibility to misjudgment. The design of outputting multiple intents and entities objectively reflects the complexity of natural language, which often involves multiple tasks, providing complete material for subsequent task decomposition. The accompanying confidence information honestly reflects the uncertainty of the recognition process, providing the system with crucial risk signals. This enables downstream processes to perceive potential errors and proactively take countermeasures, thereby significantly improving the system's fault tolerance and the reliability of the final output when facing ambiguous or unclear requests.
[0067] S200: Based on the confidence level of the key entity, a judgment is made to filter user intent according to the confidence level of the user intent, and an execution sequence containing multiple sub-tasks is obtained.
[0068] This step is a crucial intelligent decision-making stage connecting natural language understanding and task execution. Its main purpose is to transform the potentially uncertain original recognition results into a high-quality, efficient, and executable sequence of subtasks by introducing a multi-level screening and optimization mechanism based on confidence levels. Specific objectives include:
[0069] Reliability assurance utilizes confidence information of key entities and user intents to filter out low-confidence, potentially erroneous intents and entities, ensuring that the execution sequence is built on a reliable data foundation;
[0070] Task sequence optimization comprehensively considers the logical dependencies and confidence levels between intentions to plan a reasonable task execution order, avoiding execution failures or resource waste caused by improper task order.
[0071] Resource efficiency is improved by filtering out redundant or secondary tasks, allowing the system's computing resources to be concentrated on processing high-value, highly deterministic core tasks, thereby improving overall processing efficiency.
[0072] This step is implemented as a dynamic, rule-based decision-making process, the core of which lies in using confidence information for layer-by-layer filtering and ranking. Based on the preliminary judgment of the confidence level of key entities (such as company names), these key entities are the foundation for executing almost all tasks. This judgment aims to ensure that subsequent task planning is built upon a highly credible core operational object.
[0073] Furthermore, based on a comprehensive screening process using user intent confidence and dependencies, core intents worthy of execution are selected from multiple identified intents, and the logical relationships between them are clarified. The selected user intents are mapped to specific subtasks (e.g., mapping the "data acquisition" intent to the "execute enterprise data query" subtask), generating a candidate subtask set. Dynamic programming of the execution sequence arranges the selected subtasks into an optimal or near-optimal execution order.
[0074] This step, through a series of sophisticated, confidence-based judgment, filtering, and planning strategies, successfully transforms a preliminary, uncertain natural language recognition result into a reliable, efficient, and executable action plan. By filtering out low-confidence intents, the system avoids consuming unnecessary computing resources and external service call costs for erroneous or minor tasks, significantly improving task execution efficiency and success rate. Dependency-based sequence optimization ensures the smooth and logical execution of the task chain, preventing subsequent tasks from failing or being blocked due to incomplete preceding tasks, thereby improving the overall success rate of complex tasks.
[0075] S300: Based on the description of the subtask, determine at least one target data source tool from multiple data source tools encapsulated based on the MCP protocol, to perform data query based on the key entity, obtain query results, and generate a final response.
[0076] This step is the core of the entire method's technical implementation and value realization. Its main purpose is to transform the planned high-quality execution sequence into actual calls to specific data source tools in an intelligent, precise, and automated manner, and to integrate the return results of each tool to ultimately satisfy the user's original request. Specific objectives include:
[0077] It enables intelligent routing of tool calls, breaking through the limitations of traditional fixed mapping or keyword matching. Based on a deep understanding of the semantics of subtasks, it dynamically selects the most suitable tool from a massive number of MCP tools.
[0078] Perform efficient and accurate data queries, using pre-determined high-confidence key entities as precise parameters to drive the target tool to complete data acquisition;
[0079] Complete the end-to-end automated closed loop, integrate and reprocess the results of scattered tool calls, and generate the final response that users can directly use (such as structured data, analysis reports, etc.).
[0080] This step relies on the standard interface of the MCP protocol and semantic retrieval technology. Based on semantic understanding, tool discovery and matching finds one or more data source tools that are functionally most suitable for the current subtask. A candidate tool list is generated, and a list of the most relevant candidate tools (e.g., Top 5) is returned. Each candidate tool is accompanied by a similarity score, which quantifies its degree of matching with the current subtask.
[0081] The process involves identifying and invoking the target data source tool, determining the final tool from the candidate list, and executing the query. Tool selection can be based on preset strategies, such as directly choosing the tool with the highest similarity, or weighted selection based on factors like historical performance and cost.
[0082] The standardized invocation process involves identifying the target tool and then initiating an invocation request to the corresponding MCP Server via the standard MCP protocol. This process encapsulates the underlying communication details, simplifying integration. During the invocation, key entities (such as company names) are passed as input parameters.
[0083] Results retrieval: After executing the query, the MCP Server returns structured query results via the MCP protocol.
[0084] Result integration and final response generation combine the execution results of all subtasks into a coherent and complete final output. Result accumulation and association complete the subtasks one by one according to the execution sequence, and temporarily store the query results of each task. They are then associated through key entities (such as enterprise IDs) to form a complete data context.
[0085] Intelligent synthesis, once all data is ready, leverages the generative capabilities of the large language model to integrate, analyze, and refine the scattered data according to the user's initial intent (such as generating an assessment report), synthesizing the final response. For example, it can generate a PDF document titled "Enterprise Customer Qualification Review Report" containing multi-dimensional analysis of enterprise registration, operations, and risks, or directly execute an email sending task.
[0086] Output delivery presents the final response to the user or delivers it to a designated location (such as sending it to an email address), completing the entire request processing loop.
[0087] This step fully encapsulates the complexity of heterogeneous data sources through the MCP protocol, achieving standardized tool access, solving the core pain point of custom integration development for each service, significantly reducing development and maintenance costs, and simplifying integration.
[0088] Tool routing is achieved through a semantic matching mechanism based on the descriptions of the subtasks, solving the challenge of accurately selecting from a large number of tools. This method possesses powerful semantic understanding capabilities, enabling it to handle the ambiguity and diversity of natural language and ensuring high accuracy in tool invocation. It results in reduced cognitive load (compressing the candidate toolset through semantic search), significantly reduced token consumption (eliminating the need to load all tool descriptions in prompts), and improved invocation accuracy (based on semantic understanding rather than keywords).
[0089] In a preferred embodiment of the present invention, the judgment is based on the confidence level of the key entity, specifically as follows:
[0090] Identify the category level of at least one of the key entities.
[0091] The confidence level of at least one of the key entities is adjusted according to the category level, and the adjustment direction is positively correlated with the category level;
[0092] Based on the adjusted confidence level, at least one of the key entities is screened from largest to smallest to determine one of the key entities.
[0093] This preferred embodiment aims to refine and context-specifically weight and filter the confidence levels of the original key entities by introducing the entity category level dimension. Its core objective is to address the challenge of accurately identifying and locking in the most critical and reliable entity as the benchmark for subsequent task execution in complex natural language requests when multiple key entities exist, thereby preventing the entire task chain from deviating from the correct direction due to improper entity selection.
[0094] The implementation of this preferred solution is a decision-making process based on predefined knowledge and dynamic calculation. The identification and definition of key entity category levels assign different importance weights to different entity types, reflecting their core value in specific business scenarios (such as financial risk control).
[0095] The system pre-configures or dynamically loads an entity category hierarchy mapping table based on the scenario at runtime. This mapping table is built based on domain knowledge and defines the relative importance of different entity types in the task. For example, in a business qualification assessment scenario:
[0096] High-level core entities include the company name and unified social credit code. These entities are absolutely crucial to the task; a mistake in one could lead to complete failure. Their category-level weight (e.g., set to 1.5) is the highest.
[0097] Medium-level important entities, with data dimensions (such as business registration information, risk information) and time range. These entities define the specific content of the task, and their category level weight (e.g., set to 1.2) is medium.
[0098] Basic-level auxiliary entities include email addresses and report formats. These entities typically affect the output delivery format rather than the core query logic, and their category-level weight (e.g., set to 1.0) is the lowest, meaning they are not adjusted.
[0099] The confidence score is dynamically adjusted based on the category level, which combines the objective importance of an entity (category level) with its original credibility (confidence score) to obtain a more comprehensive confidence score that better reflects its actual value in the current task.
[0100] For each identified key entity, the system performs the following calculation: Adjusted confidence score = Original confidence score × Category rank weight. The adjustment direction is positively correlated with the category rank, which means that the more important an entity is (the higher its category rank), the greater its weight, and the more significant the amplification (or reduction) effect on the original confidence score.
[0101] Specifically, suppose the system identifies two entities: Entity A, {Type: Company Name, Value: XX Company, Original Confidence: 0.90}; Entity B, {Type: Email Address, Value: xxx@email.com, Original Confidence: 0.95}.
[0102] Calculate the adjusted confidence levels: Entity A (high level), 0.90 × 1.5 = 1.35; Entity B (basic level): 0.95 × 1.0 = 0.95.
[0103] After adjustment, although the original confidence level of entity B is higher, the adjusted confidence level of entity A (1.35) is much higher than that of entity B (0.95) due to its central position.
[0104] Based on the core entity selection using adjusted confidence levels, the most reliable and core entity is determined from multiple entities to serve as the primary key or anchor point for subsequent task flows. The system sorts all key entities in descending order (from largest to smallest) according to their adjusted confidence levels. Then, the entity ranked first is selected as the core key entity upon which this round of task execution depends. In the example above, the system will lock "Company Name: XX Company" as the core entity, and all subsequent data query tasks will revolve around this entity.
[0105] This preferred implementation overcomes the limitations of simply relying on model output confidence levels. An email address might be identified by the model with extremely high confidence, but its business importance is far lower than that of a company name with slightly lower confidence. By introducing category-level weights and integrating domain knowledge into the decision-making system, it ensures that the selected entities are not only credible at the identification level but also important and reliable at the business logic level. This significantly improves the accuracy of task-anchored entities, effectively prevents the system from losing focus due to entity information overload, greatly reduces the risk of the entire task chain failing due to errors in core entities, and ensures clear priorities and logical consistency in task execution.
[0106] As a preferred embodiment of this implementation, the judgment based on the confidence level of the key entity further includes:
[0107] When the confidence level of a determined key entity is greater than or equal to the entity confidence threshold, the subsequent execution sequence generation step is executed.
[0108] This preferred embodiment introduces a final quality control checkpoint based on the identified core critical entities. Its main purpose is to establish a clear and quantifiable safety execution standard, ensuring that the system only allocates resources to execute subsequent complex task sequences when the reliability of the core entities reaches a minimum acceptable level. This effectively prevents the system from performing invalid or erroneous subsequent operations when the foundation is not solid.
[0109] The implementation of this embodiment is a threshold-based binary decision process. The entity confidence threshold is set to establish a minimum confidence standard for allowing execution. Any of the following embodiments can be used, and there are no further restrictions.
[0110] Example 1: Static threshold. The system presets a global or scenario-based fixed threshold (e.g., 0.85). This value is set based on historical data analysis and experience, representing the minimum confidence level that can reliably support subsequent tasks.
[0111] Example 2: Dynamic threshold. The threshold is not fixed but dynamically adjusted based on the criticality of the task, potential risks, or inherent uncertainties of the data source. For example, when generating an internal reference report, the threshold can be set to 0.75; while when generating a formal report for credit approval, due to extremely high compliance requirements, the threshold can be increased to 0.95.
[0112] The confidence level comparison and decision execution process compares the adjusted confidence level of the selected core entities with the threshold and makes a final decision. It obtains the identified key entity and its adjusted confidence level from the previous steps. This adjusted confidence level is then compared with a preset entity confidence threshold.
[0113] If the adjusted confidence level is greater than or equal to the threshold, the core entity is deemed sufficiently reliable, and the process continues with the subsequent execution sequence generation steps. This marks the system's formal entry into the task planning phase. If the adjusted confidence level is less than the threshold, the system determines the risk is too high, suspends or terminates the current automated process, and triggers an alternative processing mechanism.
[0114] It should be noted that the alternative processing mechanism provides a proper solution when the core entity's credibility is insufficient, rather than simply reporting an error.
[0115] By initiating user clarification, the system can ask users interactive questions, such as, "Are you looking for 'XX Technology Co., Ltd.'? Its recognition reliability is low. Please confirm or re-enter." This utilizes human judgment to compensate for the uncertainty of AI.
[0116] By initiating multi-source verification, the system can call additional, lower-cost verification tools (such as a lightweight business information verification MCP service) to quickly verify the entity, and then decide whether to continue based on the verification results.
[0117] Record and report: Log this low-confidence event and may notify the system administrator for subsequent model optimization and problem analysis.
[0118] This preferred embodiment acts as an automated quality inspector, ensuring that the core data flowing into the downstream task planning and execution stages is of high quality. This fundamentally reduces the risk of wasted effort or even erroneous conclusions throughout the task chain due to errors in the source data, which is crucial for high-risk, high-compliance applications such as finance. Furthermore, it avoids wasting valuable computing resources and API call quotas when the foundation is weak, achieving refined cost management.
[0119] In a preferred embodiment of the present invention, user intent is filtered based on the confidence level of the user intent to obtain an execution sequence containing multiple sub-tasks, specifically as follows:
[0120] Based on multiple user intents, analyze the dependencies between user intents, and set dependency weights for each dependency according to its dependency level.
[0121] Based on the dependency weights, the confidence level corresponding to the user intent is adjusted;
[0122] Based on the adjusted confidence level, filter multiple user intents from largest to smallest;
[0123] Based on the multiple user intents selected and their dependencies, the user intents that the selected user intents depend on are then selected.
[0124] Based on the selected user intents, multiple sub-tasks are obtained.
[0125] This preferred embodiment aims to solve the core problem of intelligently constructing a logically correct, structurally complete, and efficiently executed task sequence from multiple identified user intents. Its purpose is not only to filter intents based on confidence levels, but also to identify and maintain the inherent logical dependencies between intents, ensuring that the final generated execution sequence contains all necessary tasks and is arranged in a reasonable order, thereby guaranteeing that complex tasks can be executed smoothly and correctly.
[0126] The implementation of this preferred solution is a refined process that combines graph theory and confidence assessment, user intent dependency analysis and weight setting, and formally describes the logical connections and execution order between different intents.
[0127] Based on a predefined domain knowledge base or runtime analysis, construct an intent dependency graph. In this directed graph, nodes represent user intents, and edges represent dependencies (e.g., intent A must be executed before intent B).
[0128] For each user intent, the system calculates or sets a comprehensive dependency weight based on the dependency levels of all its incoming edges (i.e., the dependencies of other intents on it). The dependency level is set according to the dependency order and / or the number of dependencies in the dependency path. It should be noted that the closer to the dependency source and the higher the number of dependencies in the dependency path, the higher the dependency level.
[0129] Based on dependency weights, confidence co-adjustment incorporates the structural importance of the intent within the task logic network into its confidence evaluation. For each user intent, the system performs the following calculation:
[0130] Adjusted confidence level = original confidence level × dependency weight;
[0131] An intent that is relied upon by multiple high-level intents (i.e., a key intent at the beginning of a task chain) will have its adjusted confidence significantly increased, even if its original confidence is moderate. This ensures that these fundamental intents on the critical path are not overlooked in subsequent screening.
[0132] By employing a dual screening process that considers both confidence level and dependency integrity, a complete set of intents is obtained that includes both high-confidence core intents and all necessary preceding intents. The first round of screening is based on adjusted confidence levels. The system sorts all user intents in descending order of their adjusted confidence levels and sets a threshold to filter out the top-ranked high-confidence intent set, Set_A. This step primarily ensures the quality of the intents within the sequence.
[0133] The second round of filtering involves dependency completion. The system iterates through each intent in Set_A, checking all its strongly dependent parent intents (i.e., the prerequisite intents necessary for its execution). If a parent intent is not in Set_A, it is added to a completion set Set_B. This step ensures the logical integrity of the execution sequence and avoids execution failures due to the absence of critical prerequisite tasks.
[0134] Generate the final intent set by taking the union of Set_A and Set_B to obtain the final intent set Set_Final. This set contains both high-value intents and all necessary supporting intents.
[0135] Subtask mapping transforms the selected final set of user intents into executable operation units. The system maps each user intent in `Set_Final` to a specific subtask according to predefined mapping rules. For example, user intent data acquisition is mapped to the subtask of performing multi-dimensional enterprise data queries, and report generation is mapped to calling the report generation engine. These subtasks then form a candidate pool for subsequent execution sequence ranking.
[0136] This optimized approach proactively identifies and adds crucial prerequisite tasks that may have been overlooked through dependency analysis and dependency completion filtering. This fundamentally prevents execution errors or incomplete results caused by broken task chains, which is essential for complex, multi-step, and highly dependent tasks such as generating credit reports, ensuring the effectiveness of the final output.
[0137] Furthermore, by introducing dependency weights to collaboratively adjust confidence levels, task planning focuses not only on the accuracy of intent identification but also on its criticality within the overall task logic. This shifts decision-making from local optima to global optima, significantly increasing the probability of tasks on the core path being correctly preserved and prioritized.
[0138] Compared to schemes that simply retain all identified intents, this scheme avoids redundant and low-confidence tasks by using confidence-based filtering, thus saving resources. Compared to schemes that rely solely on confidence-based filtering, this scheme avoids subsequent task failures due to missing prerequisite tasks by using dependency completion, thus preventing the waste of invested resources. The combination of these two approaches achieves efficient utilization of system resources in both the areas of false positives and true negatives.
[0139] As a preferred embodiment of this implementation, the execution sequence is specifically as follows:
[0140] Based on the adjusted confidence levels, the selected user intents are ranked from highest to lowest.
[0141] Based on the sorting, the dependencies between user intents and subsequent user intents are compared sequentially from the beginning to the end in order to adjust the sorting.
[0142] If no user intent is found that requires reordering, then multiple subtasks are executed in this order.
[0143] This preferred embodiment aims to address the key issue of how to transform a selected set of user intents into an executable task sequence. Its core objective is to generate an optimal or near-optimal task execution order while balancing execution efficiency (prioritizing high-confidence tasks) and logical correctness (satisfying inter-task dependency constraints), thereby ensuring that the entire process runs efficiently and smoothly, and avoiding execution blockages or errors caused by improper task order.
[0144] The implementation of this embodiment is a dynamic, iterative sorting optimization process, which generates an initial sequence based on the adjusted confidence of the initial sequence, prioritizing task quality and determinism.
[0145] Obtain the set of user intents filtered through the aforementioned steps, where each intent is accompanied by an adjusted confidence score (which combines its original confidence score and dependency weights). Based on this confidence score, sort these intents in descending order (from largest to smallest) to form an initial intent sequence List_Initial.
[0146] This ensures that the system prioritizes the execution of the most certain and critical tasks, which aligns with the principle of optimal efficiency and allows for the rapid completion of high-quality tasks in the early stages.
[0147] This dependency-based sequence verification and dynamic adjustment performs logical correctness checks on the initial sequence and corrects the order according to dependencies. An iterative traversal and comparison mechanism is employed. Starting with the first intent in List_Initial (denoted as Intent_i), its dependencies are compared with each subsequent intent in the sequence (denoted as Intent_j).
[0148] Dependency check: Query the predefined dependency graph to determine whether Intent_j is a prerequisite of Intent_i (i.e., the execution of Intent_i requires the result of Intent_j).
[0149] The sorting adjustment is triggered and executed when, if it is found that Intent_j is a prerequisite of Intent_i, it means that the current order (Intent_i before Intent_j) is logically incorrect. In this case, the system will automatically adjust the sequence, moving Intent_j, which is a prerequisite, to a position before Intent_i.
[0150] The sequence stability is determined and the final output is given, confirming that the current sequence satisfies all dependencies and outputting the final result. After completing a full round of traversal and adjustment, a stability check is performed, that is, checking whether any sorting adjustments were made in this round of traversal.
[0151] When the system completes a full iteration and finds no user intents requiring reordering, it determines that the current sequence is stable and all dependencies have been satisfied. At this point, the stable intent sequence List_Final is used as the final execution sequence. Each intent in this sequence is mapped to a specific subtask, forming an executable and logically correct subtask execution sequence.
[0152] This preferred embodiment eliminates runtime failures caused by incorrect task order (e.g., attempting to generate a report before data is retrieved) through automated dependency checks and order adjustments. This significantly reduces the risk of abnormal process interruptions, enabling the entire system to stably and reliably handle complex natural language user requests, thus improving the end-user experience and trust.
[0153] As another embodiment of this implementation, forming an execution sequence of multiple subtasks in this order further includes:
[0154] When the number of iterations in the dependency comparison loop reaches a certain threshold, and there is still user intent requiring sorting adjustments, then...
[0155] The number of user intent adjustments corresponding to a single dependency comparison loop is counted. Based on the number of user intent adjustments from smallest to largest, an order is determined to form an execution sequence of multiple subtasks.
[0156] If there are multiple dependency comparison loops, and the number of user intent adjustments is minimized, then a sorting order is determined based on the number of dependency comparison loops from smallest to largest to form an execution sequence for multiple subtasks.
[0157] The loop threshold is set based on the confidence level of the key entity and is positively correlated with the confidence level of the key entity.
[0158] This embodiment aims to address the challenging issue of circular or complex dependencies that may arise in task sequence planning, providing the system with a reliable exception handling and degradation strategy. Its main objective is to intelligently select an optimal approximate solution when the system cannot obtain a completely stable task sequence through conventional iterative adjustments. This ensures that the task flow can continue to execute, rather than falling into an infinite loop or directly reporting an error, thereby guaranteeing the robustness and availability of the entire system.
[0159] This embodiment is a safety boundary and optimization supplement to the aforementioned sequence generation process, identifying complex dependency scenarios that cannot be solved by conventional methods, and terminating endless loop attempts in a timely manner.
[0160] The system sets a loop threshold to limit the maximum number of adjustments. After each round of dependency comparison loops, the system checks the number of loops. Once the number of loops reaches or exceeds the threshold, and the system detects that there is still user intent that needs adjustment in the current round, it determines that the current sequence has complex dependencies that are difficult to resolve using conventional methods, immediately breaks out of the loop, and initiates the degradation strategy of this embodiment.
[0161] The intelligent setting of dynamic loop thresholds links the system's fault tolerance and computational input to the initial reliability of the task. The loop threshold is positively correlated with the confidence level of critical entities; at the start of the process, the system dynamically sets the loop threshold based on the adjusted confidence levels of the identified core critical entities.
[0162] Cyclic threshold = base threshold + (key entity confidence score × scaling factor).
[0163] When the confidence level of core entities is high, it means the task foundation is reliable, and the system is willing to invest more computing resources to try to streamline complex task dependencies, thus setting a higher loop threshold. Conversely, when the confidence level of core entities is low, the task itself has high uncertainty, and the system will adopt a more conservative strategy, quickly enabling degradation schemes to avoid wasting resources.
[0164] From the historical records of multiple iterations, the system selects the optimal approximate sequence as the final solution. The primary evaluation metric is sequence stability (minimum number of adjustments). The system traces all iterations before reaching the iteration threshold, counting the number of user intentions to make sorting adjustments in each iteration. The system selects the sequence generated after the iteration with the fewest user intention adjustments. Fewer adjustments indicate a sequence closer to a stable state and fewer internal dependency conflicts.
[0165] The second evaluation metric is convergence speed (minimum number of iterations). When multiple iterations have the same number of adjustments and all are at the minimum (for example, only one intention is adjusted in the 2nd and 4th iterations), the system selects the sequence that appears earlier (i.e., has fewer iterations) according to the principle of starting with the smallest number of iterations in the dependency comparison iterations.
[0166] This reflects the principle of early convergence. A sequence that can reach a more stable state faster may have a better internal structure and is therefore preferred.
[0167] This embodiment effectively prevents the system from getting stuck in an infinite loop or crashing completely due to complex or even circular task dependencies. It ensures that the system can produce an executable plan under any circumstances, greatly improving the system's ability to handle complex, ambiguous, or atypical user requests, which is an indispensable feature for productization.
[0168] In a preferred embodiment of the present invention, based on the description of the sub-task, at least one target data source tool is determined from a plurality of data source tools encapsulated based on the MCP protocol, specifically as follows:
[0169] The description of the subtask is converted into a first semantic vector;
[0170] The similarity between the first semantic vector and the second semantic vector corresponding to the descriptions of multiple pre-stored data source tools is obtained;
[0171] Adjustments are made based on the similarity to select the at least one target data source tool from the plurality of data source tools.
[0172] This preferred embodiment aims to address the core issue of how to intelligently and accurately select the most suitable tool for performing the current subtask from a large number of MCP tools. Its main objective is to overcome the limitations of traditional keyword-based or fixed-rule matching, achieving optimal matching between task requirements and tool capabilities through deep semantic understanding. This ensures the accuracy and efficiency of data retrieval, fully leveraging the technical advantages of standardized access via the MCP protocol.
[0173] The implementation of this preferred scheme is based on vector embedding technology and similarity calculation, which converts the subtask description and tool description into numerical forms that computers can directly compare mathematically.
[0174] The first semantic vector is generated when a subtask needs to be processed (such as "obtaining enterprise business registration information"). The system calls a vector embedding engine (such as text-embedding-3-small, bge-m3, etc.) to convert the natural language description of the subtask into a high-dimensional, dense numerical vector, i.e., the first semantic vector. The position of this vector in mathematical space represents the semantic connotation of the task.
[0175] The second semantic vector is pre-stored. During the system initialization or tool registration phase, the functional description text of all data source tools based on the MCP protocol (such as "provide enterprise business registration information query service") has been converted into a second semantic vector through the same vector embedding engine and stored in a vector database (such as the PostgreSQL + pgvector scheme) and an efficient index has been built.
[0176] Semantic similarity calculation and matching quantifies the semantic relevance between subtasks and various tools in vector space.
[0177] The system uses the generated first semantic vector as the query condition and performs an approximate nearest neighbor search in the vector database. By calculating the cosine similarity or other distance metric between the first semantic vector and each second semantic vector in the database, a similarity score between 0 and 1 is obtained. This score objectively reflects the degree of semantic matching between the subtask description and the tool's functional description.
[0178] Tool selection based on similarity involves adjusting the similarity score to make a final tool selection decision. Specifically, the adjustment is based on the similarity score as follows:
[0179] The similarity is adjusted based on the confidence level corresponding to the user's intent, with the adjustment direction being positively correlated with the confidence level, to obtain a comprehensive similarity.
[0180] When the overall similarity is greater than or equal to the similarity threshold, the corresponding data source tool is selected as the target data source tool.
[0181] The similarity threshold is adjusted based on the confidence level of the key entity and is positively correlated with the confidence level of the key entity.
[0182] This embodiment aims to establish a multi-level, adaptive tool selection and optimization mechanism. Its core purpose is to effectively transmit and apply the credibility assessment (user intent confidence, key entity confidence) generated in the task planning stage to the tool selection stage, forming a coherent and mutually reinforcing intelligent decision-making chain, thereby achieving dynamic and refined adjustment of tool matching results and further improving the accuracy and reliability of data retrieval.
[0183] This embodiment optimizes the tool selection process by introducing two types of confidence levels: similarity optimization based on user intent confidence level and using the certainty of the sub-task itself as a weighting factor for the reliability of tool matching.
[0184] The system obtains two key inputs: the original similarity obtained through semantic calculation (representing the semantic matching degree between the tool and the task), and the confidence level corresponding to the user's intent in generating the subtask (representing the reliability of the task itself).
[0185] The system performs the following calculation: Overall similarity = Original similarity × (1 + α × User intent confidence), where α is an adjustment coefficient used to control the degree of influence of intent confidence.
[0186] The higher the confidence level of a user's intent (the more certain they are that the task needs to be performed), the stronger its amplification effect on the original similarity score. This makes tools matched for highly certain tasks have a more advantageous overall similarity score and are given higher priority in the selection process. Conversely, for intents with low confidence, even if the semantic matching degree is high, their overall score will be appropriately suppressed, reflecting the prudence of the system's decision-making.
[0187] Furthermore, dynamic threshold gating based on the confidence level of key entities allows the tool's screening criteria to dynamically change according to the reliability of the task's foundation. Instead of using a fixed threshold, the similarity threshold is dynamically calculated based on the confidence level of the core key entities. For example, similarity threshold = base threshold + β × key entity confidence level, where β is an adjustment coefficient to ensure that the threshold varies within a reasonable range.
[0188] The higher the confidence level of a key entity (the more certain it is that the target object is correct), the higher the similarity threshold set by the system. This means that the system has stricter requirements for the quality of tool matching, matching only the top-tier and most relevant tools for tasks with high certainty. When the confidence level of a key entity is low, the system will appropriately relax the threshold, allowing for the matching of relatively broad tools, to avoid failing to find any usable tools due to overly strict requirements, reflecting the flexibility of the system.
[0189] The optimized metrics are applied to perform the final screening. The calculated overall similarity is compared with a dynamically set similarity threshold. Only when the overall similarity is greater than or equal to the similarity threshold will the corresponding data source tool be selected as the target data source tool.
[0190] This embodiment achieves a context-aware and refined intelligent routing mechanism by deeply integrating upstream and downstream confidence information into the core parameters of the tool's filtering.
[0191] The present invention also provides a computer-readable storage medium having a computer program stored thereon.
[0192] When the computer program is executed by the processor, it implements the intelligent data retrieval method based on the MCP protocol.
[0193] Therefore, it can achieve any effect in the intelligent data retrieval method based on the MCP protocol, which will not be elaborated here.
[0194] The present invention further provides an electronic device, including a memory and a processor, wherein the memory stores a computer program.
[0195] When the processor executes the computer program, it implements the intelligent data retrieval method based on the MCP protocol.
[0196] Therefore, it can achieve any effect in the intelligent data retrieval method based on the MCP protocol, which will not be elaborated here.
[0197] For any parts not mentioned in this invention, existing technologies can be used or referenced.
[0198] The various embodiments in this specification are described in a progressive manner. The same or similar parts between the various embodiments can be referred to each other. Each embodiment focuses on describing the differences from other embodiments.
[0199] The above description is merely an embodiment of the present invention and is not intended to limit the invention. Various modifications and variations can be made to the present invention by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principle of the present invention should be included within the scope of the claims of the present invention.
Claims
1. A smart data retrieval method based on the MCP protocol, characterized in that, include: In response to a user's natural language request, intent recognition and key entity extraction are performed to obtain multiple user intents and at least one key entity; The judgment based on the confidence level of the key entity specifically includes identifying the category level of the key entity, adjusting the confidence level of the key entity according to the category level, and the adjustment direction being positively correlated with the category level; A key entity is identified based on the adjusted confidence level; when the adjusted confidence level corresponding to the key entity is greater than or equal to the entity confidence threshold, the subsequent sequence generation steps are executed. Based on multiple user intents, analyze the dependencies between user intents, and set dependency weights for each dependency according to its dependency level; then adjust the confidence level corresponding to each user intent based on the dependency weights. User intents are filtered based on the confidence level adjusted according to user intents, resulting in an execution sequence containing multiple sub-tasks; Based on the description of the subtask, at least one target data source tool is determined from multiple data source tools encapsulated based on the MCP protocol. Specifically, this includes converting the description of the subtask into a first semantic vector, obtaining the similarity between the first semantic vector and the second semantic vectors corresponding to the descriptions of the multiple pre-stored data source tools; adjusting the similarity based on the confidence level corresponding to the user intent, with the adjustment direction being positively correlated with the confidence level, to obtain a comprehensive similarity; when the comprehensive similarity is greater than or equal to a similarity threshold, selecting the corresponding data source tool as the target data source tool, wherein the similarity threshold is adjusted based on the confidence level of the key entity and is positively correlated with the confidence level of the key entity. Based on the key entities, data queries are performed to obtain query results and generate a final response.
2. The intelligent data retrieval method based on the MCP protocol according to claim 1, characterized in that, Based on the adjusted confidence level, at least one of the key entities is screened from largest to smallest to determine one of the key entities.
3. The intelligent data retrieval method based on the MCP protocol according to claim 1, characterized in that, User intents are filtered based on their confidence level, resulting in an execution sequence containing multiple subtasks, specifically: Based on the adjusted confidence level, filter multiple user intents from largest to smallest; Based on the multiple user intents selected and their dependencies, the user intents that the selected user intents depend on are then selected. Based on the selected user intents, multiple sub-tasks are obtained.
4. The intelligent data retrieval method based on the MCP protocol according to claim 3, characterized in that, The execution sequence is specifically as follows: Based on the adjusted confidence levels, the selected user intents are ranked from highest to lowest. Based on the sorting, the dependencies between user intents and subsequent user intents are compared sequentially from the beginning to the end in order to adjust the sorting. If no user intent is found that requires reordering, then multiple subtasks are executed in this order.
5. The intelligent data retrieval method based on the MCP protocol according to claim 4, characterized in that, Arranging multiple subtasks into an execution sequence in this order also includes: When the number of iterations in the dependency comparison loop reaches a certain threshold, and there is still user intent requiring sorting adjustments, then... The number of user intent adjustments corresponding to a single dependency comparison loop is counted. Based on the number of user intent adjustments from smallest to largest, an order is determined to form an execution sequence of multiple subtasks. If there are multiple dependency comparison loops, and the number of user intent adjustments is minimized, then a sorting order is determined based on the number of dependency comparison loops from smallest to largest to form an execution sequence for multiple subtasks. The loop threshold is set based on the confidence level of the key entity and is positively correlated with the confidence level of the key entity.
6. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the intelligent data retrieval method based on the MCP protocol as described in any one of claims 1 to 5.
7. An electronic device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the intelligent data retrieval method based on the MCP protocol as described in any one of claims 1 to 5.