Connect your IDE to Cloud SQL Stay organized with collections Save and categorize content based on your preferences.
This guide shows you how to use theMCP Toolbox forDatabases to connect yourCloud SQL instance to various Integrated Development Environments (IDEs)and developer tools that supportModel Context Protocol(MCP). Use these tools to runSQL queries and interact with your database.
The Model Context Protocol (MCP) is an open protocol for connecting largelanguage models (LLMs) to data sources such as Cloud SQL. The IDEssupported are:
- Cursor
- Windsurf
- Visual Studio Code(Copilot)
- Cline(VS Code extension)
- Claude desktop
- Claude code
- Gemini CLI
- Gemini Code Assist
Before you begin
In the Google Cloud console, on theproject selectorpage,select or create a Google Cloud project.
Make sure that billing is enabled for your Google Cloudproject.
VerifyPublic IP is set up forCloud SQL instance. By default, Cloud SQL assigns a public IPaddress to a new instance. Toolbox connects securely using theCloud SQL Language Connectors.
Configure the required roles and permissions to complete this task. You needCloud SQL >Clientrole (
roles/cloudsql.client
) or equivalent Identity and Access Management permissions toconnect to the instance.ConfigureApplication Default Credentials(ADC) for yourenvironment.
Create or reusea database user,and have the username and password ready.
Install the MCP Toolbox
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+xtoolbox
Verify the installation using the following command:
./toolbox--version
Configure the MCP Client
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-postgres": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-postgres","--stdio"], "env": { "CLOUD_SQL_POSTGRES_PROJECT": "PROJECT_ID", "CLOUD_SQL_POSTGRES_REGION": "REGION", "CLOUD_SQL_POSTGRES_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_POSTGRES_DATABASE": "DATABASE_NAME", "CLOUD_SQL_POSTGRES_USER": "USER_ID", "CLOUD_SQL_POSTGRES_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-postgres": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-postgres","--stdio"], "env": { "CLOUD_SQL_POSTGRES_PROJECT": "PROJECT_ID", "CLOUD_SQL_POSTGRES_REGION": "REGION", "CLOUD_SQL_POSTGRES_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_POSTGRES_DATABASE": "DATABASE_NAME", "CLOUD_SQL_POSTGRES_USER": "USER_ID", "CLOUD_SQL_POSTGRES_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-postgres": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-postgres","--stdio"], "env": { "CLOUD_SQL_POSTGRES_PROJECT": "PROJECT_ID", "CLOUD_SQL_POSTGRES_REGION": "REGION", "CLOUD_SQL_POSTGRES_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_POSTGRES_DATABASE": "DATABASE_NAME", "CLOUD_SQL_POSTGRES_USER": "USER_ID", "CLOUD_SQL_POSTGRES_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-postgres": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-postgres","--stdio"], "env": { "CLOUD_SQL_POSTGRES_PROJECT": "PROJECT_ID", "CLOUD_SQL_POSTGRES_REGION": "REGION", "CLOUD_SQL_POSTGRES_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_POSTGRES_DATABASE": "DATABASE_NAME", "CLOUD_SQL_POSTGRES_USER": "USER_ID", "CLOUD_SQL_POSTGRES_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:
{ "mcp": { "servers": { "cloud-sql-postgres": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-postgres","--stdio"], "env": { "CLOUD_SQL_POSTGRES_PROJECT": "PROJECT_ID", "CLOUD_SQL_POSTGRES_REGION": "REGION", "CLOUD_SQL_POSTGRES_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_POSTGRES_DATABASE": "DATABASE_NAME", "CLOUD_SQL_POSTGRES_USER": "USER_ID", "CLOUD_SQL_POSTGRES_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-postgres": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-postgres","--stdio"], "env": { "CLOUD_SQL_POSTGRES_PROJECT": "PROJECT_ID", "CLOUD_SQL_POSTGRES_REGION": "REGION", "CLOUD_SQL_POSTGRES_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_POSTGRES_DATABASE": "DATABASE_NAME", "CLOUD_SQL_POSTGRES_USER": "USER_ID", "CLOUD_SQL_POSTGRES_PASSWORD": "PASSWORD"> } } }}
Gemini CLI
1. Install theGemini CLI.
2. In your working directory, create a folder named
.gemini
. Within it, create asettings.json
file.3. Add the following configuration, replace the environment variables with your values, and then save:
{ "mcpServers": { "cloud-sql-postgres": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-postgres","--stdio"], "env": { "CLOUD_SQL_POSTGRES_PROJECT": "PROJECT_ID", "CLOUD_SQL_POSTGRES_REGION": "REGION", "CLOUD_SQL_POSTGRES_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_POSTGRES_DATABASE": "DATABASE_NAME", "CLOUD_SQL_POSTGRES_USER": "USER_ID", "CLOUD_SQL_POSTGRES_PASSWORD": "PASSWORD"> } } }}
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-postgres": { "command": "./PATH/TO/toolbox", "args": ["--prebuilt","cloud-sql-postgres","--stdio"], "env": { "CLOUD_SQL_POSTGRES_PROJECT": "PROJECT_ID", "CLOUD_SQL_POSTGRES_REGION": "REGION", "CLOUD_SQL_POSTGRES_INSTANCE": "INSTANCE_ID", "CLOUD_SQL_POSTGRES_DATABASE": "DATABASE_NAME", "CLOUD_SQL_POSTGRES_USER": "USER_ID", "CLOUD_SQL_POSTGRES_PASSWORD": "PASSWORD"> } } }}
Use Tools
Your AI tool is now connected to Cloud SQL using MCP. Try asking your AIassistant to list tables, create a table, or define and execute other SQLstatements.
The following tools are available to the LLM:
- list_tables: lists tables and descriptions
- execute_sql: execute any SQL statement
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-07-14 UTC.