Skip to content

Text-to-SQL via Model Context Protocol: Structured Context Orchestration for Reliable Database Query Generation

Oct 2026 · IEEE Transactions on Knowledge and Data Engineering · Vol 38, pp. 7100-7113 · 0 citations · 36 references

Abstract

Text-to-SQL has emerged as a fundamental task for enabling natural language interfaces to relational databases, playing a critical role in data analytics, business intelligence, and end-user database interaction. Extensive research efforts have been devoted to this task, ranging from traditional semantic parsing approaches to recent large language model (LLM)-based methods. Despite recent advances, existing LLM-based Text-to-SQL approaches largely rely on one-shot prompt-based generation. This paradigm suffers from two fundamental limitations: entangled contextual information that obscures reasoning, and the absence of systematic validation mechanisms for detecting and correcting SQL errors. To address these challenges, we propose MCP-Text2SQL, a protocol-driven framework that reformulates Text-to-SQL as a controllable and verifiable generation process. Instead of relying on monolithic prompts, MCP-Text2SQL decomposes heterogeneous contextual knowledge into semantically isolated model context protocol context servers and coordinates them through an explicit generation protocol. Furthermore, we introduce a verifiable SQL generation loop that integrates schema validation and execution-based feedback as structured protocol interactions, enabling deterministic and error-aware SQL revision without modifying model parameters. We evaluate MCP-Text2SQL on standard Text-to-SQL benchmarks and demonstrate that protocol-guided context orchestration and verifiable generation substantially improve both generation accuracy and robustness. Our results suggest that MCP provides a principled system-level abstraction for Text-to-SQL, shifting the focus from prompt engineering to controllable and verifiable generation workflows.

View source

We use cookies to run the site and, with your consent, for analytics and to show ads. See our Cookie Policy.