A Workflow Intelligent Orchestration Method Based on Database MCP Service
By introducing the database MCP service and LLM, automatic conversion from natural language to SQL is achieved, solving the problems of high development threshold, low efficiency and poor flexibility in existing technologies, and realizing intelligent workflow orchestration and zero-code data query.
Patent Information
- Application Number
- CN202610204225.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-12
- Publication Date
- 2026-06-02
AI Technical Summary
Existing technologies in workflow applications suffer from rigid database query logic, high development barriers, low development efficiency, poor system flexibility, and high interface coupling, making it impossible to achieve automatic conversion from natural language to machine instructions. This makes it difficult for non-technical personnel to build or adjust data query logic.
By introducing database MCP services and Large Language Model (LLM), SQL statements are directly generated through natural language descriptions. Combined with the database schema knowledge base, intelligent workflow orchestration is achieved, data query services are dynamically generated, business logic and execution logic are decoupled, and visual node configuration is used.
It lowers the technical threshold, enabling non-technical personnel to participate in data workflow construction, improving development and orchestration efficiency, enhancing system flexibility and maintainability, and supporting business-driven agile development.
Smart Images

Figure CN122132135A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of artificial intelligence technology, specifically to a workflow intelligent orchestration method based on database MCP services. Background Technology
[0002] In existing technologies, the following solutions are mainly used to enable interaction between workflow applications (such as data analysis platforms, report generation systems, business processing flows, etc.) and the underlying database: 1. Hard-coded interface mode This is the most traditional and common implementation. Developers need to manually write specific application programming interfaces (APIs) for each specific data query requirement. In the backend logic of these APIs, developers directly write specific SQL query statements, execute the queries through database connection drivers such as JDBC and ODBC, and encapsulate the results as structured data for return. Whenever the query logic changes or the data table structure is updated, developers need to manually modify the SQL statements and redeploy the code.
[0003] 2. ORM Framework Pattern To reduce the complexity of writing direct SQL and improve development efficiency, the industry commonly uses Object-Relational Mapping (ORM) frameworks, such as MyBatis, Hibernate, and Spring Data JPA. This approach maps database tables to objects (classes) in the programming language, allowing developers to access the database by manipulating objects and methods without writing large amounts of raw SQL. However, this still requires developers to define data models, write mapping configuration files or method annotations, and essentially demands a deep understanding of database structure and SQL, with query logic embedded in the code, making dynamic generation or intelligent adjustment impossible.
[0004] 3. Multiple interface calls in traditional workflow orchestration In complex workflow scenarios, a business process may need to access multiple different data sources or perform multiple data operations. Existing technologies typically require chaining multiple data interfaces created by the two aforementioned models. Workflow engines (such as Activiti, Camunda, or custom process controllers) need to sequentially call these pre-developed, single-function interfaces and manually handle data transfer and dependencies between these interfaces. For example, a workflow for "generating a customer analysis report" may need to sequentially call multiple independent interfaces such as "querying basic customer information," "querying customer order history," and "calculating customer consumption statistics," using the output of the previous interface as the input of the next, resulting in complex process design and high coupling between interfaces.
[0005] Based on the above-mentioned existing technical solutions, the main problems and disadvantages are as follows: 1. High development threshold and strong dependence on technology Accessing the database must be achieved through manually written interfaces and SQL statements. Developers not only need to understand table structures, field types, and relationships, but also need to master SQL syntax and performance optimization techniques. Non-technical personnel (such as analysts, operations engineers, and business experts) cannot directly build or adjust data query logic, resulting in a significant technical barrier between development and use.
[0006] 2. Low development efficiency and difficulty in process expansion. Every new data query requirement, regardless of size, needs to go through a complete development cycle of "interface design -> SQL writing / ORM configuration -> code development -> testing and deployment". Different query scenarios require rewriting similar logic, resulting in a large amount of redundant code. In a multi-data source environment, it is even more necessary to maintain multiple interfaces and connection configurations, leading to low development efficiency and difficulty in quickly responding to business changes.
[0007] 3. Poor system flexibility and high maintenance costs. The data query logic is hard-coded and fixed within the application. When the database table structure or field names change, all related interfaces must be manually modified. The query logic is embedded in the program and cannot be dynamically generated based on business semantics or data context. This makes the system difficult to maintain, extremely inflexible, and unable to achieve dynamic, on-demand data queries.
[0008] 4. Complex workflow orchestration and high interface coupling. Introducing data query capabilities into workflows requires the pre-development and integration of numerous single-function data interface microservices. This results in lengthy and complex workflow diagrams, cluttered with a large number of interface call nodes. Workflow designers not only need to understand the business logic but also the specific functions and input / output specifications of these underlying interfaces, increasing orchestration complexity and the probability of errors.
[0009] 5. A gap exists between natural language and machine instructions. Current technology cannot directly and automatically convert natural human business needs (such as "Find all VIP customers who purchased more than 10,000 yuan last month") into executable machine instructions (SQL queries). This conversion process relies entirely on the human understanding and translation of developers, which is prone to misunderstandings and cannot achieve intelligent or adaptive workflow orchestration.
[0010] Therefore, we need to propose a workflow intelligent orchestration method based on database MCP services. Summary of the Invention
[0011] The purpose of this invention is to provide a workflow intelligent orchestration method based on database MCP service, which eliminates the semantic gap between "business requirements" and "SQL code", lowers the threshold for developing and using database query functions, and improves the agility and intelligence of workflow data orchestration, so as to solve the problems mentioned in the background art.
[0012] To achieve the above objectives, the present invention provides the following technical solution: a workflow intelligent orchestration method based on database MCP service, comprising the following steps: S1. Users submit their requirements using natural language descriptions through the front-end interface; S2. When the workflow engine reaches a data query node, it retrieves the natural language query description pre-entered by the user from the configuration of that node. S3. The system retrieves descriptions of data tables and fields related to the current query from the database schema knowledge base; S4. The workflow engine sends the SQL statement generated by the LLM to the database MCP service via the standard MCP protocol. The database MCP service receives the SQL, establishes a connection with the target database within itself, and executes the SQL in a read-only session. S5. The database MCP service obtains the result set of the SQL execution. The database MCP service encapsulates the result set into a standard data format and returns it to the workflow engine. The workflow engine receives the result set and stores it in the workflow's context variables for use by subsequent nodes. S6. Utilize LLM to analyze the SQL result set executed by the database MCP service and combine it with knowledge base information to respond to user input requirements.
[0013] Preferably, in step S1, the user configures a data query node in the workflow design interface, and directly describes the data query requirements using natural language in the configuration items of the data query node.
[0014] Preferably, in step S2, when the workflow engine runs to the data query node, it triggers the execution logic of the node. The workflow engine first reads the natural language query description text pre-filled by the user from the attribute configuration of the node, and activates the user-defined business intent from the static configuration into a dynamic execution instruction, so as to realize the connection between the workflow control logic and the data query service.
[0015] Preferably, in step S2, during semantic parsing and intent recognition, LLM analyzes the input text and extracts key elements including: data topic, data scope, and aggregation metrics.
[0016] Preferably, in step S3, when calling the database schema knowledge base, the database schema knowledge base is called according to the key elements extracted by the LLM, and relevant database table information is queried. The database table information includes the database name, data table name, field semantics, and the correspondence between structure type ID and name. The field semantics include ID identifier, structure name, structure type ID, and whether it is enabled.
[0017] Preferably, in step S3, a structured prompt word template is constructed, the prompt word template including: System role setting: The LLM is required to act as a professional SQL expert; Database schema information: Insert relevant table structure information retrieved from the knowledge base; User query request: Insert a natural language description entered by the user; Output format requirements: The LLM should only output standard SQL query statements without any additional interpretation; Send the constructed prompts to the LLM and receive the SQL query statement returned by the LLM.
[0018] Preferably, in step S4, the workflow engine integrates the natural language query description in step S2 and the database schema information retrieved in step S3 into a structured prompt word, calls the LLM, and the LLM generates a standard SQL query statement that conforms to the syntax and business logic based on the prompt word. Then, the workflow engine sends the generated SQL query statement to the database MCP service through MCP.
[0019] Preferably, in step S4, the database MCP service acts as a proxy between the workflow and the database. After receiving the SQL query statement, it manages the database connection pool, establishes a session with the target database, and executes the SQL query statement in a preset read-only session to prevent accidental data modification operations and isolate database access permissions and risks within the MCP service.
[0020] Preferably, in step S5, after the database MCP service executes the SQL query statement, it obtains the original query result set from the database. The database MCP service encapsulates the results into a standardized and easily processed data format. After encapsulation, the database MCP service returns the results to the workflow engine through the MCP protocol. After receiving the results, the workflow engine stores them in the workflow context variable and assigns a variable name. This means that any subsequent node in the process can directly use this variable name to obtain the query results, thereby realizing the transmission and sharing of data in the workflow.
[0021] Preferably, in step S6, the SQL execution result and related knowledge base information obtained in step S5 are used as input and provided to the LLM. The LLM analyzes the input data and generates a summary answer based on the user's initial natural language requirements.
[0022] Compared with the prior art, the beneficial effects of the present invention are: 1. This invention introduces database MCP services to abstract metadata such as database structure, table field relationships, and index information into a unified context model. Combined with the understanding of natural language instructions by the Large Language Model (LLM), it realizes the automated translation process of "natural language → SQL statement → query execution". This allows business personnel or workflow designers to directly describe data requirements using natural language, breaking down technical barriers and enabling non-technical personnel to participate in the construction of complex data workflows. This significantly reduces the technical threshold and development costs, and enables business-driven agile development.
[0023] 2. This invention transforms fixed, pre-developed data interfaces into dynamic, on-demand generated data services, and provides a unified interactive entry point through visualized intelligent nodes, achieving "zero-code" rapid delivery of data query functions. Workflow designers only need to configure an "intelligent data query" node in the graphical interface and input a natural language description to dynamically generate the required data capabilities, without waiting for development scheduling or piling up a large number of interface call nodes in the flowchart, significantly improving development and orchestration efficiency and achieving "zero-code" delivery of data query functions.
[0024] 3. This invention decouples business logic (natural language description) from execution logic (SQL code) and manages metadata through a centralized knowledge base. The impact of changes is isolated at the configuration level without affecting the code layer. When business requirements change, only the natural language description of the corresponding node needs to be modified. When the database schema changes, only the relevant description needs to be updated in the database schema knowledge base. The system can automatically adapt to the new changes without modifying or redeploying the code, greatly enhancing the system's flexibility and maintainability, and easily coping with business and data changes. Attached Figure Description
[0025] Figure 1 This is a flowchart of the present invention. Detailed Implementation
[0026] The technical solutions of the embodiments 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, and 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.
[0027] Please see Figure 1 This invention provides a technical solution: a workflow intelligent orchestration method based on database MCP service. Its core concept is to deeply integrate the natural language understanding and code generation capabilities of Large Language Model (LLM) with database services through Model Context Protocol (MCP), and build an intelligent data access layer based on this, seamlessly integrating it into the workflow engine, thereby realizing the direct driving of data query in the workflow with natural language.
[0028] This method can be applied to any system or platform that requires a tight integration of business processes and data queries, especially low-code / no-code platforms and intelligent automation systems.
[0029] The technical approach of this method is to build a workflow engine system that integrates the intelligent database MCP service. By introducing a large language model as a "natural language to SQL" translator and supplementing it with a database knowledge base to provide context, the data interface call nodes that need to be hard-coded in the traditional workflow are replaced with a configurable intelligent data query node that supports natural language description, thereby realizing the automation and intelligence of workflow data orchestration.
[0030] This method includes the following steps: S1. Users submit their requirements through the front-end interface using natural language; for example: "What tunnel structures are there on the Anxin Cloud Platform? How many are there in total?", and this input is passed to the LLM model for analysis.
[0031] In the workflow design interface, users can configure a data query node and directly describe their data query requirements using natural language in the configuration options of the data query node.
[0032] Within the properties or configuration items of the data query node, there is a dedicated input box for directly describing data query requirements using natural language. This replaces the complex configuration required in the traditional model, which necessitates filling in database connection parameters, SQL statements, or selecting specific API interfaces.
[0033] This process marks the starting point for the transformation from "business requirements" to "machine instructions," transforming the highly technical parameter configuration process in traditional workflows, which requires developer intervention, into an intuitive natural language interaction that business personnel or workflow designers can easily use.
[0034] S2. When the workflow engine reaches a data query node, it retrieves the natural language query description pre-entered by the user from the configuration of that node. When the workflow engine reaches the data query node, it triggers the execution logic of that node. The workflow engine first reads the natural language query description text pre-filled by the user from the attribute configuration of that node, and activates the user-defined business intent from the static configuration into a dynamic execution instruction to connect the workflow control logic and the data query service. As the central controller, the workflow engine obtains the specific task objective (natural language description) at this moment, and then it can schedule subsequent resources such as LLM, knowledge base, and MCP services to collaboratively complete this objective.
[0035] In semantic parsing and intent recognition, LLM analyzes the input text and extracts key elements including: data topic, data scope, and aggregation metrics.
[0036] The workflow engine is in a normal process execution state, executing each node sequentially according to the execution path. When the execution pointer reaches the data query node, the engine loads and executes the specific logic encapsulated within that node.
[0037] The workflow engine accesses the attribute configuration of the data query node. The workflow engine reads the natural language query description text pre-filled by the user from a specific field or attribute in the node configuration. Then, it activates the static business intent defined by the user during orchestration (stored in the node configuration) as a dynamic execution instruction at runtime.
[0038] S3. The system retrieves descriptions of data tables and fields related to the current query from the database schema knowledge base; When calling the database schema knowledge base, based on the key elements extracted from the LLM, the database schema knowledge base is called and relevant database table information is queried. The database table information includes the database name (e.g., anxinyun), the data table name (e.g., t_structure), the field semantics, and the correspondence between the structure type ID and the name. The field semantics include ID identifier, structure name, structure type ID, and whether it is enabled.
[0039] Construct a structured prompt word template, the prompt word template including: System role setting: The LLM is required to act as a professional SQL expert; Database schema information: Insert relevant table structure information retrieved from the knowledge base; User query request: Insert a natural language description entered by the user; Output format requirements: The LLM should only output standard SQL query statements without any additional interpretation; Send the constructed prompts to the LLM and receive the SQL query statement returned by the LLM.
[0040] The information retrieved in step S3 forms the core of the structured prompts sent to the LLM subsequently. It transmits the specific database schema information that the LLM needs to know to the LMM, constrains and guides the LLM's generation process, and prevents the LLM from "guessing" or generating incorrect SQL due to a lack of context.
[0041] This process configures a database schema knowledge base for the LLM. By querying a knowledge base rich in business semantics, keywords in the user's vague natural language requirements are transformed into specific, usable database tables, fields, and mapping relationships, providing indispensable contextual information for the LLM to generate accurate and executable SQL statements.
[0042] S4. The workflow engine sends the SQL statement generated by the LLM to the database MCP service via the standard MCP protocol. The database MCP service receives the SQL, establishes a connection with the target database within itself, and executes the SQL in a read-only session. The workflow engine integrates the natural language query description from step S2 and the database schema information retrieved in step S3 into a structured prompt term. It then calls the LLM (Local Management Module), which generates a standard SQL query statement that conforms to the syntax and business logic based on the prompt term. Finally, the workflow engine sends the generated SQL query statement to the database MCP service via MCP. MCP defines a standardized interface for communication between the workflow engine and the database service.
[0043] The database MCP service acts as a proxy between the workflow and the database. After receiving SQL query statements, it manages the database connection pool, establishes a session with the target database, and executes the SQL query statements in a preset read-only session to prevent accidental data modification operations, thus isolating database access permissions and risks within the MCP service.
[0044] By introducing the MCP protocol, the execution logic of the workflow engine is decoupled from specific database operations. There is no need to care about the database type and connection details; you only need to call the MCP service through the standard interface.
[0045] Centralizing database access permissions to the MCP service and executing dynamically generated SQL by forcing read-only sessions effectively prevents accidental data tampering and resolves security concerns arising from dynamic SQL execution.
[0046] This process reliably executes dynamically generated SQL statements from the LLM through a standardized and secure database MCP service. It ensures both execution efficiency and compatibility (supporting multiple databases) while guaranteeing data security through strict session control.
[0047] S5. The database MCP service obtains the result set of the SQL execution. The database MCP service encapsulates the result set into a standard data format and returns it to the workflow engine. The workflow engine receives the result set and stores it in the workflow context variable for use by subsequent nodes. The workflow context is a storage area that exists within the lifecycle of a process instance and is used to transfer data between nodes.
[0048] After executing the SQL query, the database MCP service retrieves the raw query result set from the database. The database MCP service then encapsulates the results into a standardized and easily processed data format. After encapsulation, the database MCP service returns the results to the workflow engine through the MCP protocol. Upon receiving the results, the workflow engine stores them in the workflow's context variables and assigns a variable name. This variable name can then be used by any subsequent node in the process to retrieve the query results, thus enabling data transfer and sharing within the workflow.
[0049] Step S5 marks the completion of the data query node task. This node not only retrieves the data but also successfully inputs it into the workflow engine, becoming the driving force for the continued operation of the business process. Traditional methods require connecting multiple interfaces and manually handling data transfer; this process achieves automatic data transfer, greatly simplifying the orchestration of complex business processes involving data dependencies.
[0050] S6. Utilize LLM to analyze the SQL result set executed by the database MCP service and combine it with knowledge base information to respond to user input requirements.
[0051] The SQL execution results and related knowledge base information obtained in step S5 are used as input to provide to the LLM. The LLM analyzes the input data and generates a summary answer based on the user's initial natural language requirements.
[0052] Step S6 will call LLM again and construct a new prompt word, which includes: Original user requirement: Reiterate the natural language question entered by the user in step S1; SQL execution results: Provides the raw query results data that have been standardized (e.g., in JSON format) and obtained in the S5 steps; Related knowledge base information: Provides database schema knowledge related to queries (such as the business meaning of fields) to help LLM correctly understand the background of the data; Output format instructions: These instructions require the LLM to analyze and summarize the data and output the final answer in a specific, easy-to-understand format (such as a point list, table, or summary statement).
[0053] This process transforms rigid, structured database query results into semantic results that conform to human language habits and contain business insights.
[0054] To ensure the stable operation of this method, the system architecture of this invention includes: User interaction layer: Provides user operation entry points and receives user natural language requests or task definitions; Workflow orchestration engine (FastGPT): Used to control the task flow of each step, with capabilities such as condition judgment, error rollback, and branch logic control; Database MCP Service Layer: Runs as an independent, standard MCP server, serving as an intelligent proxy and security gateway between the workflow engine and the target database; Database Schema Knowledge Base: A structured repository for storing and managing database metadata and its business semantic information; Natural Language Understanding and SQL Generation Layer: Based on the Large Language Model (LLM), natural language is translated and converted into executable SQL statements using a knowledge base.
[0055] In summary, during the execution of this method, the user first submits a data query request in natural language through the system interface. The system then sends the "user-input" natural language text to a Large Language Model (LLM), which transforms the natural language into structured, actionable query elements, laying the foundation for generating accurate SQL statements.
[0056] To transform the parsed query elements into actual SQL, the system calls the database schema knowledge base to obtain metadata information from the database, including data tables, fields, and their meanings. LLM combines the previously obtained semantic parsing results and database schema information to generate a grammatically correct and executable SQL query statement.
[0057] Then, the system calls the database MCP service to run the generated SQL statements and obtain the execution results. Finally, AI, combined with a knowledge base, analyzes and summarizes the SQL result set and outputs the results.
[0058] Although embodiments of the invention have been shown and described, it will be understood by those skilled in the art that various changes, modifications, substitutions and alterations can be made to these embodiments without departing from the principles and spirit of the invention, the scope of which is defined by the appended claims and their equivalents.
Claims
1. A workflow intelligent orchestration method based on database MCP service, characterized in that, Includes the following steps: S1. Users submit their requirements using natural language descriptions through the front-end interface; S2. When the workflow engine reaches a data query node, it retrieves the natural language query description pre-entered by the user from the configuration of that node. S3. The system retrieves descriptions of data tables and fields related to the current query from the database schema knowledge base; S4. The workflow engine sends the SQL statement generated by the LLM to the database MCP service via the standard MCP protocol. The database MCP service receives the SQL, establishes a connection with the target database within itself, and executes the SQL in a read-only session. S5. The database MCP service obtains the result set of the SQL execution. The database MCP service encapsulates the result set into a standard data format and returns it to the workflow engine. The workflow engine receives the result set and stores it in the workflow's context variables for use by subsequent nodes. S6. Utilize LLM to analyze the SQL result set executed by the database MCP service and combine it with knowledge base information to respond to user input requirements.
2. The intelligent workflow orchestration method based on database MCP service according to claim 1, characterized in that: In step S1, the user configures a data query node in the workflow design interface and directly describes the data query requirements using natural language in the configuration items of the data query node.
3. The intelligent workflow orchestration method based on database MCP service according to claim 1, characterized in that: In step S2, when the workflow engine reaches the data query node, it triggers the execution logic of that node. The workflow engine first reads the natural language query description text pre-filled by the user from the attribute configuration of that node, and activates the user-defined business intent from the static configuration into a dynamic execution instruction, so as to realize the connection between the workflow control logic and the data query service.
4. The intelligent workflow orchestration method based on database MCP service according to claim 1, characterized in that: In step S2, during semantic parsing and intent recognition, LLM analyzes the input text and extracts key elements including: data topic, data scope, and aggregation metrics.
5. The intelligent workflow orchestration method based on database MCP service according to claim 1, characterized in that: In step S3, when calling the database schema knowledge base, the database schema knowledge base is called according to the key elements extracted by LLM, and relevant database table information is queried. The database table information includes the database name, data table name, field semantics, and the correspondence between structure type ID and name. The field semantics include ID identifier, structure name, structure type ID, and whether it is enabled.
6. The intelligent workflow orchestration method based on database MCP service according to claim 1, characterized in that: In step S3, a structured prompt word template is constructed, the prompt word template including: System role setting: The LLM is required to act as a professional SQL expert; Database schema information: Insert relevant table structure information retrieved from the knowledge base; User query request: Insert a natural language description entered by the user; Output format requirements: The LLM should only output standard SQL query statements without any additional interpretation; Send the constructed prompts to the LLM and receive the SQL query statement returned by the LLM.
7. The intelligent workflow orchestration method based on database MCP service according to claim 1, characterized in that: In step S4, the workflow engine integrates the natural language query description from step S2 and the database schema information retrieved in step S3 into a structured prompt word, calls the LLM, and the LLM generates a standard SQL query statement that conforms to the syntax and business logic based on the prompt word. Then, the workflow engine sends the generated SQL query statement to the database MCP service through MCP.
8. The intelligent workflow orchestration method based on database MCP service according to claim 1, characterized in that: In step S4, the database MCP service acts as a proxy between the workflow and the database. After receiving the SQL query statement, it manages the database connection pool, establishes a session with the target database, and executes the SQL query statement in a preset read-only session to prevent accidental data modification operations and isolate database access permissions and risks within the MCP service.
9. The intelligent workflow orchestration method based on database MCP service according to claim 1, characterized in that: In step S5, after the database MCP service executes the SQL query statement, it retrieves the original query result set from the database. The database MCP service encapsulates the results into a standardized and easily processed data format. After encapsulation, the database MCP service returns the results to the workflow engine through the MCP protocol. After receiving the results, the workflow engine stores them in the workflow context variable and assigns a variable name. This variable name can be directly used by any subsequent node in the process to retrieve the query results, thus realizing the transfer and sharing of data in the workflow.
10. The intelligent workflow orchestration method based on database MCP service according to claim 1, characterized in that: In step S6, the SQL execution results and related knowledge base information obtained in step S5 are used as input and provided to the LLM. The LLM analyzes the input data and generates a summary answer based on the user's initial natural language requirements.