Text to SQL

v1.0.0Databasesstable

一个基于 FastMCP 框架的安全数据库查询 MCP 服务,用于数据库查询和分析。

text-to-sqlmcpai-integration
Share:
14
Stars
0
Downloads
0
Weekly
0/5

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

Convert natural language queries into SQL for safe database analysis.
Enable AI assistants to perform data queries without requiring SQL expertise.
tmstack

Maintainer

LicenseMIT
Languagepython
Versionv1.0.0
UpdatedFeb 2, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx text-to-sql

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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-server
2

Install 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.txt
3

Configure 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=8000
4

Start the MCP server

Run the server script. It will connect to MySQL and begin listening for MCP requests.

python mcp_server.py
5

Add 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.

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.

Quick Config Preview

{ "mcpServers": { "text-to-sql": { "command": "npx", "args": ["-y", "text-to-sql"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides