chat-sql
Support for ClickHouse as a target database, enabling natural-language querying, schema exploration, and secure query execution.
Optional integration for remote execution on Jupyter notebooks, enabling notebook interaction through the MCP server.
Support for MongoDB as a target database, enabling natural-language querying and data retrieval with security controls.
Support for MySQL as a target database, enabling natural-language querying, schema exploration, and secure query execution.
Support for PostgreSQL (and GaussDB) as target databases, enabling natural-language querying, schema exploration, and secure query execution.
Support for Teradata as a target database, enabling natural-language querying, schema exploration, and secure query execution.
Optional integration providing WhatsApp messaging tools, including sending messages and transcribing audio.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@chat-sqlShow me total sales by region for March."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
chat_sql
A governed natural-language → SQL agent for Claude, delivered as an MCP server. Ask a question in plain English; the agent selects the right database, writes dialect-correct SQL, runs it through security-enforcing tools, and returns results — across ClickHouse, Teradata, PostgreSQL/GaussDB, MySQL, SQL Server, DB2, Oracle, and MongoDB.
Its defining feature is that the LLM is treated as untrusted. It is structurally unable to read raw PII, to modify any table it did not create, or to reach a database outside the sanctioned tools — regardless of how it is prompted.
Why it's safe by construction
LLM (untrusted)
│ MCP over stdio — tool calls only
▼
mcp_server.py ── UNPRIVILEGED face ──────────────────
• no credentials, cannot import a connector
• forwards every DB call over a local UNIX socket
• run_python: no creds, no network (sandboxed)
│ UNIX socket (0600)
▼
dbgateway.py ── PRIVILEGED broker ───────────────────
• the only holder of credentials + connectors
• statement guard → write-guard → PII masking
• returns sanitized rows onlyGuarantee | How |
No raw PII to the LLM | Results are masked in the broker: a PII registry + column-name heuristics (default-deny) + a cell-level pattern backstop. Identifiers return as |
No writes to tables it didn't create | Writes/creates allowed only on |
No direct connector access | The |
Full threat model and control matrix: docs/SECURITY.md.
Related MCP server: nl2sql-mcp
Quick start
git clone <your-fork> chat_sql && cd chat_sql
uv venv && uv pip install -r requirements.txt # install the DB drivers you need
cp database_creds.example.json database_creds.json # add your databases
cp pii_policy.example.yaml pii_policy.yaml # classify your PII columns
cp .env.example .env # set CHATSQL_PII_SALT etc.Register the MCP server with your client (.mcp.json or ~/.claude/settings.json):
{
"mcpServers": {
"chat-sql": {
"command": "uv",
"args": ["--directory", "/path/to/chat_sql", "run", "python", "mcp_server.py"]
}
}
}For airtight run_python isolation, install bubblewrap (bwrap) or run the
broker as a separate OS user — see docs/SECURITY.md §6.
Configuring databases
Each entry in database_creds.json has a short code (the db_key you pass to
tools) and a service that selects the connector:
{
"pg_demo": {
"service": "postgres", "alias": "demo analytics",
"host": "localhost", "port": 5432,
"user": "…", "password": "…", "database": "analytics", "schema": "public"
}
}Supported service values: clickhouse, teradata, mysql, postgres
(psql/gaussdb), mssql, db2, oracle, mongo.
Classifying PII
pii_policy.yaml pins which columns are masked and how (hash | redact). The
broker also applies name-heuristics (default-deny on identifier-looking columns)
and a raw-pattern backstop, so unlisted PII is still caught — but pin known PII
explicitly. See pii_policy.example.yaml.
Tools
Database — run_query, run_query_file, export_to_csv, load_file,
drop_table, list_databases, explain_query, table_info, search_schema,
long_running_queries, kill_query.
RAG examples — find_similar_queries, save_query_example,
delete_query_example (needs a pgvector DB; set CHATSQL_RAG_DBKEY).
Local compute — run_python (sandboxed), notify.
Optional groups (off by default; enable with CHATSQL_*_ENABLED=1) —
WhatsApp (whatsapp_*, transcribe_audio), email (send_email),
Jupyter remote-exec (jupyter_*), wiki/memory (wiki_*).
Use it as a Claude skill
skills/chat-sql/SKILL.md packages the workflow so you can drop it into a
.claude/skills/ directory and invoke it by name. See that file for details.
Running the security tests
uv pip install sqlglot pyyaml pytest
python -m pytest tests/ -vThe suite proves every control (PII masking, write-guard, connector isolation, statement guard) with no live database required.
License
MIT — see LICENSE.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceAn MCP (Model Context Protocol) server that exposes natural language to SQL functionality, allowing any MCP-compatible client to convert plain English questions into SQL queries for database interaction using AI.3MIT
- Flicense-qualityFmaintenanceA production-ready MCP server that transforms natural language into safe, executable SQL queries with multi-database support and intelligent schema analysis.1
- -license-qualityCmaintenanceAn MCP server that bridges AI assistants with SQL databases, enabling natural language querying across multiple database types with built-in optimization and security.3
- Alicense-qualityDmaintenanceA unified MCP server for querying and managing multiple database types (PostgreSQL, MySQL, SQL Server, etc.) via natural language through AI assistants.GPL 3.0
Related MCP Connectors
GibsonAI MCP server: manage your databases with natural language
Official Microsoft MCP Server to query Microsoft Entra data using natural language
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Umair444/chat-sql-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server