TiDB Cloud Lake MCP Server
The TiDB Cloud Lake MCP server exposes TiDB Cloud Lake operations to clients that support the Model Context Protocol (MCP). The tidbcloudlake-mcp package supports standard input/output, HTTP, and server-sent events (SSE) transports.
Prerequisites
Before you begin, make sure that you have the following:
Python 3.12 or later
A TiDB Cloud Lake account, database, and warehouse
A TiDB Cloud Lake DSN in the following format:
lake://<username>:<password>@<host>:443/<database>?warehouse=<warehouse>
For information about obtaining connection information, see Connect to a Warehouse.
Install the MCP server
Create and activate a virtual environment:
python3.12 -m venv .venv
source .venv/bin/activate
Install the server from PyPI:
python -m pip install tidbcloudlake-mcp
Run the MCP server
Set the TiDB Cloud Lake DSN:
export LAKE_DSN='lake://<username>:<password>@<host>:443/<database>?warehouse=<warehouse>'
Run the server with its default stdio transport:
lake-mcp
You can also run the package without installing it into the active environment:
uv tool run --from tidbcloudlake-mcp@latest lake-mcp
Configure the transport
Set LAKE_MCP_SERVER_TRANSPORT to one of the following values:
For example, to run an HTTP server on the default loopback address and port:
export LAKE_MCP_SERVER_TRANSPORT=http
export LAKE_MCP_BIND_HOST=127.0.0.1
export LAKE_MCP_BIND_PORT=8001
lake-mcp
Configuration
Available tools
Safe mode
Safe mode is enabled by default. In safe mode:
- Read operations such as
SELECT,SHOW,DESCRIBE,EXPLAIN, andLISTcan access objects allowed by the configured TiDB Cloud Lake user. - Write operations are limited to objects whose names start with the current
mcp_sandbox_{session_id}_*prefix. - Data manipulation statements can modify only sandbox tables.
- Privilege changes can target only sandbox objects and principals.
Set LAKE_MCP_SAFE_MODE=false only when the MCP client is trusted and the configured TiDB Cloud Lake user has the minimum required privileges.
For client-specific configuration examples, see Connect AI Tools to TiDB Cloud Lake Using MCP.