mcp-server-tidb
TiDB(无服务器)数据库的MCP服务器实现。
前置条件
- uv(Python包安装器)
安装
# 克隆仓库
git clone https://github.com/c4pt0r/mcp-server-tidb
cd mcp-server-tidb
# 使用uv安装包和依赖
uv venv
uv pip install -e .
配置
前往 tidbcloud.com 创建免费的TiDB数据库集群
配置可以通过环境变量或使用.env文件提供:
TIDB_HOST- TiDB主机地址,例如 'gateway01.us-east-1.prod.aws.tidbcloud.com'TIDB_PORT- TiDB端口(默认:4000)TIDB_USERNAME- 数据库用户名,例如 'xxxxxxxxxx.<username>'TIDB_PASSWORD- 数据库密码TIDB_DATABASE- 数据库名称,默认为test
使用Claude Desktop运行
配置Claude Desktop,HOWTO
claude_desktop_config.json:
{
"mcpServers": {
"tidb": {
"command": "uv",
"args": [
"--directory",
"/path/to/mcp-server-tidb",
"run",
"src/main.py"
]
}
}
}
如果您在WSL中运行mcp-server-tidb,claude_desktop_config.json应如下所示:
{
"mcpServers": {
"tool-with-env-vars": {
"command": "wsl.exe",
"args": [
"bash",
"-c",
"/path/to/uv --directory /path/to/mcp-server-tidb run python src/main.py"
]
}
}
}