Text to SQL
一个基于 FastMCP 框架的安全数据库查询 MCP 服务,用于数据库查询和分析。
What is Text to SQL?
Text to SQL is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to 一个基于 fastmcp 框架的安全数据库查询 mcp 服务,用于数据库查询和分析。
一个基于 FastMCP 框架的安全数据库查询 MCP 服务,用于数据库查询和分析。
This server falls under the Databases category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- 一个基于 FastMCP 框架的安全数据库查询 MCP 服务,用于数据库查询和分析。
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx text-to-sqlConfiguration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use Text to SQL
The Text-to-SQL MCP Server is a FastMCP-based service that bridges natural language and relational databases, allowing AI assistants to query MySQL databases using plain English. It exposes seven tools covering schema discovery, query generation, execution, and result analysis while enforcing strict read-only safeguards that block destructive operations like DROP, DELETE, UPDATE, and INSERT. This makes it ideal for analysts and developers who want to interrogate production databases without needing to write SQL by hand.
Prerequisites
- Python 3.10 or higher installed
- A running MySQL database with credentials (host, port, user, password, database name)
- An MCP-compatible client such as Claude Desktop or Claude Code
- pip and a virtual environment tool for dependency management
Clone the repository
Clone the project from GitHub to your local machine.
git clone https://github.com/tmstack/text-to-sql-mcp-server.git
cd text-to-sql-mcp-serverInstall dependencies
Create a virtual environment and install the required Python packages including FastMCP, mysql-connector-python, and python-dotenv.
python -m venv venv
source venv/bin/activate
pip install -r requirements.txtConfigure environment variables
Copy the example environment file and fill in your MySQL database credentials and the server host/port.
cp .env.example .env
# Edit .env with your values:
# DB_HOST=localhost
# DB_PORT=3306
# DB_USER=your_username
# DB_PASSWORD=your_password
# DB_NAME=your_database
# MCP_HOST=127.0.0.1
# MCP_PORT=8000Start the MCP server
Run the server script. It will connect to MySQL and begin listening for MCP requests.
python mcp_server.pyAdd the server to your MCP client configuration
Point your MCP client at the running server by adding its URL to the client config file.
Text to SQL Examples
Client configuration
Add the Text-to-SQL server to claude_desktop_config.json, connecting to the locally running HTTP server.
{
"mcpServers": {
"text-to-sql": {
"command": "python",
"args": ["/path/to/text-to-sql-mcp-server/mcp_server.py"],
"env": {
"DB_HOST": "localhost",
"DB_PORT": "3306",
"DB_USER": "your_username",
"DB_PASSWORD": "your_password",
"DB_NAME": "your_database",
"MCP_HOST": "127.0.0.1",
"MCP_PORT": "8000"
}
}
}
}Prompts to try
Example queries you can send to the AI once the server is connected.
- "List all the tables in the database"
- "Show me the structure and a few sample rows from the orders table"
- "How many users signed up in the last 30 days?"
- "What are the top 10 products by total revenue this quarter?"
- "Check the health of the database connection"Troubleshooting Text to SQL
Connection refused error when starting the server
Verify that the MySQL instance is running and that DB_HOST, DB_PORT, DB_USER, and DB_PASSWORD in your .env file are correct. Test with: mysql -h $DB_HOST -P $DB_PORT -u $DB_USER -p
AI assistant returns 'permission denied' for a query
The server enforces read-only permissions. Ensure the MySQL user has at least SELECT privileges on the target database. Write operations (INSERT, UPDATE, DELETE, DROP) are blocked by design.
Module not found errors on startup
Make sure you activated the virtual environment before running the server: source venv/bin/activate, then re-run pip install -r requirements.txt.
Frequently Asked Questions about Text to SQL
What is Text to SQL?
Text to SQL is a Model Context Protocol (MCP) server that 一个基于 fastmcp 框架的安全数据库查询 mcp 服务,用于数据库查询和分析。 It connects AI assistants to external tools and data sources through a standardized interface.
How do I install Text to SQL?
Follow the installation instructions on the Text to SQL GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with Text to SQL?
Text to SQL works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is Text to SQL free to use?
Yes, Text to SQL is open source and available under the MIT license. You can use it freely in both personal and commercial projects.
Text to SQL Alternatives — Similar Databases Servers
Looking for alternatives to Text to SQL? Here are other popular databases servers you can use with Claude, Cursor, and VS Code.
Excelize
★ 20.6kGo language library for reading and writing Microsoft Excel™ (XLAM / XLSM / XLSX / XLTM / XLTX) spreadsheets
MCP Toolbox for Databases
★ 15.3kOpen source MCP server specializing in easy, fast, and secure tools for Databases.
DBHub
★ 2.8kA universal database gateway MCP server that enables AI assistants to connect to and query multiple databases (PostgreSQL, MySQL, MariaDB, SQL Server, SQLite) with support for schema exploration, SQL execution, and secure connections via SSH tunnels.
Tabularis
★ 2.1kA lightweight, cross-platform database client for developers. Supports MySQL, PostgreSQL and SQLite. Hackable with plugins. Built for speed, security, and aesthetics.
Postgres AI Guide
★ 1.7kMCP server and Claude plugin for Postgres skills and documentation. Helps AI coding tools generate better PostgreSQL code.
Anyquery
★ 1.7k🏎️ 🏠 ☁️ - Query more than 40 apps with one binary using SQL. It can also connect to your PostgreSQL, MySQL, or SQLite compatible database. Local-first and private by design.
Browse More Databases MCP Servers
Explore all databases servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up Text to SQL in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use Text to SQL?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.