Endogenous security database query method and device based on large model and MCP protocol
The endogenous secure database query method that combines large models and MCP protocols solves the problem of cross-database queries for non-technical personnel, realizes secure and reliable queries of multi-source heterogeneous data, and improves the intelligence and security of queries.
Patent Information
- Application Number
- CN202511119948.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-08-12
- Publication Date
- 2025-09-12
- Estimated Expiration
- 2045-08-12
AI Technical Summary
Existing database query methods are difficult to meet the query needs of non-technical personnel, lack support for cross-database collaborative queries, and pose risks of information leakage and data security.
An endogenous secure database query method based on a large model and the MCP protocol is adopted. The text and voice information input by the user is received through the MCP client, synonym rewriting and intent recognition are performed, a heterogeneous intelligent agent set is constructed, the database query is performed using the large model, and the final result is generated through the arbitration strategy.
It enables fully controllable, secure and reliable queries on multi-source heterogeneous data without requiring users to have code development capabilities, improves unified query and collaborative processing capabilities across database environments, and reduces security risks during the query process.
Smart Images

Figure CN120631919A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the fields of data query and artificial intelligence technology, and in particular to an intrinsically secure database query method and device based on a large model and an MCP protocol. Background Art
[0002] With the continued development of "Internet Plus," data has become a key production factor. As the core carrier for the circulation and application of data elements, database systems are used to store, manage, and query massive amounts of structured and semi-structured data, and have been widely used in various industries and scenarios. As data scale continues to expand and business needs become increasingly complex, users are placing higher demands on the intelligence level of database queries.
[0003] Currently, there are two main types of database query methods. The first is traditional database query methods, which typically rely on structured query language (SQL) and predefined data schemas. The query process often requires pre-indexing, query statement design, and optimized execution plans, and relies on the database management system (DBMS) query engine for parsing and execution. While this method is relatively mature in terms of efficiency and execution control, it requires high user expertise and is difficult to meet the query needs of non-technical personnel. The second is Text2SQL methods, based on models such as Seq2Seq. These methods convert users' natural language queries into corresponding SQL statements, greatly reducing the barrier to use. However, most existing Text2SQL models are built only for a single database, making them difficult to adapt to heterogeneous structures and multi-source data environments. They lack support for cross-database collaborative queries, and the generated SQL queries may contain risks such as semantic misjudgment, field out-of-bounds access, and unauthorized access, leading to potential information leakage and data security issues. Summary of the Invention
[0004] In view of the fact that existing database query methods are difficult to meet the query needs of non-technical personnel or lack support for cross-database collaborative queries, and are difficult to adapt to heterogeneous structures and multi-source data environments, thus causing potential information leakage and data security issues, the present invention proposes an intrinsically secure database query method and device based on a large model and the MCP protocol, which can achieve fully controllable, secure and reliable data query on multi-source heterogeneous data without requiring users to have code development capabilities.
[0005] In a first aspect, the present invention provides an intrinsically secure database query method based on a large model and the MCP protocol, comprising: Step 1: Obtain question information input by the user; wherein the question information includes text information and voice information; Step 2: The MCP client receives the question message, performs synonym rewriting and intent recognition on the question message to obtain a request message set, and sends the request message set in combination with a preset MCP connection credential set to the MCP server; wherein the request message set includes N request messages that are synonymous with the question message; Step 3: The MCP server receives the request information set and parses the MCP connection credential set, constructs a heterogeneous agent set based on the request information set, and each heterogeneous agent in the heterogeneous agent set performs a database query operation to obtain a return information set; Step 4: Adjudicate the returned information set based on the adjudication strategy to obtain the final database query result.
[0006] Furthermore, the step 1 further includes pre-processing the question information: Performing language detection, encoding standard conversion, noise character removal, and punctuation cleaning on the text information; Endpoint detection, noise suppression and speech enhancement are performed on the speech information.
[0007] Furthermore, in step 2, performing synonymous rewriting and intention recognition on the question information specifically includes: the MCP client processes the question information by calling the large model according to a preset prompt word template.
[0008] Furthermore, in step 2, the preset MCP connection credential set includes a data source location tuple, model service call parameters, a policy descriptor, and a response output configuration.
[0009] Furthermore, in step 3, each heterogeneous agent in the heterogeneous agent set performs a database query operation, specifically including: After receiving the corresponding request information, each heterogeneous agent calls the large model to perform semantic reasoning and task understanding on the request information to obtain structured instructions. Each heterogeneous agent combines the MCP connection credential set to identify the database that semantically matches the request information from multi-source heterogeneous databases, determine the corresponding execution strategy, access the corresponding database according to the structured instructions, and generate query results. After receiving the query results, the large model processes the query results according to the response output template of the heterogeneous agent and outputs return information.
[0010] Furthermore, in step 3, each heterogeneous agent in the heterogeneous agent set performs a database query operation separately, which also includes introducing a retrieval enhancement technology of a graph structure: Each heterogeneous agent obtains corresponding database meta-information in the form of structured text; the database meta-information includes the source type of each data source, the table name and table description of the data table in the data source, and the table creation statement of the data table; generating graph structure text information based on the database metadata; Vectorizing and encoding the graph structure text information and storing it in a vector database in the form of a graph structure; Each heterogeneous agent in the heterogeneous agent set constructs a graph retriever, and retrieves and recalls the most similar text fragments from the vector database according to the corresponding request information, thereby obtaining a recall information set; Each heterogeneous agent in the heterogeneous agent set executes a tool call strategy to access the target database based on the corresponding request information and recall information in combination with the MCP connection credential set, and generates a query result set.
[0011] Furthermore, generating graph structure text information based on the database metadata specifically includes: A key-value pair structure is formed based on the database metadata; wherein the key-value pair structure includes two types of key-value pair structures; the key in the first type of key-value pair structure is the source type of the data source, and the value in the first type of key-value pair structure is the table name and table description of the data table in the data source corresponding to the key in the first type of key-value pair structure; the key in the second type of key-value pair structure is the table name, table description, and business domain of the data table in the data source, and the value in the second type of key-value pair structure is the table creation statement of the data table corresponding to the key in the second type of key-value pair structure; The table descriptions in different table creation statements are deduplicated and merged, and a graph structure is formed based on the key-value pairs; wherein the nodes of the graph structure are the source type of the data source, the table name and table description of the data table in the data source, and the table creation statement of the data table, wherein the node attribute of the source type of the data source is set as a first-level node; the node attributes of the table name, table description, and business domain to which the data table in the data source belongs are set as second-level nodes; the node attributes of the table creation statement of the data table are set as third-level nodes; the edge connection relationship of the graph structure is the mapping relationship of the key-value pair structure.
[0012] Furthermore, the graph retriever performs retrieval based on a double-layer retrieval method of parent node information and leaf node information.
[0013] Furthermore, in step 4, the arbitration strategy includes format verification and consistency voting, specifically including: Perform format check on all returned information in the returned information set. If any information does not conform to the encoding format and output format, the returned information will fail the check. The returned information that has passed the format verification is voted on for consistency based on the majority judgment strategy. The returned information is split into key-value pairs according to the output format. The values corresponding to the results generated by different heterogeneous agents are determined based on the keys, and the data with the highest data consistency is selected as the final database query result.
[0014] In a second aspect, the present invention provides an intrinsically secure database query device based on a large model and the MCP protocol, comprising: A question information acquisition module is used to acquire question information input by the user; wherein the question information includes text information and voice information; a request processing and sending module, configured to receive the question information at the MCP client, perform synonymous rewriting and intent recognition on the question information to obtain a request information set, and send the request information set in combination with a preset MCP connection credential set to the MCP server; wherein the request information set includes multiple request information that are synonymous with the question information; a parsing and execution module, configured to receive the request information set from the MCP server and parse the MCP connection credential set, construct a heterogeneous agent set based on the request information set, and each heterogeneous agent in the heterogeneous agent set respectively performs a database query operation to obtain a return information set; wherein each heterogeneous agent in the heterogeneous agent set has equivalent functions but different structures; The policy decision module is used to make a decision on the returned information set based on the decision policy to obtain a final database query result.
[0015] The beneficial effects of the present invention are: The present invention organically combines the big model with the MCP protocol. The MCP protocol is like a USB-C interface. The MCP protocol provides a standardized method for the big model. By configuring the MCP connection credential set, the big model has the ability to understand the database configuration information in the target cluster and call the target database, thereby achieving efficient adaptation and seamless interaction with different types of data sources and tool systems. This technical solution effectively solves the query problem under multi-source heterogeneous data structures, and significantly improves the unified query and collaborative processing capabilities in a cross-database environment. It can then be applied to data queries in data analysis systems and intelligent customer service systems to achieve intelligent upgrades in business scenarios.
[0016] Based on the theory of inherent security, this invention uses a "redundant control + large model service" approach to construct functionally equivalent heterogeneous agents. It then applies strategic decision-making to the information returned by these agents to generate the final database query results. Compared to traditional database query models (such as Text2SQL), this effectively reduces the risks of mismatched fields, out-of-bounds data access, and permission violations caused by semantic misunderstandings during the query process, thereby enhancing data access security from the very beginning. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Figure 1 A flowchart of an intrinsically secure database query method based on a large model and the MCP protocol provided by an embodiment of the present invention; Figure 2 A schematic diagram of a flow chart of an intrinsically secure database query device based on a large model and the MCP protocol provided in an embodiment of the present invention. DETAILED DESCRIPTION
[0018] To make the objectives, technical solutions, and advantages of the present invention more clear, the technical solutions in the embodiments of the present invention will be clearly described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present invention.
[0019] Example 1 like Figure 1 As shown, an embodiment of the present invention provides an intrinsic security database query method based on a large model and the MCP protocol, including: Step 1: Obtain the question information input by the user, which includes text information and voice information.
[0020] Specifically, the user's question information input through the terminal device is obtained. The text information input by the user is query information described in natural language, such as "What is the proportion of payments completed by users through the app in the past month?", "What is the average number of daily active users (DAU) in the past seven days?", etc. This text information can be input through the browser front-end graphical user interface (GUI), command line interface, or other interactive input components. The voice information input by the user refers to the audio data obtained through a microphone device or voice acquisition device. The collected raw voice signal is processed by the automatic speech recognition module (ASR) and transcribed into a standardized text representation. The text representation and text information constitute the question information as the input for subsequent semantic understanding and task analysis.
[0021] Preferably, the process of obtaining the question information input by the user may further include: ① Perform text preprocessing operations on user input, including language detection, encoding standard conversion (such as UTF-8), noise character removal, and punctuation cleaning; ② In the process of obtaining the voice information input by the user, audio processing operations such as endpoint detection, noise suppression and voice enhancement are performed on the original voice signal collected by the microphone device or voice collection device.
[0022] Step 2: The MCP client receives the question information, performs synonym rewriting and intent recognition on the question information, obtains a request information set, and sends the request information set combined with the preset MCP connection credential set (MCP ConnectionCredential Set) to the MCP server.
[0023] The request information set includes a plurality of request information that are synonymous with the question information. In the embodiment of the present invention, there are three pieces of request information in the request information set generated, namely, the first request information, the second request information and the third request information.
[0024] Specifically, in this embodiment, the MCP client is the user interaction and service request portal deployed between the user terminal and the backend large model service. It is the interface for direct user interaction with the application and can be a web application, mobile app, or a programming API (such as a RESTful API). The MCP client's role is to receive user input to initiate requests and subsequently receive responses from heterogeneous agents.
[0025] Specifically, the MCP client implements a semantic processing flow based on a preset prompt word template and calls the big model service to process the question information and generate N≥3 request messages. The prompt word template is used to guide the big model to generate N request messages with different expressions but consistent semantics.
[0026] As an implementable method, the preset prompt word template is:
Function
Input question
Task Requirements
[0027] Specifically, the MCP client calls the large language model service three times for the same user question information based on the preset prompt word module, thereby obtaining the first request information, the second request information, and the third request information.
[0028] For example, when the user enters a text message asking "How many users are active on the app in the past seven days?", the MCP client calls the large model service three times for synonym rewriting and intent recognition, and obtains the first request information, the second request information, and the third request information, as follows: 1. The first request information is: { "Request information": "How many active users are there in the app in the past 7 days?" "Query intent": "Statistical query" } 2. The second request information is: { "Request information": "What is the total number of active users on the app in the past week?" "Query intent": "Statistical query" } 3. The third request information is: { "Request information": "How many users were active in the app in the past 7 days?", "Query intent": "Statistical query" } Specifically, the MCP connection credential set refers to a set of configuration parameters used to support secure, stable, and standardized access between large models and external database resources under the MCP protocol. This credential set not only covers the basic connection parameters of the database itself, but also includes control information for model invocation, authentication, invocation strategy, and result format management. It includes the following components: 1. Data source location tuple: target database type, target database instance terminal address, port number, database name, and authentication credentials (such as user name, password, or token); 2. Model service call parameters: service URL or API interface of the large model (such as / v1 / chat / completions), model API call license (such as API-KEY), model name and version (such as qwen-plus), and request parameters (such as temperature, Top-p, etc.); 3. Policy descriptors: query timeout threshold, maximum connection pool size, concurrency limit, and maximum number of rows in the query result set; 4. Response output configuration: output encoding format (UTF-8), output format (such as streaming output), and sensitive data desensitization rules.
[0029] Furthermore, the MCP connection credential set can be installed, obtained, and loaded from the MCP protocol open platform (such as https: / / mcp.so / ), or customized using the MCP protocol according to standard procedures. For example, the connection credential for the MySQL data source location tuple is as follows: { "mcpServers": { "mysql": { "command": "node", "args": [" / path / to / mysql-mcp-server / build / index.js"], "env": { "MYSQL_HOST": "your-mysql-host", "MYSQL_PORT": "3306", "MYSQL_USER": "your-mysql-user", "MYSQL_PASSWORD": "your-mysql-password", "MYSQL_DATABASE": "your-default-database" }, "disabled": false, "autoApprove": [] } } } Preferably, given that the current large model itself lacks the ability to perceive and understand the current time context, this embodiment acquires an MCP protocol capable of querying and perceiving the current time from the MCP protocol open platform and configures it into the MCP connection credential set. This allows the large model to access and parse the current time, enabling it to process temporal semantics. In subsequent database calls, when faced with query requests that include a time dimension, the large model can perform more precise semantic reasoning on the time information, significantly improving the accuracy of database queries. Implementations of the MCP protocol may include, but are not limited to, standardized MCP protocols that support time services, such as the Baidu Maps MCP protocol and the Amap Maps MCP protocol.
[0030] Step 3: The MCP server receives the request information set and parses the MCP connection credential set, constructs a heterogeneous agent set based on the request information set, and each heterogeneous agent in the heterogeneous agent set performs a database query operation to obtain a return information set.
[0031] Specifically, the MCP server receives the request from the MCP client and parses the MCP connection credentials. It then begins processing the request. Based on the concepts of mimetic defense and dynamic heterogeneous redundancy in intrinsic security, it constructs a first heterogeneous agent, a second heterogeneous agent, and a third heterogeneous agent based on the first, second, and third request information, respectively. The first, second, and third heterogeneous agents each understand the context and invoke available tools, then perform database queries on relevant devices to generate first, second, and third response messages.
[0032] Specifically, the MCP server is an intelligent middleware component that complies with the MCP protocol. It is responsible for coordinating semantic instruction conversion, resource scheduling, connection control, and result set processing between the large model and the external database. It is a large model hosting and inference engine used for model loading, storage, and computation scheduling.
[0033] Because the model may experience semantic deviations, field matching errors, or unauthorized field calls when understanding and generating database query statements, such queries pose significant uncertainty and information security risks. Therefore, based on the concept of dynamic heterogeneous redundancy within intrinsic security, we construct heterogeneous agents with equivalent functionality but different structures. To ensure the dynamic diversity of executors, the MCP server schedules and allocates computing resources to construct a set of heterogeneous agents: the first heterogeneous agent, the second heterogeneous agent, and the third heterogeneous agent.
[0034] Specifically, heterogeneous agents are multi-instance intelligent processing units built based on different model configurations, context-aware capabilities, and tool invocation methods, after performing multi-path semantic parsing and task decomposition of user natural language requests through a large model. Each heterogeneous agent possesses independent reasoning logic, execution links, and verification mechanisms, forming a data security query intelligent execution architecture composed of "redundant control + large model services."
[0035] Specifically, after receiving the request information, the first heterogeneous agent, the second heterogeneous agent, and the third heterogeneous agent respectively call the big model to perform semantic reasoning and task understanding on the request information, combine the MCP connection credential set, identify the target database instance that matches the request semantics from the multi-source heterogeneous database, and determine the corresponding execution strategy. According to the parsed structured execution instructions, the target database is accessed and query results that comply with the authority and format specifications are returned. After receiving the query results, the big model processes the results according to the response output template of the heterogeneous agent and outputs a response answer that conforms to the natural language expression habits and format requirements.
[0036] Preferably, to further improve the semantic understanding accuracy of context information and the accuracy of target database positioning by heterogeneous agents, this embodiment introduces graph-structured retrieval enhancement technology. During the semantic reasoning and execution strategy generation process of the heterogeneous agent set (the first heterogeneous agent, the second heterogeneous agent, and the third heterogeneous agent), dynamic semantic completion support from the vector database is used. The specific method is as follows: ① Each heterogeneous agent obtains database metadata in the form of structured text. Database metadata is information that describes various data structures in the database and is used to help understand, locate, manage and operate database data, including but not limited to: Source type of each data source (such as MySQL, Hive, etc.); The table name and description of each data table in the data source; The table creation statement for each table in the database includes information such as the field name, field type, field meaning, enumeration value description, and constraints between fields (such as primary key and foreign key).
[0037] ② Generate graph structure text information based on the database metadata, specifically including: A key-value pair structure with index value is formed based on database metadata. In the first type of key-value pair structure, the "key" is the source type of the data source, and the "value" is the table name and table description of the data table in the data source corresponding to the source type of the data source. In the second type of key-value pair structure, the "key" is the table name and table description of the data table in the data source, and the "value" is the table creation statement corresponding to the table name and table description of the data table in the data source.
[0038] Afterwards, table descriptions in different table creation statements are de-duplicated and merged to reduce unnecessary calculations, and a graph structure is formed based on the key-value pairs.
[0039] The node information in the graph structure includes the source type of the data source, the table name and description of the data table in the data source, and the table creation statement of the data table. The node attributes of the source type of the data source are set as first-level nodes; the node attributes of the table name, table description, and business domain of the data table in the data source are set as second-level nodes; and the node attributes of the table creation statement of the data table are set as third-level nodes. The edge connection relationship of the graph structure is a mapping relationship between key-value pairs.
[0040] ③ The graph structure text information is vectorized and encoded and stored in the vector database in the form of a graph structure.
[0041] Specifically, the Embedding model used in the vectorized coding may be Qwen3-Embedding, bge-m3, or m3e-base.
[0042] ④ Each heterogeneous agent in the heterogeneous agent set constructs a graph retriever respectively, and retrieves and recalls the most similar text fragments from the vector database according to the corresponding request information, thereby obtaining a recall information set, namely the first recall information, the second recall information, and the third recall information.
[0043] Specifically, the searcher performs a two-tiered search using both parent and leaf node information. Root node information refers to the first- and second-level nodes in the graph structure, while leaf node information refers to the third-level nodes. To enhance the accuracy of search results, when searching for leaf node information, the parent node information corresponding to the leaf node is also returned as a result.
[0044] Retrieval based on parent node information provides the large model with contextual information about the database structure, while retrieval based on leaf node information provides the large model with contextual information for statistical analysis and aggregation fields when parsing data queries.
[0045] Specifically, the retriever merges the retrieval results of the parent node information retrieval and the leaf node information retrieval to obtain the recalled information.
[0046] The search strategy search_type when the searcher performs a search can be multiple, including but not limited to: 1. Similarity: Directly calculates the cosine distance between the query vector and the document vector and returns the TopK algorithm; 2. mmr: Maximum marginal relevance algorithm that avoids returning content with duplicate semantics; 3. similarity_score_threshold: Similarity threshold filtering algorithm that only returns those with similarities exceeding the set threshold.
[0047] ⑤ Each heterogeneous agent in the heterogeneous agent set executes the tool call strategy to access the target database based on the corresponding request information and recall information, combined with the vector MCP connection credential set, and generates a query structure set.
[0048] Specifically, the first heterogeneous agent, the second heterogeneous agent, and the third heterogeneous agent respectively execute the tool call strategy to access the target database based on the corresponding request information and recall information, combined with the MCP connection credential set, and generate a query result set, thereby obtaining the first query result, the second query result, and the third query result.
[0049] Furthermore, the heterogeneous intelligent agent inputs the corresponding request information and recall information into the large model, and constructs a natural language prompt template that includes both user query requirements and database context information. The prompt template has database semantic perception capabilities and structured query processing capabilities, which improves accuracy.
[0050] Furthermore, the intrinsic security property of the intrinsically secure database query method is embodied by functionally equivalent heterogeneous agents. Its dynamic characteristics are manifested in the existence of three equivalent but heterogeneous agents. Its heterogeneous redundancy characteristics include: 1. Differences in request information: the first, second, and third request information after synonymous rewriting and intent identification; 2. Different large models are called: Alibaba Qwen large model, DeepSeek large model, and iFlytek Spark large model are called through the local Ollama framework or external AI capability platforms; 3. Different embedding models are used when generating vector databases: Qwen3-Embedding, bge-m3, and m3e-base; 4. Different retrieval and recall strategies: direct calculation of cosine distance, maximum marginal correlation algorithm, and similarity threshold filtering algorithm.
[0051] Furthermore, heterogeneous intelligent agents are implemented based on the SpringAI framework. Spring AI is an artificial intelligence application development framework built on the Spring ecosystem. The framework includes standardized access components for large models, prompt engineering management tools, document processing and vectorization tools, vector databases and retrieval tools, and model context protocol (MCP) support. It seamlessly integrates Spring Boot and other Spring ecosystems, which is conducive to the application of the endogenous security database query method of this embodiment to data analysis systems and intelligent customer service systems, realizing intelligent upgrades of business scenarios.
[0052] Step 4: Adjudicate the returned information set based on the adjudication strategy to obtain the final database query result.
[0053] Specifically, the adjudication strategy in this embodiment includes format verification and consistency voting. For the first, second, and third return information returned by the first, second, and third heterogeneous agents, format verification is first performed. If there is an encoding format (such as UTF-8) and output format (such as JSON) that does not meet the requirements of this embodiment, the return information of the heterogeneous agent will not pass the judgment. Afterwards, the return information that passes the format verification is subjected to consistency voting based on the majority adjudication strategy, that is, the return information is split into key-value pairs according to the output format, and the value corresponding to the generated results of different heterogeneous agents is determined based on the key value. The data with the most data consistency is selected as the final database query result.
[0054] Example 2 like Figure 2 As shown, an embodiment of the present invention further provides an intrinsically secure database query device based on a large model and the MCP protocol, comprising: The question information acquisition module is used to obtain the question information input by the user; wherein the question information includes text information and voice information; The request processing and sending module is used to receive question information on the MCP client, perform synonymous rewriting and intent recognition on the question information, obtain a request information set, and send the request information set in combination with a preset MCP connection credential set to the MCP server; wherein the request information set includes N request information that are synonymous with the question information; The parsing and execution module is used to receive the request information set from the MCP server and parse the MCP connection credential set, build a heterogeneous agent set based on the request information set, and each heterogeneous agent in the heterogeneous agent set performs a database query operation to obtain a return information set; The policy decision module is used to make a decision on the returned information set based on the decision policy to obtain the final database query result.
[0055] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the various embodiments of the present invention.
Claims
1. A method for querying an intrinsically secure database based on a large model and the MCP protocol, characterized in that: include: Step 1: Obtain question information input by the user; wherein the question information includes text information and voice information; Step 2: The MCP client receives the question message, performs synonym rewriting and intent recognition on the question message to obtain a request message set, and sends the request message set in combination with a preset MCP connection credential set to the MCP server; wherein the request message set includes N request messages that are synonymous with the question message; Step 3: The MCP server receives the request information set and parses the MCP connection credential set, constructs a heterogeneous agent set based on the request information set, and each heterogeneous agent in the heterogeneous agent set performs a database query operation to obtain a return information set; Step 4: Adjudicate the returned information set based on the adjudication strategy to obtain the final database query result.
2. The method for querying an intrinsically secure database based on a large model and the MCP protocol according to claim 1, characterized in that: The step 1 further includes pre-processing the question information: Performing language detection, encoding standard conversion, noise character removal, and punctuation cleaning on the text information; Endpoint detection, noise suppression and speech enhancement are performed on the speech information.
3. The method for querying an intrinsically secure database based on a large model and the MCP protocol according to claim 1, characterized in that: In step 2, performing synonymous rewriting and intention recognition on the question information specifically includes: the MCP client processes the question information by calling the large model according to a preset prompt word template.
4. The method for querying an intrinsically secure database based on a large model and the MCP protocol according to claim 1, characterized in that: In step 2, the preset MCP connection credential set includes a data source location tuple, model service call parameters, a policy descriptor, and a response output configuration.
5. The method for querying an intrinsically secure database based on a large model and the MCP protocol according to claim 1, characterized in that: In step 3, each heterogeneous agent in the heterogeneous agent set performs a database query operation, specifically including: After receiving the corresponding request information, each heterogeneous agent calls the large model to perform semantic reasoning and task understanding on the request information to obtain structured instructions. Each heterogeneous agent combines the MCP connection credential set to identify the database that semantically matches the request information from the multi-source heterogeneous databases, and determines the corresponding execution strategy. According to the structured instructions, it accesses the corresponding database to generate query results. After receiving the query results, the large model processes the query results according to the response output template of the heterogeneous agent and outputs return information.
6. The method for querying an intrinsically secure database based on a large model and the MCP protocol according to claim 5, characterized in that: In step 3, each heterogeneous agent in the heterogeneous agent set performs a database query operation, which also includes introducing a graph structure retrieval enhancement technology: Each heterogeneous agent obtains corresponding database meta-information in the form of structured text; the database meta-information includes the source type of each data source, the table name and table description of the data table in the data source, and the table creation statement of the data table; generating graph structure text information based on the database metadata; Vectorizing and encoding the graph structure text information and storing it in a vector database in the form of a graph structure; Each heterogeneous agent in the heterogeneous agent set constructs a graph retriever, and retrieves and recalls the most similar text fragments from the vector database according to the corresponding request information, thereby obtaining a recall information set; Each heterogeneous agent in the heterogeneous agent set executes a tool call strategy to access the target database based on the corresponding request information and recall information in combination with the MCP connection credential set, and generates a query result set.
7. The method for querying an intrinsically secure database based on a large model and the MCP protocol according to claim 6, characterized in that: Generating graph structure text information based on the database metadata specifically includes: A key-value pair structure is formed based on the database metadata; wherein the key-value pair structure includes two types of key-value pair structures; the key in the first type of key-value pair structure is the source type of the data source, and the value in the first type of key-value pair structure is the table name and table description of the data table in the data source corresponding to the key in the first type of key-value pair structure; the key in the second type of key-value pair structure is the table name and table description of the data table in the data source, and the value in the second type of key-value pair structure is the table creation statement of the data table corresponding to the key in the second type of key-value pair structure; The table descriptions in different table creation statements are deduplicated and merged, and a graph structure is formed based on the key-value pairs; wherein the nodes of the graph structure are the source type of the data source, the table name and table description of the data table in the data source, and the table creation statement of the data table, wherein the node attribute of the source type of the data source is set as a first-level node; the node attributes of the table name and table description of the data table in the data source are set as second-level nodes; the node attributes of the table creation statement of the data table are set as third-level nodes; the edge connection relationship of the graph structure is the mapping relationship of the key-value pair structure.
8. The method for querying an intrinsically secure database based on a large model and the MCP protocol according to claim 6, characterized in that: The graph retriever performs retrieval based on a double-layer retrieval method of parent node information and leaf node information.
9. The method for querying an intrinsically secure database based on a large model and the MCP protocol according to claim 1, characterized in that: In step 4, the arbitration strategy includes format verification and consistency voting, specifically including: Perform format check on all returned information in the returned information set. If any information does not conform to the encoding format and output format, the returned information will fail the check. The returned information that passes the format verification is voted on for consistency based on the majority judgment strategy. The returned information is split into key-value pairs according to the output format. The values corresponding to the results generated by different heterogeneous agents are determined based on the keys, and the data with the highest data consistency is selected as the final query result.
10. An endogenous security database query device based on a large model and MCP protocol, characterized in that: include: A question information acquisition module is used to acquire question information input by the user; wherein the question information includes text information and voice information; a request processing and sending module, configured to receive the question information on the MCP client, perform synonymous rewriting and intent recognition on the question information to obtain a request information set, and send the request information set in combination with a preset MCP connection credential set to the MCP server; wherein the request information set includes N request information that are synonymous with the question information; a parsing and executing module, configured to receive the request information set from the MCP server and parse the MCP connection credential set, construct a heterogeneous agent set based on the request information set, and each heterogeneous agent in the heterogeneous agent set performs a database query operation to obtain a return information set; The policy decision module is used to make a decision on the returned information set based on the decision policy to obtain a final database query result.
Citation Information
Patent Citations
System intelligent interaction method and device based on large language model
CN117370493A
Method and system for automatically generating sql and replying questions
CN118093634A
Data processing method and device and large language model fine tuning method and device
CN119576964A
Multi-modal enhanced retrieval method and system
CN119903198A
External data query strategy method
CN119961307A
Cited By
LLM and MCP protocol-based edge computing terminal information query method and intelligent agent
CN120892447A
An edge computing terminal information query method and agent based on LLM and MCP protocols
CN120892447B
Multi-interface collaborative natural language data query method and system
CN120910225A
Product maintenance method, system, medium, equipment and program product
CN121636542A
