Add the TiDB MCP server to VS Code

Config last verified Jun 1, 2026

The exact config to run TiDB in VS Code — paste it in, restart, and the tools load.

Prerequisites

  • VS Code installed.
  • TIDB_HOST — Hostname of your TiDB server or TiDB Cloud cluster.
  • TIDB_PORT — Port of the TiDB server, typically 4000.
  • TIDB_USERNAME — TiDB username used to authenticate.
  • TIDB_PASSWORD — Password for the TiDB user.
  • TIDB_DATABASE — Default database to connect to.

Setup

1. Open .vscode/mcp.json

2. Add this configuration

Add to .vscode/mcp.json

.vscode/mcp.json
json
{
  "servers": {
    "tidb": {
      "type": "stdio",
      "command": "uvx",
      "args": [
        "--from",
        "pytidb[mcp]",
        "tidb-mcp-server"
      ],
      "env": {
        "TIDB_HOST": "<TIDB_HOST>",
        "TIDB_PORT": "<TIDB_PORT>",
        "TIDB_USERNAME": "<TIDB_USERNAME>",
        "TIDB_PASSWORD": "<TIDB_PASSWORD>",
        "TIDB_DATABASE": "<TIDB_DATABASE>"
      }
    }
  }
}

Heads up

  • VS Code uses the `servers` key (not `mcpServers`) and requires `type`.

3. Restart VS Code and confirm the TiDB tools load.

Gotchas

  • VS Code uses the `servers` key (not `mcpServers`) and requires `type`.

VS Code is the exception to every other client: its top-level key is "servers", not "mcpServers", and each entry needs an explicit "type" (for example "http" or "stdio"). Secrets are not inlined; instead you declare an "inputs" array and reference each value as ${input:id}, so VS Code prompts for it once and never writes it to disk. Remote servers connect natively with OAuth.

← Back to the TiDB MCP server