execute_natural_language_queryLABSCO SUMMARY
The read-only switch is the decision.
Whether this is safe to point at a real database comes down to one setting: SELECT-only mode is a tool the model can toggle, and get_security_mode_status is how you check what is in force before asking for anything. Two other things shape the fit — the questions are answered by an OpenAI model, so schema and generated queries leave the machine, and the database side is SQL Server only today.
What it is
An MCP server that turns English questions into SQL against Microsoft SQL Server. It reads your schema first, generates the query with an OpenAI model, validates it, and returns results with the SQL it ran — so the query is reviewable rather than hidden.
What you get
- A question in English turned into SQL and executed —
execute_natural_language_query - Direct SQL when you already know what you want, with the same validation applied —
execute_direct_sql_query - Schema exploration: every table in the database, one table's details, and a sample of its rows —
list_database_tables,get_table_information,get_table_sample_data - A read-only switch you can flip from the conversation, and a way to check which mode you are in —
toggle_select_only_mode,get_security_mode_status - Result limiting and query validation on every path, so a generated query cannot run unbounded
Requirements
Python 3.8+, a reachable SQL Server (2017+, Express and Azure SQL Database both listed) and the ODBC Driver 17 for SQL Server. Configuration goes in .env: DB_SERVER, DB_DATABASE, DB_DRIVER, and DB_USERNAME with DB_PASSWORD — both left empty for Windows Authentication. Natural-language generation needs an OPENAI_API_KEY, with OPENAI_MODEL and OPENAI_MAX_TOKENS available to tune it. You do not start the server by hand; the AI client launches it. Support is SQL Server only — PostgreSQL, MySQL, SQLite and Oracle are listed as planned.
Setup effort
Build from source — git clone https://github.com/razah-ai/chatql-mcp.git
USE CASES
Answering a data question without writing SQL
Ask in English and read back both the answer and the query that produced it.
Exploring a database you inherited
List the tables, read one table's details, then sample its rows before writing anything.
Debugging data while you code
Find the rows behind a bug from inside the editor rather than opening a SQL client.
Keeping an assistant away from writes
Turn on SELECT-only mode and confirm it is active before handing the session to a model.
7 tools
Listed in project docs. Your client may show a different list.
execute_direct_sql_queryget_table_informationlist_database_tablesget_table_sample_datatoggle_select_only_modeget_security_mode_statusBEFORE YOU INSTALL
What to know first
Tools you get
7 tools named in the project's documentation.
Requires
- Python 3.8+
- SQL Server (Express or any edition) and ODBC Driver 17 for SQL Server
- OPENAI_API_KEY in your environment
Where it runs
Both documented clients run the server on your machine.
INSTALLATION
Connect your client
You clone this one yourself.
Server setup
git clone https://github.com/razah-ai/chatql-mcp.git
cd chatql-mcp
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txt
cp env.example .envMCP Clients
Claude Desktop, Cursor
{
"mcpServers": {
"chatql-mcp": {
"command": "<YOUR_PATH_TO_CHATQL_MCP>/venv/bin/python",
"args": [
"<YOUR_PATH_TO_CHATQL_MCP>/server.py"
],
"env": {
"DB_SERVER": "localhost\\SQLEXPRESS",
"DB_DATABASE": "<YOUR_DB_DATABASE>",
"OPENAI_API_KEY": "<YOUR_OPENAI_API_KEY>"
}
}
}
}