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
- Codex
- Cline (VS Code extension)
- Cursor
- Visual Studio Code (Copilot)
- Windsurf (Codeium)
- Antigravity
For an integrated experience, we recommend using the dedicated Gemini CLI extension for Cloud SQL for PostgreSQL .
As Google Cloud's next-generation command-line interface, Gemini CLI bundles the underlying skills 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, skills, and prompts to assist with your workflow.
Use the Gemini CLI extensions in Cloud SQL for PostgreSQL
The Cloud SQL Gemini CLI extension is based on MCP Toolbox for Databases.
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 skills based on MCP Tools.
For more information, see GitHub documentation for the Gemini CLI extension for Cloud SQL for PostgreSQL .Gemini CLI extension for Cloud SQL for PostgreSQL databases
Thecloud-sql-postgresql
extension includes skills for querying the
database, managing Cloud SQL resources, and monitoring database health. For all available skills, see the Cloud SQL skills on GitHub
The cloud-sql-postgresql-observability
extension provides a unified
interface for managing and monitoring database performance and health directly
from the Gemini CLI.
-
get_system_metrics: Retrieves system metrics for a Cloud SQL instance. -
get_query_metrics: Retrieves query-related metrics for a Cloud SQL instance.
Gemini CLI extension for PostgreSQL databases
For a list of those operations, see MCP Toolbox for Databases and Gemini CLI extension for PostgreSQL .
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 .
-
Enable the Cloud SQL Admin API in the 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:
TaskRole nameRequired IAM roleProvides read-only access to resources, including the following operations:-
get_instance -
list_instances -
list_databases -
wait_for_operation
Cloud SQL Viewerroles/cloudsql.viewerProvides read-only access to monitoring data such as time series metrics.Cloud Monitoring Viewerroles/monitoring.viewerProvides permissions to manage existing resources, including the following:- All
viewertools -
create_database
Cloud SQL Editorroles/cloudsql.editorProvides full control over all resources, including the following:- All
viewerandeditortools -
create_instance -
create_user
Cloud SQL Adminroles/cloudsql.admin -
-
Configure Application Default Credentials (ADC) for your environment.
-
Create or reuse a database user , and have the username and password ready.
Connect with Antigravity
You can connect Cloud SQL for PostgreSQL to Antigravity in the following ways:
- Use the MCP Store
- Use a custom configuration
MCP Store
The most recommended method to connect to Cloud SQL for PostgreSQL in Antigravity is to use the built-in MCP Store.
- Open Antigravity and open the editor's agent panel .
- Click the "..." icon at the top of the panel and select MCP Servers .
- Locate Cloud SQL for PostgreSQL in the list of available servers and click Install .
- Follow the on-screen prompts to securely link your accounts where applicable.
After you install Cloud SQL for PostgreSQL in the MCP Store, resources and tools from the server are automatically available to the editor.
Custom configuration
To connect to a custom MCP server, follow these steps:
- Open Antigravity and open the editor's agent panel .
- Click the "..." icon at the top of the panel and select MCP Servers .
- Click Manage MCP Servers > View raw config
to open the
mcp_config.jsonfile. - Add the following configuration, replace the environment variables with your values, and save.
{ "mcpServers": { "cloud-sql-postgres": { "command": "npx", "args": ["-y","@toolbox-sdk/server","--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 " } } } }
Once you configure the custom MCP server, the resources and tools from the Cloud SQL for PostgreSQL server are available to the editor.
Install the MCP Toolbox
< div
>
< devsite
-
selector
>
< section
>
< h3
id
=
"linux-amd64"
> linux
/
amd64
< /
h3
>
< pre
class
=
"devsite-click-to-copy"
> curl
-
O
https
:
//
storage
.
googleapis
.
com
/
genai
-
toolbox
/
v0
.
7
.
0
/
linux
/
amd64
/
toolbox
< /
pre
>
< /
section
>
< section
>
< h3
id
=
"darwin-arm64"
> darwin
/
arm64
< /
h3
>
< pre
class
=
"devsite-click-to-copy"
> curl
-
O
https
:
//
storage
.
googleapis
.
com
/
genai
-
toolbox
/
v0
.
7
.
0
/
darwin
/
arm64
/
toolbox
< /
pre
>
< /
section
>
< section
>
< h3
id
=
"darwin-amd64"
> darwin
/
amd64
< /
h3
>
< pre
class
=
"devsite-click-to-copy"
> curl
-
O
https
:
//
storage
.
googleapis
.
com
/
genai
-
toolbox
/
v0
.
7
.
0
/
darwin
/
amd64
/
toolbox
< /
pre
>
< /
section
>
< section
>
< h3
id
=
"windows-amd64"
> windows
/
amd64
< /
h3
>
< pre
class
=
"devsite-click-to-copy"
> curl
-
O
https
:
//
storage
.
googleapis
.
com
/
genai
-
toolbox
/
v0
.
7
.
0
/
windows
/
amd64
/
toolbox
< /
pre
>
< /
section
>
< /
devsite
-
selector
>
< /
div
>
```
bash
chmod
+
x
toolbox
```
```
bash
.
/
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 PostgreSQL
- Install the Gemini CLI .
- Install the Cloud SQL for PostgreSQL extension for Gemini CLI from the GitHub
repository using the following command:
While installing the extension, replace the following:gemini extensions install https://github.com/gemini-cli-extensions/cloud-sql-postgresql
- 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".
- Start the Gemini CLI in interactive mode:
gemini
The CLI automatically loads the Gemini CLI extension for Cloud SQL and its skills, which you can use to interact with your database.
In the Gemini CLI, use the
/extensionscommand to verify the extension is installed and/mcp listcommand to see the tools.
Gemini CLI for PostgreSQL
- Install the Gemini CLI .
- Install the PostgreSQL software extension for Gemini
CLI from the GitHub repository using the following command:
While installing the extension, replace the following:gemini extensions install https://github.com/gemini-cli-extensions/postgres
Replace the following:export POSTGRES_HOST=" HOST " export POSTGRES_PORT=" PORT " export POSTGRES_DATABASE=" DATABASE " export POSTGRES_USER=" USER " export POSTGRES_PASSWORD=" PASSWORD " export POSTGRES_QUERY_PARAMETERS=" QUERY_PARAMETERS "
- HOST : The hostname or IP address of the PostgreSQL server.
- PORT : The port number for the PostgreSQL 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
dbconnection string.
- Start the Gemini CLI in interactive mode:
gemini
The CLI automatically loads the Gemini CLI extension for PostgreSQL and its tools, which you can use to interact with your database.
Gemini Code Assist
- Install the Gemini Code Assist extension in Visual Studio Code.
- Enable Agent Mode in Gemini Code Assist chat.
- In your working directory, create a folder named
.gemini. Within it, create asettings.jsonfile. - 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 " } } } }
Claude code
- Install Claude Code .
- Set environment variables to connect to your Cloud SQL instance:
Replace the following:export CLOUD_SQL_POSTGRES_PROJECT=" PROJECT_NAME " export CLOUD_SQL_POSTGRES_REGION=" REGION " export CLOUD_SQL_POSTGRES_INSTANCE=" INSTANCE_NAME " export CLOUD_SQL_POSTGRES_DATABASE=" DATABASE_NAME " export CLOUD_SQL_POSTGRES_USER=" DATABASE_USER_NAME " export CLOUD_SQL_POSTGRES_PASSWORD=" PASSWORD " export CLOUD_SQL_POSTGRES_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".
- Start the agent:
claude
- Find the latest release version at Cloud SQL for PostgreSQL Skills repository
and add the marketplace:
/plugin marketplace add https://github.com/gemini-cli-extensions/cloud-sql-postgresql.git# VERSION - Install the plugin:
/plugin install cloud-sql-postgresql@cloud-sql-postgresql-marketplace
Claude desktop
- Open Claude Desktop and navigate to Settings .
- Under the Developer tab, tap Edit Config to open the configuration file.
- Add the following to connect to the MCP server and set the environment variables:
{ "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 " } } } } - Restart Claude Desktop. The new chat screen displays the MCP icon with the new MCP server available.
Cline
- Open Cline extension in VS Code and tap MCP Servers icon.
- Tap Configure MCP Servers to open the configuration file.
- Add the following configuration, replace the environment variables with your values, and save:
A green active status appears after the server connects successfully.{ "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 " } } } }
Codex
- Find the latest release version at Cloud SQL for PostgreSQL Skills repository
and clone it:
git clone --branch VERSION git@github.com:gemini-cli-extensions/cloud-sql-postgresql.git
- Install the plugin:
mkdir -p ~/.codex/plugins cp -R /absolute/path/to/cloud-sql-postgresql ~/.codex/plugins/cloud-sql-postgresql
- Configure the environment variables to connect to your Cloud SQL instance:
Replace the following:export CLOUD_SQL_POSTGRES_PROJECT=" PROJECT_NAME " export CLOUD_SQL_POSTGRES_REGION=" REGION " export CLOUD_SQL_POSTGRES_INSTANCE=" INSTANCE_NAME " export CLOUD_SQL_POSTGRES_DATABASE=" DATABASE_NAME " export CLOUD_SQL_POSTGRES_USER=" DATABASE_USER_NAME " export CLOUD_SQL_POSTGRES_PASSWORD=" PASSWORD " export CLOUD_SQL_POSTGRES_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".
- Create or update marketplace.json:
{ "name": "my-data-cloud-google-marketplace", "interface": { "displayName": "Google Data Cloud Skills" }, "plugins": [ { "name": "cloud-sql-postgresql", "source": { "source": "local", "path": "./plugins/cloud-sql-postgresql" }, "policy": { "installation": "AVAILABLE", "authentication": "ON_INSTALL" }, "category": "Database" } ] } - Run
codex plugin listor use thepluginsinteractive menu to verify your installed plugins.
Cline
- Open Cline extension in VS Code and tap MCP Servers icon.
- Tap Configure MCP Servers to open the configuration file.
- Add the following configuration, replace the environment variables with your values, and save:
A green active status appears after the server connects successfully.{ "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 " } } } }
Cursor
- Create
.cursordirectory in your project root if it does not exist. - Create
.cursor/mcp.jsonfile if it does not exist and open it. - 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 " } } } } - Open Cursor and navigate to Settings > Cursor Settings > MCP . A green active status appears when the server connects.
Visual Studio Code (Copilot)
- Open VS Code
and create
.vscodedirectory in your project root if it does not exist. - Create
.vscode/mcp.jsonfile if it does not exist, and open it. - Add the following configuration, replace the environment variables with your values, and save:
{ "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
- Open Windsurf and navigate to Cascade assistant .
- Tap MCP icon, then tap Configure to open the configuration file.
- 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 " } } } }

