This page shows you how to connect your Cloud SQL instance to various AI developer assistance tools, including the following:
- Gemini Code Assist
- Claude code
- Claude desktop
- Cline (VS Code extension)
- Cursor
- Visual Studio Code (Copilot)
- Windsurf (Codeium)
For an integrated experience, we recommend using the dedicated Gemini CLI extension for Cloud SQL for MySQL.
As Google Cloud's next-generation command-line interface, Gemini CLI bundles the underlying MCP server directly into the extension, which simplifies setup and configuration. You can configure Gemini Code Assist to use the Gemini CLI, offering similar setup benefits in your IDE.
For other developer tools that support the Model Context Protocol (MCP), you can connect by manually configuring the MCP Toolbox for Databases (Toolbox). Toolbox is an open-source MCP server that connects AI agents to your data by managing tasks such as authentication and connection pooling. This lets you interact with your data using natural language directly from your IDE. For these tools, this method provides core database interaction capabilities.
For more information, see Prebuilt tools and MCP Toolbox for Databases on GitHub.
About Gemini CLI and extensions
Gemini CLI is an open-source AI agent designed to assist with development workflows by assisting with coding, debugging, data exploration, and content creation. It provides an agentic interface for interacting with database and analytics services and popular open-source databases.
How extensions work
Gemini CLI is highly extensible, allowing for the addition of new tools and capabilities through extensions. You can load the extensions from a GitHub URL, a local directory, or a configurable registry. They provide new tools, slash commands, and prompts to assist with your workflow.
Use the Gemini CLI extensions in Cloud SQL for MySQL
The Cloud SQL Gemini CLI extension is based on MCP Toolbox for Databases. MCP Toolbox for Databases is currently in beta (pre-v1.0), and may see breaking changes until the first stable release (v1.0).
The integration with Gemini CLI is through a dedicated extension that offers additional capabilities compared to the standard Toolbox connection. The extension offers a streamlined installation process and a set of tools.
For more information, see GitHub documentation for the Gemini CLI extension for Cloud SQL for MySQL.Gemini CLI extension for Cloud SQL for MySQL databases
Thecloud-sql-mysql
extension includes tools for querying the database and monitoring database health.
Category | Tools |
---|---|
Database operations |
|
Resource management for instances, & users |
|
The cloud-sql-mysql-observability
extension provides a unified
interface for managing and monitoring database performance and health directly
from the Gemini CLI.
Category | Tools |
---|---|
Observability |
|
Gemini CLI extension for MySQL databases
For a list of those operations, see MCP Toolbox for Databases and Gemini CLI extension for MySQL.
Before you begin
In the Google Cloud console, on the project selector page, select or create a Google Cloud project.
Make sure that billing is enabled for your Google Cloud project.
By default, Cloud SQL assigns a public IP address to a new instance. Depending on your use case, make sure either a Public IP or Private IP is set up for your Cloud SQL instances. Toolbox connects securely using the Cloud SQL Language Connectors.
Grant the necessary Identity and Access Management (IAM) roles to the user that will be running the MCP server. The tools available depends on the roles granted:
Task Role name Required IAM role Provides read-only access to resources, including the following operations: get_instance
list_instances
list_databases
wait_for_operation
Cloud SQL Viewer roles/cloudsql.viewer
Provides read-only access to monitoring data such as time series metrics. Cloud Monitoring Viewer roles/monitoring.viewer
Provides permissions to manage existing resources, including the following: - All
viewer
tools create_database
Cloud SQL Editor roles/cloudsql.editor
Provides full control over all resources, including the following: - All
viewer
andeditor
tools create_instance
create_user
Cloud SQL Admin roles/cloudsql.admin
Configure Application Default Credentials (ADC) for your environment.
Create or reuse a database user, and have the username and password ready.
Install the MCP Toolbox
To install the toolbox, download the binary that corresponds to your operating system and CPU architecture.
linux/amd64
curl -O https://storage.googleapis.com/genai-toolbox/v0.7.0/linux/amd64/toolbox
darwin/arm64
curl -O https://storage.googleapis.com/genai-toolbox/v0.7.0/darwin/arm64/toolbox
darwin/amd64
curl -O https://storage.googleapis.com/genai-toolbox/v0.7.0/darwin/amd64/toolbox
windows/amd64
curl -O https://storage.googleapis.com/genai-toolbox/v0.7.0/windows/amd64/toolbox
Make the binary executable:
chmod +x toolbox
Verify the installation using the following command:
./toolbox --version
Configure the MCP Client
This section describes how to configure various developer tools to connect to your Cloud SQL instance using Toolbox. Toolbox acts as an open-source Model Context Protocol (MCP) server that sits between your IDE and your database, providing a secure and efficient control plane for your AI tools. Select the tab for your specific tool to see the configuration instructions.
Gemini CLI for Cloud SQL for MySQL
1. Install the Gemini CLI.
2. Install the Cloud SQL for MySQL extension for Gemini CLI from the GitHub repository using the following command:
gemini extensions install https://github.com/gemini-cli-extensions/cloud-sql-mysql
export CLOUD_SQL_MYSQL_PROJECT="PROJECT_NAME" export CLOUD_SQL_MYSQL_REGION="REGION" export CLOUD_SQL_MYSQL_INSTANCE="INSTANCE_NAME" export CLOUD_SQL_MYSQL_DATABASE="DATABASE_NAME" export CLOUD_SQL_MYSQL_USER="DATABASE_USER_NAME" export CLOUD_SQL_MYSQL_PASSWORD="PASSWORD" export CLOUD_SQL_MYSQL_IP_TYPE="IP_TYPE"
- PROJECT_NAME: The Google Cloud project ID.
- REGION: The region of your Cloud SQL instance.
- INSTANCE_NAME: The ID of your Cloud SQL instance.
- DATABASE_NAME: The name of the database to connect to.
- DATABASE_USER_NAME: Optional: The database username. Defaults to IAM authentication if unspecified.
- PASSWORD: Optional: The password for the database user. Defaults to IAM authentication if unspecified.
- IP_TYPE: Optional: The IP type, such as "Public" (default) or "Private".
gemini
The CLI automatically loads the Gemini CLI extension for Cloud SQL and its tools, which you can use to interact with your database.
In the Gemini CLI, use the /extensions
command to verify the extension is installed and /mcp list
command to see the tools.
Gemini CLI for MySQL
1. Install the Gemini CLI.
2. Install the MySQL software extension for Gemini CLI from the GitHub repository using the following command:
gemini extensions install https://github.com/gemini-cli-extensions/mysql
export MYSQL_HOST="HOST" export MYSQL_PORT="PORT" export MYSQL_DATABASE="DATABASE" export MYSQL_USER="USER" export MYSQL_PASSWORD="PASSWORD" export MYSQL_QUERY_PARAMETERS="QUERY_PARAMETERS"
- HOST: The hostname or IP address of the MySQL server.
- PORT: The port number for the MySQL server.
- DATABASE: The name of the database to connect to.
- USER: The database username.
- PASSWORD: The password for the database user.
- QUERY_PARAMETERS: Optional: The raw query to be added to the
db
connection string.
gemini
The CLI automatically loads the Gemini CLI extension for MySQL and its tools, which you can use to interact with your database.
Gemini Code Assist
1. Install the Gemini Code Assist extension in Visual Studio Code.
2. Enable Agent Mode in Gemini Code Assist chat.
3. In your working directory, create a folder named
.gemini
. Within it, create a settings.json
file.4. Add the following configuration, replace the environment variables with your values, and then save:
{
"mcpServers": {
"cloud-sql-mysql": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","cloud-sql-mysql","--stdio"],
"env": {
"CLOUD_SQL_MYSQL_PROJECT": "PROJECT_ID",
"CLOUD_SQL_MYSQL_REGION": "REGION",
"CLOUD_SQL_MYSQL_INSTANCE":"INSTANCE_ID",
"CLOUD_SQL_MYSQL_DATABASE": "DATABASE_NAME",
"CLOUD_SQL_MYSQL_USER": "USER_ID",
"CLOUD_SQL_MYSQL_PASSWORD": "PASSWORD"
}
}
}
}
Claude code
1. Install Claude Code.
2. Create
.mcp.json
file in your project root if it does not exist. 3. Add configuration, replace the environment variables with your values, and save:
{
"mcpServers": {
"cloud-sql-mysql": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","cloud-sql-mysql","--stdio"],
"env": {
"CLOUD_SQL_MYSQL_PROJECT": "PROJECT_ID",
"CLOUD_SQL_MYSQL_REGION": "REGION",
"CLOUD_SQL_MYSQL_INSTANCE":"INSTANCE_ID",
"CLOUD_SQL_MYSQL_DATABASE": "DATABASE_NAME",
"CLOUD_SQL_MYSQL_USER": "USER_ID",
"CLOUD_SQL_MYSQL_PASSWORD": "PASSWORD"
}
}
}
}
Claude desktop
1. Open Claude Desktop and navigate to Settings.
2. Under the Developer tab, tap Edit Config to open the configuration file.
3. Add configuration, replace the environment variables with your values, and save:
{
"mcpServers": {
"cloud-sql-mysql": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","cloud-sql-mysql","--stdio"],
"env": {
"CLOUD_SQL_MYSQL_PROJECT": "PROJECT_ID",
"CLOUD_SQL_MYSQL_REGION": "REGION",
"CLOUD_SQL_MYSQL_INSTANCE":"INSTANCE_ID",
"CLOUD_SQL_MYSQL_DATABASE": "DATABASE_NAME",
"CLOUD_SQL_MYSQL_USER": "USER_ID",
"CLOUD_SQL_MYSQL_PASSWORD": "PASSWORD"
}
}
}
}
5. Restart Claude Desktop.
6. The new chat screen displays a hammer (MCP) icon with the new MCP server available.
Cline
1. Open Cline extension in VS Code and tap MCP Servers icon.
2. Tap Configure MCP Servers to open the configuration file.
3. Add the following configuration, replace the environment variables with your values, and save:
{
"mcpServers": {
"cloud-sql-mysql": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","cloud-sql-mysql","--stdio"],
"env": {
"CLOUD_SQL_MYSQL_PROJECT": "PROJECT_ID",
"CLOUD_SQL_MYSQL_REGION": "REGION",
"CLOUD_SQL_MYSQL_INSTANCE":"INSTANCE_ID",
"CLOUD_SQL_MYSQL_DATABASE": "DATABASE_NAME",
"CLOUD_SQL_MYSQL_USER": "USER_ID",
"CLOUD_SQL_MYSQL_PASSWORD": "PASSWORD"
}
}
}
}
4. A green active status appears after the server connects successfully.
Cursor
1. Create
.cursor
directory in your project root if it does not exist. 2. Create
.cursor/mcp.json
file if it does not exist and open it.3. Add the following configuration, replace the environment variables with your values, and save:
{
"mcpServers": {
"cloud-sql-mysql": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","cloud-sql-mysql","--stdio"],
"env": {
"CLOUD_SQL_MYSQL_PROJECT": "PROJECT_ID",
"CLOUD_SQL_MYSQL_REGION": "REGION",
"CLOUD_SQL_MYSQL_INSTANCE":"INSTANCE_ID",
"CLOUD_SQL_MYSQL_DATABASE": "DATABASE_NAME",
"CLOUD_SQL_MYSQL_USER": "USER_ID",
"CLOUD_SQL_MYSQL_PASSWORD": "PASSWORD"
}
}
}
}
4. Open Cursor and navigate to Settings > Cursor Settings > MCP. A green active status appears when the server connects.
Visual Studio Code (Copilot)
1. Open VS Code and create
.vscode
directory in your project root if it does
not exist. 2. Create
.vscode/mcp.json
file if it does not exist, and open it. 3. Add the following configuration, replace the environment variables with your values, and save:
{
"servers": {
"cloud-sql-mysql": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","cloud-sql-mysql","--stdio"],
"env": {
"CLOUD_SQL_MYSQL_PROJECT": "PROJECT_ID",
"CLOUD_SQL_MYSQL_REGION": "REGION",
"CLOUD_SQL_MYSQL_INSTANCE":"INSTANCE_ID",
"CLOUD_SQL_MYSQL_DATABASE": "DATABASE_NAME",
"CLOUD_SQL_MYSQL_USER": "USER_ID",
"CLOUD_SQL_MYSQL_PASSWORD": "PASSWORD"
}
}
}
}
Windsurf
1. Open Windsurf and navigate to Cascade assistant.
2. Tap MCP icon, then tap Configure to open the configuration file.
3. Add the following configuration, replace the environment variables with your values, and save:
{
"mcpServers": {
"cloud-sql-mysql": {
"command": "./PATH/TO/toolbox",
"args": ["--prebuilt","cloud-sql-mysql","--stdio"],
"env": {
"CLOUD_SQL_MYSQL_PROJECT": "PROJECT_ID",
"CLOUD_SQL_MYSQL_REGION": "REGION",
"CLOUD_SQL_MYSQL_INSTANCE":"INSTANCE_ID",
"CLOUD_SQL_MYSQL_DATABASE": "DATABASE_NAME",
"CLOUD_SQL_MYSQL_USER": "USER_ID",
"CLOUD_SQL_MYSQL_PASSWORD": "PASSWORD"
}
}
}
}