A large model data report generation tool and method based on MCP

By leveraging the MCP-Server architecture and SSE protocol, the system enhances the ability of large models to understand database structures, solving the problem of large models struggling to comprehend database query results. This enables an automated process from database queries to visual reports, improving data analysis efficiency and user experience.

CN120687467BActive Publication Date: 2026-01-09HANGZHOU SHUJU CHAIN TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511196117.6
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-26
Publication Date
2026-01-09
Estimated Expiration
2045-08-26

AI Technical Summary

Technical Problem

Large language models lack understanding of database structures, resulting in a low probability of calling database query tools and difficulty in accurately interpreting query results, thus failing to generate corresponding reports.

Method used

Adopting the MCP-Server architecture, it communicates with the MCP-Client via the SSE protocol. It includes a database module, a tool module, and a chart generation module, which realizes dynamic embedding of database table names and Chinese annotations, simplified string format conversion, and interactive chart generation, thereby enhancing the large model's ability to recognize the database structure and understand the data.

Benefits of technology

It improves the accuracy and proactivity of large-scale model database query tools, realizes end-to-end automated process from database query to visual report, and enhances data analysis efficiency and user interaction experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120687467B_ABST
    Figure CN120687467B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of networks, in particular to a large model data report generation method based on MCP. First, the database table name and the corresponding Chinese annotation are dynamically embedded into the tool description text, the cognitive ability of the large model to the underlying database structure is enhanced, and the accuracy and initiative of the large model in calling the database query tool are effectively improved. Secondly, a simplified string format conversion mechanism is introduced, the original query result is converted into semantic clear data in the form of key-value pairs, redundant information is stripped, and the large model is more easy to understand and utilize the key data content. Finally, the simplified data is automatically parsed through a chart generation module, and an interactive chart link is generated, realizing an end-to-end automatic process from original database query to visual report, greatly improving the data analysis efficiency, use convenience and user interaction experience.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of network technology, and in particular to a tool and method for generating large model data reports based on MCP. Background Technology

[0002] With the rapid development of artificial intelligence technology, large language models (LLMs) have demonstrated remarkable capabilities in the field of natural language processing. However, relying solely on the knowledge within the model has certain limitations, especially when processing real-time data, performing specific tasks, or interacting with external systems. To address these issues, the function calling mechanism has been introduced, enabling LLMs to interact with external tools and APIs, thereby expanding their functional scope.

[0003] Currently, MCP supports tools for querying MySQL databases, but it still faces some challenges in practical applications:

[0004] First, large models lack understanding of database structures, so they are less likely to call database query tools and have difficulty accurately interpreting the results returned after the calls. As a result, large models cannot generate corresponding reports based on the results by date and can only return the queried data. Summary of the Invention

[0005] In view of this, the purpose of this invention is to provide a tool and method for generating large model data reports based on MCP.

[0006] In a first aspect, embodiments of the present invention provide a large model data report generation tool based on MCP, which adopts an MCP-Server architecture and communicates with an MCP-Client via the SSE protocol. The tool includes:

[0007] The database module is configured with database connection parameters. It is used to execute SQL queries to retrieve all table names and Chinese comments in the current database, format the query results into a specified structured data format, and then embed tool description text. The database module is also used to query the table structure and table data based on the table name.

[0008] The tool module connects to the database module. The tool module includes a tool declaration module and a tool invocation module. The tool declaration module responds to the tool discovery request from the MCP-Client and returns optimized tool description text, which includes table comments and table name mapping strings generated by the database module. The tool invocation module responds to the tool invocation request from the MCP-Client, queries the target table data according to the table name in the request parameters, and converts the target table data into a simplified string with Chinese comments.

[0009] The chart generation module, connected to the tool module, is used to parse key-value pair data in simplified strings and generate interactive chart links based on the key-value pair data.

[0010] In conjunction with the first aspect, the tool describes the generation of text, including:

[0011] Extract the database name from the database connection parameters;

[0012] Perform a table metadata query to obtain the table name-comment mapping relationship for each list;

[0013] The mapping relationship is formatted as a string of a specified form;

[0014] Embed the string into the preset tool description template.

[0015] In conjunction with the first aspect, simplifying string generation includes:

[0016] Perform a field metadata query to obtain numeric fields, date fields, and field comments from the target list;

[0017] For each target field, convert the target field and its corresponding field comments into key-value pairs in a specified format;

[0018] By combining all the key-value pairs, a simplified string with Chinese comments is obtained.

[0019] In conjunction with the first aspect, simplifying string generation also includes:

[0020] Based on the field order in the target list, arrange the key-value pairs sequentially and separate them with semicolons.

[0021] In conjunction with the first aspect, the generation of interactive chart links includes:

[0022] Use date fields from the key-value pair data as the horizontal axis labels, numeric fields as the vertical axis data, and use the comments that contain the target list corresponding to the key-value pair data as the chart title.

[0023] Generate interactive chart links based on the chart type parameter in the request.

[0024] In conjunction with the first aspect, it also includes a communication interface module for receiving tool discovery requests from the MCP-Client; the communication interface module is also used to return the optimized tool description text output by the tool declaration module to the MCP-Client for large model tool integration; the communication interface module is also used to return the interactive chart link generated by the chart generation module to the MCP-Client for generating the final answer.

[0025] In conjunction with the first aspect, database connection parameters should include at least the URL, user, password, and driver name.

[0026] Secondly, embodiments of this application also provide a method for generating large model data reports based on MCP, applied to the tools described above; the method includes:

[0027] The tool declaration module receives the tool discovery request sent by the MCP-Client, drives the database module to extract the database name based on the pre-configured database connection parameters, performs table metadata query to generate an optimized MCP tool description and returns it to the MCP-Client for large model integration toolset;

[0028] The tool invocation module receives the tool invocation request forwarded by MCP-Client, parses the target table name in the request, generates a simplified string in non-JSON format, and calls the chart generation module to parse the simplified string to generate an interactive chart and return the value MCP-Client.

[0029] In conjunction with the second aspect, the steps of parsing the target table name in the request and generating a simplified non-JSON string include:

[0030] Perform a field metadata query to obtain numeric fields, date fields, and field comments from the target list;

[0031] For each target field, convert the target field and its corresponding field comments into key-value pairs in a specified format;

[0032] By combining all the key-value pairs, a simplified string with Chinese comments is obtained.

[0033] In conjunction with the second aspect, the steps of calling the chart generation module to simplify string parsing and generate interactive charts include:

[0034] Use date fields from the key-value pair data as horizontal axis labels and numeric fields as vertical axis data. Also, use the comments that contain the target list corresponding to the key-value pair data as the chart title.

[0035] Generate interactive chart links based on the chart type parameter in the request.

[0036] The embodiments of this invention bring the following beneficial effects: This invention provides a tool and method for generating large model data reports based on MCP. The tool adopts an MCP-Server architecture and communicates with MCP-Client through the SSE protocol. The tool includes: a database module configured with database connection parameters; the database module is used to execute SQL queries to obtain all table names and Chinese comments in the current database, format the query results into structured data of a specified form, and then embed the tool description text; the database module is also used to query the table structure and table data according to the table name; a tool module connected to the database module; the tool module includes a tool declaration module and a tool invocation module; the tool declaration module is used to respond to the tool discovery request of the MCP-Client and return the optimized tool description text, which includes table comments and table name mapping strings generated by the database module; the tool invocation module is used to respond to the tool invocation request of the MCP-Client, query the target table data according to the table name in the request parameters, and convert the target table data into a simplified string with Chinese comments; a chart generation module connected to the tool module is used to parse the key-value pair data in the simplified string and generate interactive chart links based on the key-value pair data.

[0037] This application first enhances the large model's understanding of the underlying database structure by dynamically embedding database table names and their corresponding Chinese annotations into the tool description text, effectively improving the accuracy and proactivity of its database query tools. Second, it introduces a simplified string format conversion mechanism to transform the original query results into semantically clear key-value pair data, stripping away redundant information and making it easier for the large model to understand and utilize this key data content. Finally, it automatically parses the simplified data through a chart generation module and generates interactive chart links, realizing an end-to-end automated process from original database queries to visual reports, greatly improving data analysis efficiency, ease of use, and user interaction experience.

[0038] Other features and advantages of the invention will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the invention. The objects and other advantages of the invention are realized and obtained in accordance with the structures particularly pointed out in the description, claims and drawings.

[0039] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, preferred embodiments are described below in detail with reference to the accompanying drawings. Attached Figure Description

[0040] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0041] Figure 1 A schematic diagram of the components of the MCP-based large model data report generation tool provided in this embodiment of the invention;

[0042] Figure 2 Example charts generated by the MCP-based large model data report generation tool provided in this embodiment of the invention;

[0043] Figure 3 This is a schematic diagram of the method for generating large model data reports based on MCP provided in an embodiment of the present invention;

[0044] Figure 4 This is a schematic diagram of the electronic device structure provided in an embodiment of the present invention. Detailed Implementation

[0045] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0046] To facilitate understanding of this embodiment, the technical terms used in this application will be briefly introduced below.

[0047] The Model Context Protocol (MCP) is an open-source protocol developed by Anthropic. It aims to integrate large models with external data sources and tools, establishing a secure, bidirectional connection between the model and the data source. Through MCP, large models can better access and utilize external data sources, such as databases and APIs, thereby enhancing their functionality and application scenarios.

[0048] After introducing the technical terms used in this application, the application scenarios and design concepts of the embodiments of this application will be briefly described below.

[0049] Large models lack understanding of database structures, thus they are less likely to call database query tools and have difficulty accurately interpreting the results returned after the calls. As a result, large models cannot generate corresponding reports based on the results by date and can only return the queried data.

[0050] Based on this, this application provides a tool and method for generating large model data reports based on MCP.

[0051] Example 1

[0052] This application provides a large-scale model data report generation tool based on MCP, employing an MCP-Server architecture and communicating with MCP-Client via the SSE protocol. Combined with... Figure 1 As shown, the tool includes: database module 10, tool module 20, and chart generation module 30.

[0053] Database module 10 is configured with database connection parameters; database module 10 is used to execute SQL queries to obtain all table names and Chinese comments in the current database, format the query results into structured data of a specified form and then embed tool description text; database module 10 is also used to query table structure and table data based on table name.

[0054] The tool module 20 is connected to the database module 10; the tool module 20 includes a tool declaration module and a tool invocation module; the tool declaration module is used to respond to the tool discovery request of the MCP-Client and return the optimized tool description text, which includes the table comments and table name mapping strings generated by the database module 10; the tool invocation module is used to respond to the tool invocation request of the MCP-Client, query the target table data according to the table name in the request parameters and convert the target table data into a simplified string with Chinese comments.

[0055] The chart generation module 30 is connected to the tool module 20 and is used to parse key-value pair data in simplified strings; and generate interactive chart links based on the key-value pair data.

[0056] This application significantly enhances the intelligence and practicality of MCP in database report generation tasks through innovative system architecture and data processing design. Firstly, at the tool invocation level, by dynamically embedding database table names and their corresponding Chinese annotations into the tool description text, the large model's ability to understand the underlying database structure is enhanced, effectively improving the accuracy and proactivity of its database query tool invocation. Secondly, at the data parsing level, a simplified string format conversion mechanism is introduced, transforming the original query results into semantically clear key-value pair data, stripping away redundant information, making it easier for the large model to understand and utilize this key data content. Finally, at the output presentation level, the simplified data is automatically parsed through a chart generation module, generating interactive chart links, realizing an end-to-end automated process from original database queries to visual reports, greatly improving data analysis efficiency, ease of use, and user interaction experience. This design not only solves the problem of the lack of report generation capabilities in existing technologies but also provides a scalable technical foundation for subsequent complex data-driven tasks.

[0057] In conjunction with the first aspect, the tool describes the generation of text, including:

[0058] S110, extract the database name from the database connection parameters.

[0059] S120, execute table metadata query to obtain the table name-annotation mapping relationship for each list.

[0060] S130, format the mapping relationship as a specified string.

[0061] S140, embed the string into the preset tool description template.

[0062] The database module 10 is a key component in the system responsible for interacting with the database, and it contains the necessary database connection parameters. These connection parameters typically include information such as the database address (IP or URL), port number, database name, username, and password, used to establish a secure connection with the target database.

[0063] In practice, when metadata information about the current database is needed, the database module extracts the "database name" field from these connection parameters. The database name refers to the name of the specific database instance being connected to; it is the fundamental identifier for subsequent database queries and operations. By extracting the database name, it ensures that subsequent operations are performed on the correct database instance, thereby guaranteeing the accuracy and validity of data queries. Therefore, database connection parameters can quickly identify the database from which the data to be processed originates.

[0064] Subsequently, by executing a table metadata query, all table names in the database and their corresponding comments are obtained, thus revealing the table name-comment mapping for each list. Specifically, the following table metadata query can be used to retrieve all table names and their comments in the database "zone_llm_summary":

[0065] SELECT TABLE_NAME, TABLE_COMMENT

[0066] FROM INFORMATION_SCHEMA, TABLES

[0067] WHERE TABLE_SCHEMA='zone_llm_summary'

[0068] ORDER BY TABLE_NAME.

[0069] The table name-annotation mapping relationship obtained from the above example is shown in Table 1.

[0070] Table 1 shows the table name-annotation mapping relationship in the database "zone_llm_summary".

[0071]

[0072] Then, the above results are formatted. Combining the above example, Table 1 is formatted to obtain:

[0073] Weekly statistics on personnel entry and exit frequency: “people_in_exit_record_every_week”; Monthly statistics on import and export volume of bonded zones: “zone_in_export_statistics_month_report”; Monthly statistics on import and export volume of xx bonded zone: “zone_in_export_statistics_month_report_xx”.

[0074] Finally, the above string is embedded into the preset tool description template so that the tool can be quickly identified through the tool description, and then the target report data can be obtained through the identified tool. For example, when a user asks about bonded zone report analysis, it is easy for the large model to quickly identify and call the corresponding tool.

[0075] In practical applications, upon receiving a call request, a query is performed on the target table based on the table name in the request parameters. For example, if the database parameter in the request parameters is "zone_llm_summary" and the table name is "zone_in_export_statistics_month_report_xx", then the table metadata query is performed as follows:

[0076] select*from one_llm_summary.zone_in_export_statistics_month_report_xx.

[0077] The resulting query combinations are shown in Table 2.

[0078] Table 2 shows an example of the results of searching the table “zone_in_export_statistics_month_report_xx” in the “zone_llm_summary” database.

[0079]

[0080] As can be seen, the returned data is ultimately a collection of objects. When there are many data fields, the naming is not intuitive, or there are escape characters, directly returning a collection of objects will significantly reduce the ability of large models to understand the data, thus leading to incorrect parameters or reliance on fake data when generating charts.

[0081] Specifically, if this collection is directly used as the return value of the tool call, the large model will have difficulty understanding what data is being generated for the chart when calling the chart generation tool in the next step. This causes the large model to create its own set of fake data when providing the chart generation tool parameters, instead of using the data queried from the database report. The difficulty in understanding this includes the use of English field names, and the fact that the meaning of English is not accurate.

[0082] Secondly, if the report query has a large number of fields, the large model cannot know which fields to generate the report from and will directly return the collection. This will be subject to JSON serialization, resulting in a lot of transition characters in the text, which will affect the overall understanding and combination of the text.

[0083] Therefore, this application processes the returned data to simplify annotation fields, selectively extract key fields, and avoid JSON sequence interference, so as to provide the chart generation module 30 with the necessary context information (such as horizontal axis fields, vertical axis fields, chart type, etc.) for generating charts. This can help large models accurately understand how to use the data, avoid writing fake data, and ensure the accuracy of parameters.

[0084] Firstly, simplifying string generation includes:

[0085] S210, execute field metadata query to obtain numeric fields, date fields and field comments from the target list.

[0086] S220: For each target field, convert the target field and its corresponding field annotation into key-value pairs in a specified format.

[0087] S230, combining all key-value pairs, yields a simplified string with Chinese comments.

[0088] After identifying the specific table, the process begins by performing a field metadata query to obtain the names and comments of all fields in the table. Then, the data is filtered to obtain numeric fields, date fields, and field comments.

[0089] As an example, perform the following field metadata query:

[0090] SELECT COLUMN_NAME,COLUMN-TYPE,COLUMN_COMMENT

[0091] FROM INFORMATION_SCHEMA,COLUMNS

[0092] WHERE TABLE_SCHEMA='zone_llm_summary'AND TABLE_NAME='zone_in_export_statistics_month_report_xx'

[0093] ORDER BY ORDINAL_POSITON.

[0094] The results obtained from the above field metadata query are shown in Table 3.

[0095] Table 3 shows an example of the field metadata results.

[0096]

[0097] Among them, "bigint(20)" indicates that this is a large integer field; "varchar(100)" indicates that this is a string field with a length of no more than 100 characters; "decimal(10,0)" indicates that this is a decimal numeric field with a total of 10 digits and 0 decimal digits (i.e., an integer); "date" indicates that this is a date type field.

[0098] Then, the fields in Table 3 are filtered to remove fields without Chinese comments or fields whose data type is not one of the specified types (numeric or date). For example, the data set returned after filtering is:

[0099] [{

[0100] “id”:4,

[0101] "in_value": 120,

[0102] "export_value": 1200,

[0103] "total_value": 271202

[0104] "date": "20241201"

[0105] }, {

[0106] "id":11,

[0107] "in_value": 110,

[0108] "export_value": 1100,

[0109] "total_value": 271202

[0110] "date": "20241101"

[0111] }).

[0112] Then, the data is formatted into strings. Specifically, each target field is converted into a key-value pair in a specified format. For example, in the example above, “date”:“20241101” is converted into “Report Date: 2024-11-01”, or “in_value”:“110” is converted into “Import Amount: 110”.

[0113] In conjunction with the first aspect, based on the field order in the target list, each key-value pair is arranged sequentially and separated by semicolons.

[0114] Understandably, in order to maintain consistency with the original data order, the key-value pairs are sorted according to the field order in the original list, and a uniform delimiter (such as a semicolon) is used to connect the key-value pairs. This makes the generated simplified string structure more organized, which is convenient for subsequent programs or systems to parse and process according to fixed rules, thus improving the efficiency of automated processing.

[0115] Furthermore, since the field order remains consistent with the original list, users can more intuitively connect the simplified string to the original data structure, reducing the cost of understanding and improving the user experience.

[0116] Based on the above examples, the simplified strings are: Import value: 120, Export value: 1200, Total value: 271202, Report date: 2024-12-01; Import value: 110, Export value: 1100, Total value: 271202, Report date: 2024-11-01.

[0117] In conjunction with the first aspect, the generation of interactive chart links includes:

[0118] S310 uses the date field in the key-value pair data as the horizontal axis label, the numeric field as the vertical axis data, and the annotation containing the target list corresponding to the key-value pair data as the chart title.

[0119] S320, Generate interactive chart links based on the chart type parameter in the request.

[0120] By using date fields in key-value pairs as horizontal axis labels and numeric fields as vertical axis data, and combining them with annotation information from the target list as chart titles, the generated charts have clear semantic expression and intuitive visualization, making it easier for users to understand the data background and trends. By dynamically generating interactive chart links based on the chart type parameters in the request, the system can quickly support and switch between different chart types (such as bar charts, line charts, pie charts, etc.), improving its ability to adapt to diverse data display needs.

[0121] Understandably, in practical applications, users raise questions to the large model. The large model, through the tool description text added by the database module 10, accurately understands the purpose and data processing scenario of each tool, thus enabling it to accurately select the appropriate tool for the current work requirements. It then calls the tool module 20 to perform table queries and data processing, and constructs visual charts (selecting chart formats such as tables, bar charts, line charts, and pie charts according to the scenario) based on the simplified strings obtained by the tool module 20, and publishes reports and pushes corresponding web page links.

[0122] In addition to the first aspect, the tool also includes a communication interface module.

[0123] The communication interface module is responsible for receiving tool discovery requests from the MCP-Client, so that the MCP-Client can obtain information on available tools and enable the client to select appropriate tools for integration and use.

[0124] Upon receiving a tool discovery request, the communication interface module retrieves the optimized tool description text from the tool declaration module and returns it to the MCP-Client. This helps the MCP-Client better understand and integrate large model tools.

[0125] The communication interface module is also responsible for returning the interactive chart links generated by the chart generation module to the MCP-Client. These links can be used to generate the final answer, providing a more intuitive data display and interactive experience.

[0126] In conjunction with the first aspect, database connection parameters should include at least the URL, user, password, and driver name.

[0127] The URL is the connection address, which specifies the network location and connection information of the database server, and typically includes the protocol, host, port and database name.

[0128] The user is the database's authenticated account name and must have access permissions.

[0129] The driver name specifies the fully qualified name of the database driver class to ensure that the program can load the correct driver.

[0130] Secondly, this application provides a method for generating large model data reports based on MCP, combined with Figure 3 As shown, the method includes:

[0131] S010, the tool declaration module receives the tool discovery request sent by the MCP-Client, drives the database module to extract the database name based on the pre-configured database connection parameters, performs table metadata query to generate an optimized MCP tool description and returns it to the MCP-Client for large model integration toolset.

[0132] S020, the tool invocation module receives the tool invocation request forwarded by MCP-Client, parses the target table name in the request, generates a simplified string in non-JSON format, and calls the chart generation module to parse the simplified string to generate an interactive chart and return the value MCP-Client.

[0133] This application responds to the tool discovery request from the MCP-Client through the tool declaration module, providing a standardized tool description. The tool invocation module responds to the tool invocation request. Through the collaboration between the modules, the optimized MCP tool description is automatically generated based on metadata. Subsequently, the tool invocation module simplifies the string and automatically generates interactive charts and returns them. This solves the problem of tool invocation errors in traditional report generation, greatly improving data analysis efficiency, ease of use, and user interaction experience.

[0134] In conjunction with the second aspect, the steps of parsing the target table name in the request and generating a simplified non-JSON string include:

[0135] Perform a field metadata query to obtain numeric fields, date fields, and field comments from the target list.

[0136] For each target field, convert the target field and its corresponding field comments into key-value pairs in the specified format.

[0137] By combining all the key-value pairs, a simplified string with Chinese comments is obtained.

[0138] Specifically, the target table's field metadata is extracted from the database, including field names, data types, and comments. Then, field filtering is performed, and all filtered fields (numeric and date types) are traversed. For each field, the field name, Chinese comments, and field type are extracted. Fields and comments that meet the conditions are converted into key-value pairs in a specified format. Finally, all key-value pairs are combined into a single-line string for the tool to call the module for parsing.

[0139] In conjunction with the second aspect, the steps of calling the chart generation module to simplify string parsing and generate interactive charts include:

[0140] Use date fields from the key-value pair data as the horizontal axis labels, numeric fields as the vertical axis data, and use the comments that contain the target list corresponding to the key-value pair data as the chart title.

[0141] Generate interactive chart links based on the chart type parameter in the request.

[0142] Combination Figure 2 As shown, the generated chart is presented as an example, and an openable webpage link (i.e., an interactive chart link) is returned.

[0143] Thirdly, embodiments of this application provide an electronic device, combined with Figure 4 As shown, the electronic device includes a memory 131 and a processor 130. The memory 131 stores a computer program, and the processor 130 runs the computer program to make the electronic device perform the above-described method.

[0144] Furthermore, combined Figure 4 The electronic device shown also includes a bus 132 and a communication interface 133, with the processor 130, the communication interface 133 and the memory 131 connected via the bus 132.

[0145] The memory 131 may include high-speed random access memory (RAM) and may also include non-volatile memory, such as at least one disk storage device. Communication between this system network element and at least one other network element is achieved through at least one communication interface 133 (which can be wired or wireless), such as the Internet, wide area network, local area network, metropolitan area network, etc. The bus 132 may be an ISA bus, PCI bus, or EISA bus, etc. The bus can be divided into address bus, data bus, control bus, etc. For ease of representation, Figure 4 The symbol is represented by a single double-headed arrow, but this does not mean that there is only one bus or one type of bus.

[0146] Processor 130 may be an integrated circuit chip with signal processing capabilities. In implementation, each step of the above method can be completed by the integrated logic circuitry in the hardware of processor 130 or by instructions in software form. Processor 130 may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components. It can implement or execute the methods, steps, and logic block diagrams disclosed in the embodiments of this invention. The general-purpose processor may be a microprocessor or any conventional processor. The steps of the methods disclosed in the embodiments of this invention can be directly manifested as execution by a hardware decoding processor, or execution by a combination of hardware and software modules in the decoding processor. The software module can reside in a mature storage medium in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. This storage medium is located in memory 131, and processor 130 reads the information in memory 131 and, in conjunction with its hardware, completes the steps of the method described in the foregoing embodiments.

[0147] Fourthly, embodiments of this application provide a readable storage medium storing computer program instructions, which are read and executed by a processor to perform the above-described method.

[0148] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the system and apparatus described above can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.

[0149] Furthermore, in the description of the embodiments of the present invention, unless otherwise explicitly specified and limited, the terms "installation," "connection," and "linking" should be interpreted broadly. For example, they can refer to a fixed connection, a detachable connection, or an integral connection; they can refer to a mechanical connection or an electrical connection; they can refer to a direct connection or an indirect connection through an intermediate medium; and they can refer to the internal connection of two components. Those skilled in the art can understand the specific meaning of the above terms in the present invention based on the specific circumstances.

[0150] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0151] In the description of this invention, it should be noted that the terms "center," "upper," "lower," "left," "right," "vertical," "horizontal," "inner," and "outer," etc., indicate the orientation or positional relationship based on the orientation or positional relationship shown in the accompanying drawings. They are used only for the convenience of describing the invention and for simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation. Therefore, they should not be construed as limitations on the invention. Furthermore, the terms "first," "second," and "third" are used for descriptive purposes only and should not be construed as indicating or implying relative importance.

[0152] Finally, it should be noted that the above embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. An apparatus comprising a MCP-based large model data report generation tool, characterized in that, An apparatus adopting MCP-Server architecture and communicating with MCP-Client through SSE protocol, comprising: a database module configured with database connection parameters; the database module is used to execute SQL query to obtain all table names and Chinese annotations of the current library, and embed structured data in the form of the specified form into tool description text after formatting the query results; the database module is also used to query table structure and table data according to table name; a tool module connected with the database module; the tool module includes a tool declaration module and a tool calling module; the tool declaration module is used to return the optimized tool description text including the table annotation and table name mapping string generated by the database module in response to the tool discovery request sent by the large model through the MCP-Client; the tool calling module is used to query target table data according to the table name in the request parameter and convert the target table data into a simplified string with Chinese annotations in response to the tool calling request sent by the large model through the MCP-Client; a chart generation module connected with the tool module, used to parse the key-value pair data in the simplified string, and generate interactive chart links based on the key-value pair data.

2. The apparatus of claim 1, wherein, The generation of the tool description text includes: extracting the database name from the database connection parameters; executing table metadata query to obtain the table name-annotation mapping relationship of each table; formatting the mapping relationship into a string in a specified form; embedding the string into a preset tool description template.

3. The apparatus of claim 2, wherein, The generation of the simplified string includes: executing field metadata query to obtain numerical fields, date type fields and field annotations in the target table; for each target field, converting the target field and the corresponding field annotation into a key-value pair in a specified form; combining all the key-value pairs to obtain the simplified string with Chinese annotations.

4. The apparatus of claim 3, wherein, The generation of the simplified string also includes: sequentially arranging each key-value pair based on the field arrangement order in the target table and separating them with semicolons.

5. The apparatus of claim 3, wherein, The generation of the interactive chart link includes: using the date type field in the key-value pair data as the horizontal axis label, the numerical type field as the vertical axis data, and backtracking the annotation of the target table containing the key-value pair data as the chart title; generating the interactive chart link based on the chart type parameter in the request.

6. The apparatus of claim 1, wherein, It also includes a communication interface module for receiving the tool discovery request sent by the large model through the MCP-Client; the communication interface module is also used to return the optimized tool description text output by the tool declaration module to the MCP-Client for large model tool integration; the communication interface module is also used to return the interactive chart link generated by the chart generation module to the MCP-Client for generating the final answer.

7. The apparatus of claim 1, wherein, The database connection parameters at least include URL, user, password and driver name.

8. A method for generating a large model data report table based on MCP, characterized in that, The method is applied to the apparatus of any one of claims 1-7; the method includes: The tool declaration module receives a tool discovery request sent by the large model through the MCP-Client, drives the database module to extract a database name based on a preconfigured database connection parameter, executes a table metadata query to generate an optimized tool description text, and returns the optimized tool description text to the MCP-Client for large model integrated tool set; The tool calling module receives a tool calling request sent by the large model through the MCP-Client, parses a target table name in the request to generate a simplified string in a non-JSON format, and calls the chart generation module to parse the simplified string to generate an interactive chart and return the interactive chart to the MCP-Client.

9. The method of claim 8, wherein, The step of parsing the target table name in the request to generate the simplified string in the non-JSON format comprises: performing a field metadata query to obtain numerical fields, date type fields, and field annotations in the target list; for each target field, converting the target field and the corresponding field annotation into a key-value pair in a specified form; combining all the key-value pairs to obtain the simplified string with Chinese annotations.

10. The method of claim 9, wherein, The step of calling the chart generation module to parse the simplified string to generate the interactive chart comprises: taking the date type fields in the key-value pair data as horizontal axis labels, taking the numerical fields as vertical axis data, and taking annotations of the target list corresponding to the key-value pair data as a chart title; generating the interactive chart link based on a chart type parameter in the request.

Citation Information

Patent Citations

  • Database table structure exporting method and device and terminal equipment

    CN111352986A

  • Report generation method and device based on large language model and storage medium

    CN118917296A