focus_mcp_sql_engine
An advanced Model Context Protocol (MCP) mechanism engineered to translate conversational queries into precise SQL syntax via a sequential, dual-phase methodology, thus mitigating generative model inaccuracies and fostering high user confidence, particularly among non-specialists.
Author

FocusSearch
Quick Info
Actions
Tags
FOCUS DATA MCP Server [中文]
A Model Context Protocol (MCP) utility facilitating the transformation of natural language instructions into executable Structured Query Language (SQL) statements via an AI assistant interface.
Rationale for this Text-to-SQL Solution
Fundamentally, focus_mcp_sql employs a chained, two-stage SQL construction pipeline. This architecture is deliberately designed to exert granular oversight over Large Language Model (LLM) hallucinations, thereby establishing unwavering trust in the resultant SQL queries for users lacking deep technical expertise.
Here is a comparative assessment detailing focus_mcp_sql against established alternatives:
Comparative Matrix Analysis
This table contrasts the operational characteristics of focus_mcp_sql with prevalent LLM-based frameworks:
| Characteristic | Conventional LLM Systems | focus_mcp_sql Implementation |
|---|---|---|
| Generation Flow | Opaque, monolithic SQL creation | Explicit, bipartite (tokenization + SQL synthesis) |
| Error Propensity | Elevated, contingent on foundational model quality | Diminished, controlled via intermediate verification step |
| Operational Latency | Relatively high, dependent on extensive model computation | Low, benefits from deterministic keyword-to-SQL mapping |
| Operational Expense | Significant, necessitates high-tier model deployment | Reduced, minimizes dependency on resource-intensive models |
| Novice User Utility | Limited, verification of output is challenging | Superior, output validation simplified via keyword inspection |
Core Capabilities
- Facilitate initial model bootstrapping and setup.
- Execute the translation of human language into formal SQL commands.
Prerequisites for Deployment
- Java Development Kit (JDK) version 23 or newer. Obtain from jdk
- Gradle build automation tool version 8.12 or later. Download gradle
- A valid bearer token secured from Datafocus. Steps:
- Complete user registration at Datafocus
- Provision a new application entity.
- Access the newly created application instance.
- Navigate to Admin -> Interface Authentication -> Bearer Token -> Generate New Token
Deployment Procedure
- Obtain the source code repository:
bash git clone https://github.com/FocusSearch/focus_mcp_sql.git cd focus_mcp_sql
- Compile and package the server application:
bash gradle clean gradle bootJar
The resultant executable file path: build/libs/focus_mcp_sql.jar
MCP Configuration Integration
Integrate the server configuration into your primary MCP settings manifest:
{ "mcpServers": { "focus_mcp_data": { "command": "java", "args": [ "-jar", "path/to/focus_mcp_sql/focus_mcp_sql.jar" ], "autoApprove": [ "gptText2sqlStart", "gptText2sqlChat" ] } } }
Callable Functions (Tools)
1. gptText2sqlStart
Functionality: Initializes the underlying data model context.
Mandatory Arguments:
model(Type: object): Schema definition for the database tables.bearer(Type: string): Authentication token for API access.
Optional Arguments:
language(Type: string): Specifies the desired operational language (options: ['english','chinese'])
Invocation Example:
{ "model": { "tables": [ { "columns": [ { "columnDisplayName": "name", "dataType": "string", "aggregation": "", "columnName": "name" }, { "columnDisplayName": "address", "dataType": "string", "aggregation": "", "columnName": "address" }, { "columnDisplayName": "age", "dataType": "int", "aggregation": "SUM", "columnName": "age" }, { "columnDisplayName": "date", "dataType": "timestamp", "aggregation": "", "columnName": "date" } ], "tableDisplayName": "test", "tableName": "test" } ], "relations": [
],
"type": "mysql",
"version": "8.0"
}, "bearer": "ZTllYzAzZjM2YzA3NDA0ZGE3ZjguNDJhNDjNGU4NzkyYjY1OTY0YzUxYWU5NmU=" }
Schema Parameter Deep Dive (model Argument):
| Element Name | Location | Data Type | Requirement | Description |
|---|---|---|---|---|
| model | body | object | Yes | Database Structure Definition |
| » type | body | string | Yes | Database System Identifier |
| » version | body | string | Yes | System Version Number |
| » tables | body | [object] | Yes | Array detailing all relevant table structures |
| »» tableDisplayName | body | string | No | Human-readable alias for the table |
| »» tableName | body | string | No | The actual database table name |
| »» columns | body | [object] | No | List of attribute specifications for the table |
| »»» columnDisplayName | body | string | Yes | Alias for the column field |
| »»» columnName | body | string | Yes | The native column name |
| »»» dataType | body | string | Yes | The underlying data type classification |
| »»» aggregation | body | string | Yes | Default aggregation function if applicable |
| » relations | body | [object] | Yes | Definition of table join dependencies |
| »» conditions | body | [object] | No | Specific criteria for linking tables |
| »»» dstColName | body | string | No | Source column name from the 'dimension' table in the join |
| »»» srcColName | body | string | No | Source column name from the 'fact' table in the join |
| »» dimensionTable | body | string | No | The foreign/dimension table identifier |
| »» factTable | body | string | No | The primary/fact table identifier |
| »» joinType | body | string | No | Type of SQL join operation (e.g., INNER, LEFT) |
2. gptText2sqlChat
Functionality: Executes the natural language to SQL conversion based on the initialized context.
Mandatory Arguments:
chatId(Type: string): Unique identifier for the current conversational session.input(Type: string): The user's query phrased in natural language.bearer(Type: string): The required authentication credential.
Invocation Example:
{ "chatId": "03975af5de4b4562938a985403f206d4", "input": "what is the max age", "bearer": "ZTllYzAzZjM2YzA3NDA0ZGE3ZjguNDJhNDjNGU4NzkyYjY1OTY0YzUxYWU5NmU=" }
Standardized Output Contract
All invoked tools return data conforming to this uniform JSON structure:
{ "errCode": 0, "exception": "", "msgParams": null, "promptMsg": null, "success": true, "data": { } }
Example Workflow within Visual Studio Code Client
- Install the necessary cline extension for VSCode.
-
Configure the mcp server details as shown above.
-
Execution Sequence:
-
Execute the model initialization tool (
gptText2sqlStart). -
Submit the query: what is the max age
-
Support and References
Community Discussion Forum: https://discord.gg/mFa3yeq9 REFERENCE DOCUMENTATION: XMLHttpRequest (XHR) is an Application Programming Interface, realized as a JavaScript object, whose methods facilitate the transmission of HTTP requests from a web browser environment to a remote web server. These methods empower browser-based applications to dispatch server requests subsequent to page rendering completion, and subsequently receive retrieved data. XMLHttpRequest is an integral constituent of the Ajax programming paradigm. Prior to Ajax, interaction with the server primarily relied upon traditional hyperlinks and form submissions, frequently resulting in a complete page reload. This utility is distinct from that technology.
== Historical Context == The conceptual foundation for XMLHttpRequest was first posited in the year 2000 by the development team behind Microsoft Outlook. This concept was subsequently implemented within the Internet Explorer 5 browser release (1999). However, the initial syntax did not employ the standardized 'XMLHttpRequest' identifier. Instead, developers utilized the identifiers ActiveXObject("Msxml2.XMLHTTP") and ActiveXObject("Microsoft.XMLHTTP"). As of Internet Explorer version 7 (released 2006), universal browser support for the 'XMLHttpRequest' identifier was established. The 'XMLHttpRequest' identifier has since become the universally accepted standard across all major browser engines, encompassing Mozilla's Gecko rendering engine (2002), Safari version 1.2 (2004), and Opera version 8.0 (2005).
=== Standardization Process === The World Wide Web Consortium (W3C) formally published the initial Working Draft specification for the XMLHttpRequest object on April 5, 2006. On February 25, 2008, the W3C released the Level 2 specification working draft. Level 2 introduced crucial enhancements such as methods for monitoring data transfer progress, enabling cross-site communication, and handling binary byte streams. By the conclusion of 2011, the features defined in the Level 2 specification were formally merged back into the primary specification document. At the close of 2012, development stewardship transitioned to the WHATWG group, which now maintains the living standard document utilizing the Web IDL (Interface Definition Language) specification.
== Operational Usage Pattern == Generally, the process of dispatching a server request using XMLHttpRequest involves several sequential programming operations.
- Instantiate an XMLHttpRequest object by invoking its constructor:
- Invoke the "open" method to define the request methodology (GET/POST), specify the target resource URI, and select between synchronous or asynchronous execution mode:
- If an asynchronous request is selected, establish an event listener function designed to execute upon changes in the request's state:
- Commence the network transmission by executing the "send" method, optionally passing payload data:
- Process state transitions within the assigned event listener callback. Upon successful data receipt from the server, the payload is typically accessible via the "responseText" property. Once the object completes processing the response, its state transitions to 4, designated as the "done" state. Beyond these fundamental steps, XMLHttpRequest offers numerous configuration points to dictate request transmission behavior and response handling. Custom header fields can be programmatically injected into the request to communicate specific server instructions, and data payloads can be transmitted during the "send" invocation. The incoming data stream can be automatically parsed from JSON format into native JavaScript objects, or processed incrementally as data arrives, bypassing the need to await the full content transfer. Furthermore, the request can be forcibly halted prematurely or configured to automatically fail if a time limit is exceeded.
== Inter-Domain Communication (Cross-domain Requests) ==
During the initial evolutionary phase of the World Wide Web, developers recognized the potential for security vulnerabilities related to unauthorized cross-origin data access, leading to the implementation of origin policies.
