Connect your IDE to Cloud SQL

This guide shows you how to use the MCP Toolbox for Databases to connect your Cloud SQL instance to various Integrated Development Environments (IDEs) and developer tools that support Model Context Protocol (MCP). Use these tools to run SQL queries and interact with your database.

The Model Context Protocol (MCP) is an open protocol for connecting large language models (LLMs) to data sources such as Cloud SQL. The IDEs supported are:

Before you begin

  1. In the Google Cloud console, on the project selector page, select or create a Google Cloud project.

  2. Make sure that billing is enabled for your Google Cloud project.

  3. Enable the Cloud SQL Admin API in the Google Cloud project.

  4. Ensure Public IP is set up for Cloud SQL instance. By default, Cloud SQL assigns a public IP address to a new instance. Toolbox connects securely using the Cloud SQL Language Connectors.

  5. Configure the required roles and permissions to complete this task. You need Cloud SQL > Client role (roles/cloudsql.client) or equivalent Identity and Access Management permissions to connect to the instance.

  6. Configure Application Default Credentials (ADC) for your environment.

  7. Create or reuse a database user, and have the username and password ready.

Install the MCP Toolbox

  1. 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.6.0/linux/amd64/toolbox

    darwin/arm64

    curl -O https://storage.googleapis.com/genai-toolbox/v0.6.0/darwin/arm64/toolbox

    darwin/amd64

    curl -O https://storage.googleapis.com/genai-toolbox/v0.6.0/darwin/amd64/toolbox

    windows/amd64

    curl -O https://storage.googleapis.com/genai-toolbox/v0.6.0/windows/amd64/toolbox
  2. Make the binary executable:

    chmod +x toolbox
    
  3. Verify the installation using the following command:

    ./toolbox --version
    

Configure the MCP Client

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-sqlserver": {
      "command": "./PATH/TO/toolbox",
      "args": ["--prebuilt","cloud-sql-mssql","--stdio"],
      "env": {
        "CLOUD_SQL_MSSQL_PROJECT": "",
        "CLOUD_SQL_MSSQL_REGION": "",
        "CLOUD_SQL_MSSQL_INSTANCE": "",
        "CLOUD_SQL_MSSQL_DATABASE": "",
        "CLOUD_SQL_MSSQL_IP_ADDRESS": "",
        "CLOUD_SQL_MSSQL_USER": "",
        "CLOUD_SQL_MSSQL_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-sqlserver": {
      "command": "./PATH/TO/toolbox",
      "args": ["--prebuilt","cloud-sql-mssql","--stdio"],
      "env": {
        "CLOUD_SQL_MSSQL_PROJECT": "",
        "CLOUD_SQL_MSSQL_REGION": "",
        "CLOUD_SQL_MSSQL_INSTANCE": "",
        "CLOUD_SQL_MSSQL_DATABASE": "",
        "CLOUD_SQL_MSSQL_IP_ADDRESS": "",
        "CLOUD_SQL_MSSQL_USER": "",
        "CLOUD_SQL_MSSQL_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-sqlserver": {
      "command": "./PATH/TO/toolbox",
      "args": ["--prebuilt","cloud-sql-mssql","--stdio"],
      "env": {
        "CLOUD_SQL_MSSQL_PROJECT": "",
        "CLOUD_SQL_MSSQL_REGION": "",
        "CLOUD_SQL_MSSQL_INSTANCE": "",
        "CLOUD_SQL_MSSQL_DATABASE": "",
        "CLOUD_SQL_MSSQL_IP_ADDRESS": "",
        "CLOUD_SQL_MSSQL_USER": "",
        "CLOUD_SQL_MSSQL_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": "",
        "CLOUD_SQL_MSSQL_REGION": "",
        "CLOUD_SQL_MSSQL_INSTANCE": "",
        "CLOUD_SQL_MSSQL_DATABASE": "",
        "CLOUD_SQL_MSSQL_IP_ADDRESS": "",
        "CLOUD_SQL_MSSQL_USER": "",
        "CLOUD_SQL_MSSQL_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:


{
  "mcpServers": {
    "cloud-sql-sqlserver": {
      "command": "./PATH/TO/toolbox",
      "args": ["--prebuilt","cloud-sql-mssql","--stdio"],
      "env": {
        "CLOUD_SQL_MSSQL_PROJECT": "",
        "CLOUD_SQL_MSSQL_REGION": "",
        "CLOUD_SQL_MSSQL_INSTANCE": "",
        "CLOUD_SQL_MSSQL_DATABASE": "",
        "CLOUD_SQL_MSSQL_IP_ADDRESS": "",
        "CLOUD_SQL_MSSQL_USER": "",
        "CLOUD_SQL_MSSQL_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-sqlserver": {
      "command": "./PATH/TO/toolbox",
      "args": ["--prebuilt","cloud-sql-mssql","--stdio"],
      "env": {
        "CLOUD_SQL_MSSQL_PROJECT": "",
        "CLOUD_SQL_MSSQL_REGION": "",
        "CLOUD_SQL_MSSQL_INSTANCE": "",
        "CLOUD_SQL_MSSQL_DATABASE": "",
        "CLOUD_SQL_MSSQL_IP_ADDRESS": "",
        "CLOUD_SQL_MSSQL_USER": "",
        "CLOUD_SQL_MSSQL_PASSWORD": ""
      }
    }
  }
}

Use Tools

Your AI tool is now connected to Cloud SQL using MCP. Try asking your AI assistant to list tables, create a table, or define and execute other SQL statements.

The following tools are available to the LLM:

  1. list_tables: lists tables and descriptions
  2. execute_sql: execute any SQL statement