Skip to main content
Glama
siddontang

TiDB Cloud Zero MCP Server

by siddontang

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

That'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.py

Connect 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/mcp

Bring 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.py

Or 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

query

Run SELECT / SHOW / DESCRIBE / EXPLAIN

execute

Run CREATE / INSERT / UPDATE / DELETE / ALTER

batch_execute

Run multiple SQL statements sequentially

list_tables

List all tables with row counts

describe_table

Get table schema

get_database_info

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 server

License

MIT


Try TiDB Cloud: Free TrialEssential 101Startup ProgramTiDB Cloud AI

Available Tools

6 tools
batch_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')" ])

ParametersJSON Schema
NameRequiredDescriptionDefault
statementsYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.7/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must disclose behavioral traits. It only mentions 'sequentially', but fails to describe error handling, transactional behavior, partial failure semantics, permissions, or return aggregation. Critical for a batch execution tool, this gap leaves the agent uncertain about side effects and failure atomicity.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise: a one-sentence summary plus an Args section and a clear example. It is well-structured and front-loaded, with no wasted words. The example is illustrative without being overly verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool has moderate complexity, with an output schema available. The description provides an example and clarifies ordering, but omits important contextual information such as failure semantics, transaction boundaries, and how results are returned. Given the presence of an output schema, return format is less critical, but the gap around error handling lowers completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema alone defines 'statements' as an array of strings, but the description adds crucial meaning: 'List of SQL statements to execute in order' and the example clarifies usage with DDL and DML statements. Since schema description coverage is 0%, the description compensates well for this single parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action: 'Execute multiple SQL statements sequentially.' It specifies the resource (SQL statements) and scope (multiple, sequential), distinguishing it from the sibling tool 'execute' which presumably handles a single statement. This is a specific verb+resource with clear scope.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for running multiple statements in one call, but it does not explicitly contrast with sibling tools like 'execute' or 'query', nor does it provide guidance on when to prefer batch_execute over alternatives. No exclusions or when-not-to-use scenarios are given.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

describe_tableA

Get the schema of a table (columns, types, keys).

Args: table: Table name to describe

ParametersJSON Schema
NameRequiredDescriptionDefault
tableYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.8/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It only says 'Get the schema' and does not disclose whether the operation is read-only, what happens if the table does not exist, or any permissions required. The verb implies non-mutating but insufficient context is given for a tool with zero annotation support.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is one sentence plus an argument definition, front-loaded with the purpose. No wasted words, and the structure with 'Args:' is clean and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a simple 1-parameter tool with an output schema, the description adequately covers purpose and parameter semantics. It lacks usage guidance but remains sufficient for a basic describe operation. The sibling tools make the intended use clear enough.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 0%, so the description's 'Args: table: Table name to describe' provides essential meaning beyond the bare 'string' type. It clarifies the purpose of the parameter, though it does not specify format, constraints, or examples.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the verb 'Get' and the resource 'schema of a table' with explicit details (columns, types, keys). This clearly distinguishes it from sibling tools like list_tables, query, and get_database_info.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Usage is implied: use this when you need a table's schema. However, there is no explicit guidance on when to choose this over query or execute, nor any exclusion criteria. It falls short of naming alternatives or when-not-to-use.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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')")

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

The description discloses a key behavior—returning the number of affected rows—and labels the operation as a write. However, there are no annotations, and it omits additional important details such as transaction handling, permission requirements, or the risks of DROP statements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is short, front-loaded with the core purpose, and includes concise examples. Every sentence adds value without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a one-parameter tool with an output schema, the description is adequate but not fully complete. It would benefit from explicit warnings about destructive statements (DROP) and a note to use query for read-only SELECT, given the tool's powerful nature.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema is bare (0% coverage) with only 'sql' as a string parameter. The description compensates with concrete examples showing how to pass entire SQL statements, adding meaning beyond the schema's mere type definition.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool executes write SQL statements (CREATE, INSERT, UPDATE, DELETE, ALTER, DROP), identifying a specific action and resource. This distinguishes it from sibling tools like query (for reads) and list_tables (for metadata).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context by enumerating the statement types it handles, implying it is for write operations. It does not explicitly name alternatives like query for SELECT, but the sibling list and the 'write SQL' phrase give sufficient guidance for typical usage.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

get_database_infoA

Get database connection info, TiDB version, and instance status.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.1/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the burden of disclosing behavior. It clearly indicates a read-only 'Get' action, but it does not mention any permissions, rate limits, or side effects. For a simple info tool, this is adequate but not rich.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single sentence that lists three specific outputs without any filler, making it extremely concise and easy to parse.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the simplicity (no params) and the presence of an output schema, the description fully covers the tool's purpose. The output schema defines the return structure, so the description needn't elaborate further.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the description adds no parameter semantics, but none are needed. The baseline for 0-parameter tools is 4, as the schema already covers everything.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description uses a specific verb ('Get') and clearly names the resources: database connection info, TiDB version, and instance status. This clearly distinguishes it from sibling tools like list_tables or query, which focus on other aspects.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for retrieving database-level metadata, but it does not explicitly state when to use this tool versus alternatives such as describe_table or query. There is no mention of exclusions or preferred scenarios.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

list_tablesA

List all tables in the current database with row counts.

ParametersJSON Schema
NameRequiredDescriptionDefault

No parameters

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.3/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden. It implies a read-only operation ('List') and adds the return detail of row counts, but it does not explicitly state that it is non-mutating, discuss potential performance implications, or mention any permissions or side effects. For a simple listing tool this is adequate but not comprehensive.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, front-loaded sentence with no filler. It communicates the essential information efficiently, earning every word.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's simplicity (no parameters) and the presence of an output schema (per context signals), the description is complete. It states exactly what the tool does and what information is returned, which is sufficient for an agent to select and invoke it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The tool has zero parameters, so the baseline is 4. The description adds meaningful context by indicating that rows counts are included in the output, which goes beyond what the empty schema conveys. No parameter explanations are needed since there are none.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's action and scope: 'List all tables in the current database with row counts.' It uses a specific verb ('List') and resource ('tables') and adds the distinct detail of 'row counts', which differentiates it from sibling tools like describe_table or get_database_info.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use the tool: to list all tables and their row counts. It does not explicitly mention alternatives or exclusions, but the purpose is obvious enough that an agent would know when to invoke it versus query or execute. No misleading guidance is present.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

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")

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A4.5/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden. It explicitly states the tool is read-only, which is a critical safety signal, and mentions that results are returned as a formatted table. It does not cover potential errors or limits, but the core behavior is well-disclosed.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise: a single purpose sentence, a result note, and three examples. Every sentence adds value and the key information is front-loaded.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool is simple (one parameter) and an output schema exists, so return values are already defined. The description covers usage, allowed statements, and output format, making it complete for an agent to invoke the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema has only 'sql' with no description (0% coverage). The description compensates by specifying allowed statement types (SELECT, SHOW, DESCRIBE, EXPLAIN) and providing concrete examples, adding semantic meaning beyond the raw parameter name.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Execute a read-only SQL query' with specific allowed commands (SELECT, SHOW, DESCRIBE, EXPLAIN), which is a specific verb+resource. The read-only scoping distinguishes it from the sibling tool 'execute'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description clearly indicates this is for read-only SQL queries, providing context for when to use it. However, it does not explicitly mention alternatives or exclusions, though the read-only scope is an implicit exclusion.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 6 tool updatesv0.1.0
    • First observedbatch_execute
    • First observeddescribe_table
    • First observedexecute
    • First observedget_database_info
    • First observedlist_tables
    • First observedquery

TDQS

A4/5.0
Disambiguation3/5

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.

Naming Consistency4/5

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.

Tool Count5/5

Six tools is well within the ideal range for a database server MCP, covering both read and write operations without being bloated.

Completeness5/5

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

ActivityInactive
ResponsivenessNo issues

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Related MCP Connectors

Related MCP Servers

  • F
    license
    Not graded
    quality
    D
    maintenance
    A 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
    -
  • A
    license
    A
    quality
    D
    maintenance
    A 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.
    6
    454
    8
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Enables 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.
    24
    Apache 2.0
  • F
    license
    Not graded
    quality
    D
    maintenance
    A 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.
    -

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/siddontang/tidb-cloud-zero-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server