How to set up an MCP Server in Kimi CLI
This guide demonstrates how to connect a MySQL MCP server to Kimi CLI, giving the AI assistant direct access to your MySQL database. You will learn how to build the MCP server, register it in the Kimi CLI configuration file, and test the available database tools.
What is an MCP server?
An MCP (Model Context Protocol) server exposes tools that an AI model can call during a conversation. In this setup, the MySQL MCP server provides database tools such as running queries, creating tables, and inserting data. Kimi CLI launches the MCP server as a subprocess and communicates with it directly, making the setup simpler than browser-based integrations that require an HTTP proxy.
Steps to follow
We assume Kimi CLI is already installed on your system. If you haven't installed Open Code, check out our How to setup Kimi CLI with Ozeki AI Gateway guide.
- Download and build the MySQL MCP server
- Configure the MCP server in Kimi CLI
- Test the database tools
Quick reference
# Install dependencies and build the MCP server
npm install
npm run build
# Kimi CLI MCP configuration file location
C:\Users\{User}\.kimi\mcp.json
# MCP server configuration to add to mcp.json
{
"mcpServers": {
"mysql-mcp-server": {
"command": "node",
"args": [
"C:\\path\\to\\mysql-mcp-server\\build\\index.js"
],
"env": {
"MYSQL_HOST": "your-mysql-host",
"MYSQL_PORT": "your-mysql-port",
"MYSQL_USER": "your-mysql-user",
"MYSQL_PASSWORD": "your-mysql-password",
"MYSQL_DATABASE": "your-database-name"
}
}
}
}
How to install the MySQL MCP server video
The following video shows how to download, build, and set up the MySQL MCP server step-by-step.
Step 1 - Download and build the MySQL MCP server
Navigate to the MySQL MCP server repository on GitHub and download the repository as a ZIP file by clicking the Code button and selecting Download ZIP (Figure 1).
Locate the downloaded ZIP file in your Downloads folder and extract it to a directory of your choice. The extracted folder will contain the MCP server source files (Figure 2).
Open a terminal window in the extracted MCP server folder. You can do this by right-clicking inside the folder and selecting Open in Terminal or by navigating to the folder path in an existing terminal (Figure 3).
Run npm install to download and install all dependencies required by the
MCP server. Wait for the installation to complete before proceeding (Figure 4).
npm install
Run npm run build to compile the TypeScript source files into JavaScript.
The compiled output will be placed in the build folder. This is the
index.js file you will reference in the Kimi CLI configuration (Figure 5).
npm run build
Step 2 - Configure the MCP server in Kimi CLI
The following video shows how to register the MySQL MCP server in Kimi CLI and verify the database tools through a series of test prompts.
Locate the Kimi CLI MCP configuration file at C:\Users\{User}\.kimi\mcp.json
and open it in a text editor. If the file does not exist yet, create it. This file
stores all MCP server registrations separately from the main Kimi CLI settings (Figure 6).
Add the MySQL MCP server entry to the mcpServers block. Replace the
path in the args array with the actual path to the index.js
file in your build folder, and fill in your MySQL connection details in the
env section. Save the file when done (Figure 7).
{
"mcpServers": {
"mysql-mcp-server": {
"command": "node",
"args": [
"C:\\path\\to\\mysql-mcp-server\\build\\index.js"
],
"env": {
"MYSQL_HOST": "your-mysql-host",
"MYSQL_PORT": "your-mysql-port",
"MYSQL_USER": "your-mysql-user",
"MYSQL_PASSWORD": "your-mysql-password",
"MYSQL_DATABASE": "your-database-name"
}
}
}
}
Open Kimi CLI from a terminal window. Kimi CLI will read the updated configuration file and automatically connect to the registered MCP server on startup (Figure 8).
Step 3 - Test the database tools
Test the query tool by asking Kimi CLI to retrieve data from your database. Kimi CLI will use the MCP tool to execute the SQL query and return the results directly in the terminal (Figure 9). If prompted, accept the Tool usage.
Show me all users from the database.
Test the table creation tool by instructing Kimi CLI to create a new table in your database (Figure 10).
Create a table called "employees" in the database with columns for id, name, position, and salary.
Test the data insertion tool by asking Kimi CLI to insert records into the table. Provide the data in natural language and it will construct and execute the appropriate INSERT statements (Figure 11).
Insert these three rows into the employees table: Alice - Developer - 850000, Bob - Designer - 720000, Charlie - Manager - 950000.
Finally, test a conditional query to confirm that filtering works correctly. This verifies the full pipeline from natural language input through SQL execution to result display in the terminal (Figure 12).
Query the database and show me all employees who earn more than 800000.
Final thoughts
You have successfully set up a MySQL MCP server and connected it to Kimi CLI. The AI assistant can now interact with your MySQL database directly through natural language, executing queries, creating tables, and managing data without requiring any manual SQL input.