TiDB Cloud Zero MCP Server
Click on "Deploy 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., "@TiDB Cloud Zero MCP Server Create a products table with id, name, and price columns"
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.
TiDB Cloud Zero MCP Server
Give any AI agent a persistent MySQL database through the Model Context Protocol.
Zero config — the server automatically provisions a free TiDB Cloud Zero instance on first use. No signup, no API keys, no credentials. Just run it.
How It Works
┌─────────────┐ MCP ┌──────────────┐ HTTPS ┌─────────────────┐
│ AI Agent │◄────────────►│ MCP Server │◄────────────►│ TiDB Cloud Zero │
│ (Claude, │ stdio/http │ (this repo) │ /v1beta/sql │ (free MySQL) │
│ Cursor) │ │ │ pure HTTP │ │
└─────────────┘ └──────────────┘ └─────────────────┘On first query, the server calls POST https://zero.tidbapi.com/v1alpha1/instances to create a free database, then uses the TiDB Serverless HTTP API for all SQL — pure HTTPS, no MySQL driver, no persistent connections.
The instance credentials are cached locally (~/.tidb-cloud-zero-mcp/instance.json) and reused until expiry.
Related MCP server: MySQL MCP Server
Quick Start
git clone https://github.com/siddontang/tidb-cloud-zero-mcp.git
cd tidb-cloud-zero-mcp
uv run server.pyThat's it. No environment variables needed. The first query auto-provisions a database.
Connect to Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"tidb": {
"command": "uv",
"args": ["run", "--project", "/path/to/tidb-cloud-zero-mcp", "server.py"]
}
}
}Connect to Claude Code
claude mcp add tidb -- uv run --project /path/to/tidb-cloud-zero-mcp server.pyConnect to Cursor / Windsurf
Add to your MCP settings:
{
"tidb": {
"command": "uv",
"args": ["run", "--project", "/path/to/tidb-cloud-zero-mcp", "server.py"]
}
}HTTP Transport
uv run server.py --transport http
# Connect at http://localhost:8000/mcpBring Your Own Database (Optional)
If you already have a TiDB Cloud instance, set TIDB_URL:
export TIDB_URL="mysql://user:password@host/database"
uv run server.pyOr individual variables:
export TIDB_HOST="gateway01.us-west-2.prod.aws.tidbcloud.com"
export TIDB_USERNAME="your_user"
export TIDB_PASSWORD="your_password"
export TIDB_DATABASE="test"Tools
Tool | Description |
| Run SELECT / SHOW / DESCRIBE / EXPLAIN |
| Run CREATE / INSERT / UPDATE / DELETE / ALTER |
| Run multiple SQL statements sequentially |
| List all tables with row counts |
| Get table schema |
| Database info, version, and instance status |
Example Interactions
Once connected, ask your AI agent:
"Create a users table and add some sample data"
"Show me all tables in the database"
"Analyze the data in the orders table"
"Write a query to find the top 10 customers by revenue"
The agent uses MCP tools to interact with TiDB Cloud Zero directly — no configuration needed.
Architecture
Every SQL query is a single HTTP POST to TiDB's Serverless HTTP API:
POST https://http-{host}/v1beta/sql
Authorization: Basic {base64(user:pass)}
TiDB-Database: {database}
Content-Type: application/json
{"query": "SELECT * FROM users"}This means:
No MySQL driver — works anywhere with HTTPS
No connection management — stateless, each query is independent
Edge-compatible — runs in serverless functions and edge workers
Auto-provisioning — database created on first use via Zero API
Why TiDB Cloud Zero?
Feature | Benefit |
Zero signup | No account, no credit card — just use it |
MySQL compatible | Works with every tool, ORM, and language |
Serverless | No provisioning, no maintenance |
HTTP API | No drivers needed, pure HTTPS |
Vector Search | Store embeddings alongside relational data |
Disposable | 72-hour instances for testing and demos |
Development
uv sync # Install dependencies
uv run mcp dev server.py # Test with MCP Inspector
uv run server.py --transport http # Run HTTP serverLicense
MIT
Try TiDB Cloud: Free Trial • Essential 101 • Startup Program • TiDB Cloud AI
Available Tools
6 toolsbatch_executeA
Execute multiple SQL statements sequentially.
Args: statements: List of SQL statements to execute in order
Example: batch_execute([ "CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255))", "INSERT INTO users (name) VALUES ('Alice')", "INSERT INTO users (name) VALUES ('Bob')" ])
Inputs: statements (required). Returns: result
describe_tableA
Get the schema of a table (columns, types, keys).
Args: table: Table name to describe
Inputs: table (required). Returns: result
executeA
Execute a write SQL statement (CREATE, INSERT, UPDATE, DELETE, ALTER, DROP).
Returns the number of affected rows.
Examples: execute("CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(255))") execute("INSERT INTO users (name) VALUES ('Alice')")
Inputs: sql (required). Returns: result
get_database_infoA
Get database connection info, TiDB version, and instance status.
Inputs: no named parameters. Returns: result
list_tablesA
List all tables in the current database with row counts.
Inputs: no named parameters. Returns: result
queryA
Execute a read-only SQL query (SELECT, SHOW, DESCRIBE, EXPLAIN).
Returns results as a formatted table.
Examples: query("SELECT * FROM users LIMIT 10") query("SHOW TABLES") query("DESCRIBE users")
Inputs: sql (required). Returns: result
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 6 tools
Some overlap exists between query and list_tables/describe_table since query supports SHOW and DESCRIBE, which can duplicate those tools. However, the descriptions clarify the intended use cases, making selection mostly straightforward.
Names use a consistent lowercase underscore style with imperative verbs, but mix single-word verbs (query, execute) with verb_noun pairs (list_tables, describe_table). This is a minor deviation from a fully uniform pattern.
Six tools is well within the ideal range for a database server MCP, covering both read and write operations without being bloated.
The tool set covers core database operations: listing tables, describing schema, running read-only queries, executing write statements, batch execution, and retrieving server info. No obvious gaps for its stated purpose.
Maintenance
Related MCP Connectors
PostgreSQL, MySQL, OpenAPI/Swagger, and shared Agent Memory with scoped access.
Analytical memory for AI agents: a real Postgres queried in plain English over MCP. One command.
Supabase-compatible Postgres for agents: projects, branches, SQL, auth, storage, email.
An agent-native database over MCP: shared, validated, structured records in every AI chat.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables AI models to interact with MySQL databases through natural language, supporting SQL queries, table creation, and schema exploration.3-
- AlicenseAqualityDmaintenanceA Model Context Protocol server that allows AI agents to execute SQL queries against a MySQL database, supporting operations like reading data, creating tables, inserting, updating, and deleting records.6896 npm7MIT
- AlicenseNot gradedqualityDmaintenanceEnables interaction with TiDB serverless databases through the Model Context Protocol. Allows users to connect to and manage TiDB cloud databases using natural language through Claude Desktop.24Apache 2.0
- FlicenseNot gradedqualityDmaintenanceA Model Context Protocol service that enables AI assistants to directly query and manage MySQL databases through natural language. It supports SQL execution, schema inspection, and atomic transactions for comprehensive database interaction.-