ChatSQL MCP Server
Converts natural language questions into SQL queries using Google Gemini.
Executes generated SQL queries against a PostgreSQL database and returns results.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
💬 ChatSQL — Natural Language to SQL using Gemini & FastMCP
ChatSQL is a command-line tool that lets you query a PostgreSQL database using natural language. It uses Google Gemini to convert your questions into SQL, and FastMCP to execute them against your database.
🚀 Tech Stack
Python 3.11+
PostgreSQL (via
psycopg2)FastMCP (Modular Composable Protocol)
Google Gemini (for Natural Language to SQL conversion)
Rich (for pretty command-line interface output)
python-dotenv (for environment variable configuration)
Related MCP server: pgEdge Postgres MCP Server
🧠 Use Case
You ask a question in plain English, and ChatSQL generates and executes the SQL, then displays the results.
Input: "Get all employees earning more than 50000"
Generated SQL:
SELECT * FROM employees WHERE salary > 50000;
Output:
+----+---------+--------+------------+-----------+------------+
| id | name | salary | phone_no | address | department |
+----+---------+--------+------------+-----------+------------+
| 1 | Alice | 75000 | 9876543210 | New York | HR |
| 2 | Bob | 65000 | 1234567890 | Chicago | Finance |
+----+---------+--------+------------+-----------+------------+
⚙️ Setup Instructions
✅ 1. Clone the Repository & Configure Environment
> git clone https://github.com/thomasjerard/ChatSQL.git
> cd chatSQL✅ 2. Prerequisites
Bash shell is required (default on macOS/Linux).
Python 3.11+ must be installed and accessible via your terminal. If not installed,
For macOS:
brew install python@3.11For Linux:
sudo apt install python3.11 python3.11-venv✅ 3. Create a .env file in the root folder with the following content:
DB_NAME=chattosql
DB_USER=postgres
DB_PASS=yourpassword
DB_HOST=localhost
DB_PORT=5432
GEMINI_API_KEY=your-gemini-api-key✅ 3. Run the Application
You’ll need two separate terminals:
🖥️ Terminal 1 — Start the Server
./run_server.sh💬Terminal 2 — Start the Client
./run_client.shOnce the client starts, you'll see a prompt like:
💬 ChatSQL (Gemini + FastMCP) 🗨️ Ask (NL):
🔧 What Happens Internally
Each script (run_server.sh / run_client.sh) performs the following:
Deletes any existing virtual environment and creates a fresh one.
Loads environment variables from the .env file.
Installs required Python dependencies from requirements.txt.
Sets up PostgreSQL:
Creates the database (chattosql)
Adds the user (postgres)
Creates a sample employees table
Starts the FastMCP server or the ChatSQL CLI client, depending on the script.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
Text-to-SQL MCP server: read-only queries on PostgreSQL, MySQL and SQL Server with your real schema
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Query your warehouse or a CSV with Claude/ChatGPT over MCP, governed by table-level ACL + audit.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA FastMCP server that enables natural language querying of PostgreSQL databases through LLM integration, allowing users to generate SQL queries from plain English and visualize the results.4-

pgEdge Postgres MCP Serverofficial
AlicenseNot gradedqualityAmaintenanceEnables SQL queries against PostgreSQL databases through MCP-compatible clients and includes a natural language agent for forming SQL queries from natural language.246PostgreSQL- AlicenseNot gradedqualityDmaintenanceEnables natural language querying of PostgreSQL databases with intelligent SQL generation using LLMs.1Apache 2.0
- AlicenseAqualityDmaintenanceEnables querying and interacting with PostgreSQL databases using natural language through MCP. Supports configuration via environment variables and Cursor IDE integration.3MIT