Execute a SQL query against the TiDB database and return the results
List all tables in the connected TiDB database
Show the schema of a specific table in the database
TiDB Database Connector provides a seamless interface between AI assistants and TiDB databases. It allows you to execute SQL queries, manage database schemas, and analyze data directly through natural language conversations. This MCP server implementation specifically targets TiDB Cloud's serverless database offerings, enabling powerful database interactions without leaving your AI assistant interface.
TiDB Database Connector enables AI assistants to interact directly with TiDB databases. This allows you to perform database operations, run SQL queries, and analyze data through natural language conversations with your AI assistant.
Before installing the TiDB Database Connector, you'll need:
uv
package installerClone the repository:
git clone https://github.com/c4pt0r/mcp-server-tidb
cd mcp-server-tidb
Install the package and dependencies using uv:
uv venv
uv pip install -e .
Create a .env
file in the project directory based on the .env.example
file with your TiDB connection details:
TIDB_HOST=gateway01.us-east-1.prod.aws.tidbcloud.com
TIDB_PORT=4000
TIDB_USERNAME=xxxxxxxxxx.<username>
TIDB_PASSWORD=your_password
TIDB_DATABASE=test
To use the TiDB Database Connector with Claude Desktop:
Create or update your claude_desktop_config.json
file:
{
"mcpServers": {
"tidb": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp-server-tidb",
"run",
"src/main.py"
]
}
}
}
If you're using WSL, your configuration should look like:
{
"mcpServers": {
"tidb": {
"command": "wsl.exe",
"args": [
"bash",
"-c",
"/path/to/uv --directory /path/to/mcp-server-tidb run python src/main.py"
]
}
}
}
Replace /path/to/mcp-server-tidb
with the actual path to your cloned repository.
Restart Claude Desktop to apply the changes.
Once configured, you can interact with your TiDB database through natural language. For example:
The connector will translate your requests into SQL queries, execute them against your TiDB database, and return the results.