Use Cloud SQL for SQL Server with MCP, Gemini CLI, and other agents Stay organized with collections Save and categorize content based on your preferences.
This page shows you how to connect your Cloud SQL instance to various AIdeveloper 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 dedicatedGemini CLI extension for Cloud SQL for SQL Server.
As Google Cloud's next-generation command-line interface, Gemini CLIbundles the underlying MCP server directly into the extension, which simplifiessetup and configuration. You can configure Gemini Code Assist to usethe Gemini CLI, offering similar setup benefits in your IDE.
For other developer tools that support theModel Context Protocol (MCP),you can connect by manually configuring theMCP Toolbox for Databases (Toolbox). Toolbox is an open-source MCP server that connects AI agents to your data bymanaging tasks such as authentication and connection pooling. This lets youinteract with your data using natural language directly from your IDE. For thesetools, this method provides core database interaction capabilities.
For more information, seePrebuilt toolsandMCP Toolbox for Databases on GitHub.
About Gemini CLI and extensions
Gemini CLI is an open-source AI agent designed to assist with developmentworkflows by assisting with coding, debugging, data exploration, and contentcreation. It provides an agentic interface for interacting withdatabase and analytics services and popular open-source databases.
How extensions work
Gemini CLI is highly extensible, allowing for the addition of new toolsand capabilities through extensions. You can load the extensions from a GitHubURL, a local directory, or a configurable registry. They provide new tools, slashcommands, and prompts to assist with your workflow.
Use the Gemini CLI extensions in Cloud SQL for SQL Server
The Cloud SQL Gemini CLI extension is based on MCP Toolbox forDatabases.MCP Toolbox for Databases is currently in beta (pre-v1.0), and may seebreaking changes until the first stable release (v1.0).
The integration with Gemini CLI is through a dedicated extension thatoffers additional capabilities compared to the standard Toolbox connection. Theextension offers a streamlined installation process and a set of tools.
For more information, see GitHub documentation for theGemini CLI extension for Cloud SQL for SQL Server.Gemini CLI extension for Cloud SQL for SQL Server databases
Thecloud-sql-sqlserver extension includes tools for querying thedatabase and monitoring database health.| Category | Tools |
|---|---|
| Database operations |
|
| Resource management for instances, & users |
|
Thecloud-sql-sqlserver-observability extension provides a unifiedinterface for managing and monitoring database performance and health directlyfrom the Gemini CLI.
| Category | Tools |
|---|---|
| Observability |
|
Gemini CLI extension for SQL Server databases
For a list of those operations, seeMCP Toolbox for DatabasesandGemini CLI extension for SQL Server.
Before you begin
In the Google Cloud console, on theproject 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. Dependingon your use case, make sure either aPublic IPorPrivate IP is set up for yourCloud SQL instances. Toolbox connects securely using theCloud SQL Language Connectors.
Grant the necessaryIdentity and Access Management (IAM)roles to the user that will be running the MCP server. The tools availabledepends on the roles granted:
Task Role name Required IAM role Provides read-only access to resources, including the following operations: get_instancelist_instanceslist_databaseswait_for_operation
Cloud SQL Viewer roles/cloudsql.viewerProvides read-only access to monitoring data such as time series metrics. Cloud Monitoring Viewer roles/monitoring.viewerProvides permissions to manage existing resources, including the following: - All
viewertools create_database
Cloud SQL Editor roles/cloudsql.editorProvides full control over all resources, including the following: - All
viewerandeditortools create_instancecreate_user
Cloud SQL Admin roles/cloudsql.adminConfigureApplication Default Credentials (ADC)for your environment.
Create or reusea database user,and have the username and password ready.
Install the MCP Toolbox
Note: This step isn't required for Gemini CLI extensions.To install the toolbox, download the binary that corresponds to youroperating 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+xtoolboxVerify the installation using the following command:
./toolbox--version
Configure the MCP Client
This section describes how to configure various developer tools to connect toyour Cloud SQL instance usingToolbox.Toolbox acts as an open-sourceModel Context Protocol (MCP)server that sits between your IDE and your database, providing a secure andefficient control plane for your AI tools. Select the tab for your specific toolto see the configuration instructions.
Gemini CLI for Cloud SQL for SQL Server
1. Install theGemini CLI.
2. Install the Cloud SQL for SQL Server extension for Gemini CLI from the GitHub repository using the following command:
gemini extensions install https://github.com/gemini-cli-extensions/cloud-sql-sqlserver
export CLOUD_SQL_MSSQL_PROJECT="PROJECT_NAME" export CLOUD_SQL_MSSQL_REGION="REGION" export CLOUD_SQL_MSSQL_INSTANCE="INSTANCE_NAME" export CLOUD_SQL_MSSQL_DATABASE="DATABASE_NAME" export CLOUD_SQL_MSSQL_USER="DATABASE_USER_NAME" export CLOUD_SQL_MSSQL_PASSWORD="PASSWORD" export CLOUD_SQL_MSSQL_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 SQL Server
1. Install theGemini CLI.
2. Install the SQL Server software extension for Gemini CLI from the GitHub repository using the following command:
gemini extensions install https://github.com/gemini-cli-extensions/sql-server
export MSSQL_HOST="HOST" export MSSQL_PORT="PORT" export MSSQL_DATABASE="DATABASE" export MSSQL_USER="USER" export MSSQL_PASSWORD="PASSWORD"
- HOST: The hostname or IP address of the SQL Server server.
- PORT: The port number for the SQL Server server.
- DATABASE: The name of the database to connect to.
- USER: The database username.
- PASSWORD: The password for the database user.
gemini
The CLI automatically loads the Gemini CLI extension for SQL Server and its tools, which you can use to interact with your database.
Gemini Code Assist
1. Install theGemini 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 asettings.json file.4. Add the following configuration, replace the environment variables with your values, and then save:
{ "mcpServers": { "cloud-sql-sqlserver": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-mssql","--stdio"], "env": { "CLOUD_SQL_MSSQL_PROJECT": "PROJECT_ID", "CLOUD_SQL_MSSQL_REGION": "REGION", "CLOUD_SQL_MSSQL_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_MSSQL_DATABASE": "DATABASE_NAME", "CLOUD_SQL_MSSQL_IP_ADDRESS": "IP_ADDRESS", "CLOUD_SQL_MSSQL_USER": "USER_ID", "CLOUD_SQL_MSSQL_PASSWORD": "PASSWORD" } } }}Claude code
1. InstallClaude 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-sqlserver": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-mssql","--stdio"], "env": { "CLOUD_SQL_MSSQL_PROJECT": "PROJECT_ID", "CLOUD_SQL_MSSQL_REGION": "REGION", "CLOUD_SQL_MSSQL_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_MSSQL_DATABASE": "DATABASE_NAME", "CLOUD_SQL_MSSQL_IP_ADDRESS": "IP_ADDRESS", "CLOUD_SQL_MSSQL_USER": "USER_ID", "CLOUD_SQL_MSSQL_PASSWORD": "PASSWORD" } } }}Claude desktop
1. OpenClaude 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-sqlserver": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-mssql","--stdio"], "env": { "CLOUD_SQL_MSSQL_PROJECT": "PROJECT_ID", "CLOUD_SQL_MSSQL_REGION": "REGION", "CLOUD_SQL_MSSQL_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_MSSQL_DATABASE": "DATABASE_NAME", "CLOUD_SQL_MSSQL_IP_ADDRESS": "IP_ADDRESS", "CLOUD_SQL_MSSQL_USER": "USER_ID", "CLOUD_SQL_MSSQL_PASSWORD": "PASSWORD" } } }}5. Restart Claude Desktop.
6. The new chat screen displays a hammer (MCP) icon with the new MCP server available.
Cline
1. OpenCline extension in VS Code and tapMCP 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-sqlserver": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-mssql","--stdio"], "env": { "CLOUD_SQL_MSSQL_PROJECT": "PROJECT_ID", "CLOUD_SQL_MSSQL_REGION": "REGION", "CLOUD_SQL_MSSQL_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_MSSQL_DATABASE": "DATABASE_NAME", "CLOUD_SQL_MSSQL_IP_ADDRESS": "IP_ADDRESS", "CLOUD_SQL_MSSQL_USER": "USER_ID", "CLOUD_SQL_MSSQL_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-sqlserver": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-mssql","--stdio"], "env": { "CLOUD_SQL_MSSQL_PROJECT": "PROJECT_ID", "CLOUD_SQL_MSSQL_REGION": "REGION", "CLOUD_SQL_MSSQL_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_MSSQL_DATABASE": "DATABASE_NAME", "CLOUD_SQL_MSSQL_IP_ADDRESS": "IP_ADDRESS", "CLOUD_SQL_MSSQL_USER": "USER_ID", "CLOUD_SQL_MSSQL_PASSWORD": "PASSWORD" } } }}4. OpenCursor and navigate toSettings > Cursor Settings > MCP. A green active status appears when the server connects.
Visual Studio Code (Copilot)
1. OpenVS 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-sqlserver": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-mssql","--stdio"], "env": { "CLOUD_SQL_MSSQL_PROJECT": "PROJECT_ID", "CLOUD_SQL_MSSQL_REGION": "REGION", "CLOUD_SQL_MSSQL_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_MSSQL_DATABASE": "DATABASE_NAME", "CLOUD_SQL_MSSQL_IP_ADDRESS": "IP_ADDRESS", "CLOUD_SQL_MSSQL_USER": "USER_ID", "CLOUD_SQL_MSSQL_PASSWORD": "PASSWORD" } } }}Windsurf
1. OpenWindsurf and navigate to Cascade assistant.
2. Tap MCP icon, then tapConfigure to open the configuration file.
3. Add the following configuration, replace the environment variables with your values, and save:
{ "mcpServers": { "cloud-sql-sqlserver": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-mssql","--stdio"], "env": { "CLOUD_SQL_MSSQL_PROJECT": "PROJECT_ID", "CLOUD_SQL_MSSQL_REGION": "REGION", "CLOUD_SQL_MSSQL_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_MSSQL_DATABASE": "DATABASE_NAME", "CLOUD_SQL_MSSQL_IP_ADDRESS": "IP_ADDRESS", "CLOUD_SQL_MSSQL_USER": "USER_ID", "CLOUD_SQL_MSSQL_PASSWORD": "PASSWORD" } } }}Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-15 UTC.