TiDB MCP Server
The TiDB MCP Server enables executing SQL queries against a TiDB database instance via the Model Context Protocol (MCP).
Execute SQL Queries: Run SELECT statements by default on a TiDB database
Additional Operations: Optionally perform INSERT, UPDATE, and DELETE operations when configured
Secure Configuration: Configure connections securely using environment variables
Lightweight: Simple installation and configuration process, supporting npx or global npm installation
Runs as a Node.js application, requiring Node.js 16+ to function.
Click on "Install 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 MCP Servershow me the top 10 customers by total purchase amount"
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 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 claudeVia npx
npx tidb-mcp-serverGlobal installation
npm install -g tidb-mcp-server
tidb-mcp-serverConfiguration
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
Start the server:
tidb-serverAdd 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"
}
}
}
}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
Clone the repo:
git clone https://github.com/l1806858547/tidb-server.git
cd tidb-serverInstall dependencies:
npm installBuild:
npm run buildRun:
node build/index.jsLicense
MIT
Available Tools
1 tooltidb_queryC
Execute SQL queries against TiDB
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | The SQL query to execute |
TDQS
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.
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.
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.
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.
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.
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 tool update
v1.0.0- First observed
tidb_query
TDQS
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.
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.
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.
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
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
A Model Context Protocol server for Wix AI tools
Model Context Protocol server for Studex tools, notifications, and profile integrations
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
Model Context Protocol server for todo.vu task management and time tracking.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that enables SQL query execution, database management, and business intelligence capabilities through MySQL connections.1,166MIT
- AlicenseNot gradedqualityCmaintenanceA Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.11,0522,108MIT
- AlicenseNot gradedqualityDmaintenanceA Model Context Protocol server that provides read-only access to MySQL databases, enabling LLMs to inspect database schemas and execute read-only queries.11,052MIT
- AlicenseBqualityAmaintenanceA Model Context Protocol server that enables SQL operations (SELECT, INSERT, UPDATE, DELETE) and table management through a standardized interface with SQLite databases.71401ISC
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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