Skip to main content
Glama
l1806858547

TiDB MCP Server

by l1806858547

TiDB MCP Server

A Model Context Protocol (MCP) server for TiDB that allows executing SELECT queries through MCP tools.

Features

  • Execute SELECT queries on TiDB

  • Secure connection via environment variables

  • Lightweight and easy to use

Related MCP server: MCP Server for MySQL

Prerequisites

  • Node.js 16+

  • TiDB instance

Installation

Installing via Smithery

To install TiDB Server for Claude Desktop automatically via Smithery:

npx -y @smithery/cli install @l1806858547/tidb-server --client claude

Via npx

npx tidb-mcp-server

Global installation

npm install -g tidb-mcp-server
tidb-mcp-server

Configuration

Set these environment variables before running:

export TIDB_HOST="your_tidb_host"
export TIDB_PORT="your_tidb_port" 
export TIDB_USER="your_username"
export TIDB_PASS="your_password"
export TIDB_DB="your_database"

# Optional operation permissions (default: false)
export ALLOW_INSERT_OPERATION="false"  # Set to "true" to allow INSERT operations
export ALLOW_UPDATE_OPERATION="false"  # Set to "true" to allow UPDATE operations 
export ALLOW_DELETE_OPERATION="false"  # Set to "true" to allow DELETE operations

WARNING: Enabling these operations may expose your database to modification risks.
Only enable what you need and ensure proper access controls are in place.

Usage

  1. Start the server:

tidb-server
  1. Add to MCP configuration (cline_mcp_settings.json):

{
  "mcpServers": {
    "tidb-server": {
      "command": "npx",
      "args": ["-y", "tidb-mcp-server"], # Also adding the -y flag for consistency
      "env": {
        "TIDB_HOST": "your_tidb_host",
        "TIDB_PORT": "your_tidb_port",
        "TIDB_USER": "your_username",
        "TIDB_PASS": "your_password",
        "TIDB_DB": "your_database"
      }
    }
  }
}
  1. Use the MCP tool:

const result = await use_mcp_tool({
  server_name: 'tidb-server',
  tool_name: 'tidb_query', 
  arguments: {
    sql: 'SELECT * FROM your_table LIMIT 10'
  }
});

Development

  1. Clone the repo:

git clone https://github.com/l1806858547/tidb-server.git
cd tidb-server
  1. Install dependencies:

npm install
  1. Build:

npm run build
  1. Run:

node build/index.js

License

MIT

Available Tools

1 tool
tidb_queryC

Execute SQL queries against TiDB

ParametersJSON Schema
NameRequiredDescriptionDefault
sqlYesThe SQL query to execute

TDQS

C2.9/5.0
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure but only states the basic action without details on permissions, side effects, rate limits, or response format. It fails to address critical aspects like whether queries are read-only, transactional, or have other constraints.

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, efficient sentence with zero waste, clearly front-loading the tool's purpose. It is appropriately sized for a simple tool with one parameter and no complex context.

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

Completeness2/5

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

Given the lack of annotations and output schema, the description is incomplete for a tool that executes SQL queries. It omits essential context like return value format, error handling, or behavioral traits, leaving significant gaps for an AI agent to understand the tool fully.

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

Parameters3/5

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

The schema description coverage is 100%, so the input schema already documents the 'sql' parameter fully. The description does not add any meaning beyond what the schema provides, such as SQL dialect specifics or query limitations, resulting in a baseline score.

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

Purpose4/5

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

The description clearly states the action ('Execute SQL queries') and target resource ('against TiDB'), providing a specific verb+resource combination. It distinguishes the tool's function effectively, though there are no sibling tools to differentiate from, which prevents a perfect score.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or context for its application. It lacks explicit usage instructions, making it minimally helpful for decision-making in a broader toolset.

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. 1 tool updatev1.0.0
    • First observedtidb_query

TDQS

B3/5.0
Disambiguation5/5

With only one tool, there is no possibility of ambiguity or overlap between tools. The tool's purpose is clearly defined and distinct by default.

Naming Consistency5/5

A single tool inherently has perfect naming consistency, as there are no other tools to compare it against. The naming pattern is straightforward and clear.

Tool Count2/5

A single tool is too few for a database server like TiDB, which typically requires operations beyond just querying (e.g., schema management, data manipulation, administration). This minimal set severely limits functionality.

Completeness1/5

The tool surface is severely incomplete for a TiDB server. It only supports query execution, missing essential operations like creating/dropping tables, inserting/updating/deleting data, managing indexes, or handling transactions.

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

  • A
    license
    Not graded
    quality
    D
    maintenance
    A Model Context Protocol server that enables SQL query execution, database management, and business intelligence capabilities through MySQL connections.
    1,166
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    A Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.
    11,052
    2,108
    MIT
  • A
    license
    B
    quality
    A
    maintenance
    A Model Context Protocol server that enables SQL operations (SELECT, INSERT, UPDATE, DELETE) and table management through a standardized interface with SQLite databases.
    7
    140
    1
    ISC

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/l1806858547/tidb-server'

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