Back to MCP Catalog

TiDB Database Connector MCP Server

DatabasesPython
Connect to and query TiDB databases directly from your AI assistant
Available Tools

execute_query

Execute a SQL query against the TiDB database and return the results

show_tables

List all tables in the connected TiDB database

describe_table

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.

Overview

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.

Prerequisites

Before installing the TiDB Database Connector, you'll need:

  • Python and the uv package installer
  • A TiDB Cloud account with a database cluster (you can create a free tier account at tidbcloud.com)
  • Your TiDB connection credentials (host, port, username, password)

Installation

  1. Clone the repository:

    git clone https://github.com/c4pt0r/mcp-server-tidb
    cd mcp-server-tidb
    
  2. Install the package and dependencies using uv:

    uv venv
    uv pip install -e .
    
  3. 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
    

Configuration for Claude Desktop

To use the TiDB Database Connector with Claude Desktop:

  1. 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"
          ]
        }
      }
    }
    
  2. Replace /path/to/mcp-server-tidb with the actual path to your cloned repository.

  3. Restart Claude Desktop to apply the changes.

Usage

Once configured, you can interact with your TiDB database through natural language. For example:

  • "Show me all tables in the database"
  • "Run a query to find all users who signed up in the last month"
  • "Create a new table for storing product information"
  • "Analyze the sales data by region"

The connector will translate your requests into SQL queries, execute them against your TiDB database, and return the results.

Related MCPs

Milvus Vector Database
DatabasesPython

Connect to Milvus vector database for semantic search and vector operations

MotherDuck DuckDB
DatabasesPython

SQL analytics with DuckDB and MotherDuck for AI assistants

Alibaba Cloud Tablestore
DatabasesJava, Python

Connect to Alibaba Cloud Tablestore for vector search and RAG applications

About Model Context Protocol

Model Context Protocol (MCP) allows AI models to access external tools and services, extending their capabilities beyond their training data.

Generate Cursor Documentation

Save time on coding by generating custom documentation and prompts for Cursor IDE.