

Thank you for reading! If you found this series helpful, please consider taking this 2-minute survey. Your feedback directly helps me create more tutorials for the developer community.
Gemini CLI Tutorial Series:
Part 1 : Installation and Getting Started
Part 2 : Gemini CLI Command line options
Part 3 : Configuration settings via settings.json and .env files
Part 4 : Built-in Tools
Part 5: Using Github MCP Server
Part 6: More MCP Servers : Firebase, Google Workspace, Google Gen AI Media Services and MCP Toolbox for Databases
Part 7: Custom slash commands
Part 8: Building your own MCP Server
Part 9: Understanding Context, Memory and Conversational Branching
Part 10: Gemini CLI and VS Code Integration
Part 11: Gemini CLI Extensions
Part 12: Gemini CLI GitHub Actions
Part 13 : Gemini CLI Observability
Part 14: Gemini CLI extensions for Google Data Cloud (this post)➡️ Codelab : Hands-on Gemini CLI
Welcome back to the Gemini CLI Tutorial Series! Gemini CLI extensions were recently announced and is a standard way for you to bring your tools into Gemini CLI. There is a Gemini CLI extensions gallery that lists both Google and external parties that have developed Gemini CLI extensions.
We covered a deep dive of understand Gemini CLI extensions and not just installing / using them but also how to write one and prepare it for distribution. If you have not yet started on your Gemini CLI extension journey, please do read that part here:
Even prior to the official announcement, there was a big bang post that announced a series of Gemini CLI extensions for Google Data Cloud. Almost every single Google Cloud Data product now had a Gemini CLI extensions and depending on the functionality exposed, you could not just query the data but also perform administrative functions, if supported. This truly brought the idea of staying in your terminal while interacting with your databases by giving your queries in natural language.
As the original blog post stated, “Whether you’re just getting started or a seasoned developer, these extensions make common data interactions such as app development, deployment, operations, and data analytics more productive and easier.”
Gemini CLI extensions for Google Data Cloud
The blog post listed down a long list of Gemini CLI extensions for Google Data Cloud. Right from Spanner, Cloud SQL, AlloyDB, Firebase, BigQuery and several other databases, including ones that you could use locally.
You can check out the list here (though this one has some extensions other than ones for the Google Data Cloud too):
I will reproduce a list from the blog post that showed the list of extensions, what they are for and the configuration steps:
Getitng started with any of the extensions
If you are familiar with Gemini CLI extensions and the gemini extensions install
command that we have covered in the earlier part on Extensions, using these extensions would be a breeze.
The steps would be to:
- Ensure that you are running the latest version of the Gemini CLI tool. Use the
npm install -g @google/gemini-cli@latest
command to do so. - Pick the Data product in Google Cloud that you want to experiment with, say Cloud SQL for MySQL. Ensure that you have the local
gcloud
CLI setup with authentication and Google Cloud Project Id setup. - Use the command
gemini extensions install https://github.com/gemini-cli-extensions/
command, where
is the name of the extension. For e.g. cloud-sql-mysql. - Visit the respective page for the extension. For e.g. the Gemini CLI Extension — CLoud SQL for MySQL page and it will provide additional Environemnt variables, GCP Roles, etc that are needed to be configured.
- Check out the sample queries/operations supported by the extension (several of them are provided in the docs) and understand how it all comes together.
Under the hood
What got me immediately interested in this large list of Gemini CLI extensions for Google Data Cloud was to understand how this was made possible. I strongly suspected that a common underlying software was doing the hardwork underneath it and in fact I have written and spoken about it at several events.
The workhorse behind these extensions is the MCP Toolbox for Databases.
We have used this in Part 6: More MCP Servers : Firebase, Google Workspace, Google Gen AI Media Services and MCP Toolbox for Databases, where we saw how MCP Toolbox provides a MCP Server for the databases. In essence, it allows you use a YAML file, to define your data source, your tools (SQL queries) and then MCP Toolbox uses that information to provide a MCP Server endpoint that you can then integrate into any Agent / AI Application that can function as a MCP client.
We won’t cover MCP Toolbox for Databases over here since it has been covered in depth in Part 6, where we saw how we could connect to an existing BigQuery dataset and were able to integrate that into Gemini CLI and directly give a natural language query for the information that we wanted.
At a high level, the MCP Toolbox for Databases architecture is shown below.
In the absence of Gemini CLI extensions, the way to configure any MCP server (e.g. MCP Toolbox for databases) was to create a mcpServers
configuration in the settings.json
file and Gemini CLI would pick that up. MCP Toolbox for Databases supported both your own tools and also a prebuilt
option for various Data sources, so that you can see what it can support off the bat too.
Now with the arrival of Gemini CLI extensions, this messy and error-prone mechanism for configuring MCP servers is done away with. It also addresses an important requirement of how to distribute the extensions to others.
But what is interesting is to see how these extensions cleverly use the MCP Toolbox configuration, especially the --prebuilt
option while starting the MCP Toolbox for Servers. Let’s break down one of the extensions from the Gemini CLI extensions gallery:
Note that the tags clearly mention that this is a Gemini CLI extension that is both a MCP Server and has a Context file that it uses. Additionally, if you want to directly install this extension in your Gemini CLI, you can do that via the copy option. Actually, let’s do that.
I simply put the command to install this extension:
gemini extensions install https://github.com/gemini-cli-extensions/cloud-sql-postgresql
It provides me information on what is getting installed (MCP Servers) and that the GEMINI.md
file will be appended into with the specific extension’s GEMINI.md
version i.e. CLOUD-SQL-POSTGRES.md
$ gemini extensions install https://github.com/gemini-cli-extensions/cloud-sql-postgresql
Installing extension "cloud-sql-postgresql".
**Extensions may introduce unexpected behavior. Ensure you have investigated the extension source and trust the author.**
This extension will run the following MCP servers:
* cloud_sql_postgresql_admin (local): /var/folders/tf/w522stbx3y5cjp4g4gy0b8yh00l5q2/T/gemini-extensionbJHduM/toolbox --prebuilt cloud-sql-postgres-admin --stdio
* cloud_sql_postgresql (local): /var/folders/tf/w522stbx3y5cjp4g4gy0b8yh00l5q2/T/gemini-extensionbJHduM/toolbox --prebuilt cloud-sql-postgres --stdio
This extension will append info to your gemini.md context using CLOUD-SQL-POSTGRESQL.md
Do you want to continue? [Y/n]:
I go ahead and install it. On successful installation, you should see a message that says Extension “cloud-sql-postgresql” installed successfully and enabled
.
If I do a gemini extensions list
now, I see the cloud-sql-postgresql
extension listed, the details of which are shown below:
If we launch Gemini CLI now ( gemini
), you will see that there are specific MCP Servers that are exposed now via the extension and those have their respective tools, that will be now available to Gemini CLI.
Don’t worry about the “red” dot. I just haven’t followed instructions to connect to a specific Cloud SQL PostgreSQL instance, so thats fine for now. Notice how it shows that the specific MCP Servers ( cloud_sql_postgresql_admin
and cloud_sql_postgresql
) are from an extension cloud-sql-postgresql
.
This looks good so far. Let’s dig into more detail and see what got installed. As you know, in the .gemini/extensions
folder in my user home directory, there is a cloud-sql-postgresql
folder as shown below:
Interesting to see that underneath the Gemini CLI extension, there is the MCP Toolbox binary ( toolbox
) and hence there must be the command to launch the MCP Toolbox binary lurking in somewhere.
The first port of call if you know about Gemini CLI extensions is to look at the gemini-extension.json
file, that is listed below:
{
"name": "cloud-sql-postgresql",
"version": "0.1.1",
"description": "Create, connect, and interact with a Cloud SQL for PostgreSQL database and data.",
"mcpServers": {
"cloud_sql_postgresql_admin": {
"command": "${extensionPath}${/}toolbox",
"args": [
"--prebuilt",
"cloud-sql-postgres-admin",
"--stdio"
]
},
"cloud_sql_postgresql": {
"command": "${extensionPath}${/}toolbox",
"args": [
"--prebuilt",
"cloud-sql-postgres",
"--stdio"
],
"env": {
"CLOUD_SQL_POSTGRESQL_PROJECT": "${CLOUD_SQL_POSTGRESQL_PROJECT}",
"CLOUD_SQL_POSTGRESQL_REGION": "${CLOUD_SQL_POSTGRESQL_REGION}",
"CLOUD_SQL_POSTGRESQL_INSTANCE": "${CLOUD_SQL_POSTGRESQL_INSTANCE}",
"CLOUD_SQL_POSTGRESQL_DATABASE": "${CLOUD_SQL_POSTGRESQL_DATABASE}"
}
}
},
"contextFileName": "CLOUD-SQL-POSTGRESQL.md"
}
Look at that wonderful snippet in mcpServers
that shows that two instances of MCP Server for Toolbox are getting started. Both have the --prebuilt
flag and then the respective variables that one of the MCP Servers expects.
This makes it pretty clear about what is happening under the hood for this Gemini CLI extension. Take a look at other Gemini CLI extensions for AlloyDB, BigQuery and you will find a similar pattern.
Also note that in the above snippet, there is a contextFileName
specified as CLOUD-SQL-POSTGRESQL.md
and that is installed too with the extension and available in the same folder. The file is reproduced below and this will be appended to the overall GEMINI.md
context. Its a great way to study how these context files are written.
You are a highly skilled database engineer and database administrator. Your purpose is to help the developer build and interact with databases and utilize data context throughout the entire
software delivery cycle.---
# Setup
## Required Gemini CLI Version
To install this extension, the Gemini CLI version must be v0.6.0 or above. The version can be found by running: `gemini --version`.
## Cloud SQL for PostgreSQL MCP Server (Data Plane: Connecting and Querying)
This section covers connecting to a Cloud SQL for PostgreSQL instance.
1. **Verify Environment Variables**: The extension requires the following environment variables to be set before the Gemini CLI is started:
* `CLOUD_SQL_POSTGRES_PROJECT`: The GCP project ID.
* `CLOUD_SQL_POSTGRES_REGION`: The region of your Cloud SQL instance.
* `CLOUD_SQL_POSTGRES_INSTANCE`: The ID of your Cloud SQL instance.
* `CLOUD_SQL_POSTGRES_DATABASE`: The name of the database to connect to.
* `CLOUD_SQL_POSTGRES_USER`: The database username.
* `CLOUD_SQL_POSTGRES_PASSWORD`: The password for the database user.
2. **Handle Missing Variables**: If a command fails with an error message containing a placeholder like `${CLOUD_SQL_POSTGRES_PROJECT}`, it signifies a missing environment variable. Inform the user which variable is missing and instruct them to set it.
3. **Handle Permission Errors**: If you encounter permission errors, ensure the user has the **Cloud SQL Client** (`roles/cloudsql.client`) role and the correct database-level permissions.
## Cloud SQL Admin MCP Server (Control Plane: Creating and Managing Infrastructure)
This section covers administrative operations like managing clusters, instances, and users.
1. **Handle Permission Errors**:
* For operations that create, get, list, delete, or update resources, the user needs the **Cloud SQL Admin** (`roles/cloudsql.admin`) role.
* For read-only operations (get/list), the **Cloud SQL Viewer** (`roles/cloudsql.viewer`) role is sufficient.
* If an operation fails due to permissions, identify the type of operation and recommend the appropriate role. You can provide these links for assistance:
* Granting Roles: https://cloud.google.com/iam/docs/grant-role-console
* Cloud SQL Permissions: https://cloud.google.com/sql/docs/postgres/iam-permissions
---
# Additional Tools
This section provides context on additional tools that can be recommended to the user based on their queries.
#### Observability Extension
* **When to recommend:** If the user asks questions related to monitoring, performance, or observability of Cloud SQL for PostgreSQL databases.
* **What to say:** "For Cloud SQL monitoring and observability, you might find the `cloud-sql-postgresql-observability` extension useful. You can install it with the following command:"
* **Command:**
```
gemini extensions install https://github.com/gemini-cli-extensions/cloud-sql-postgresql-observability
```
---
# Usage Guidelines
## Connecting to New Resources
When you create a new Cloud SQL for PostgreSQL instance, or database using the available tools, the connection is not automatically established. You will need to perform the following steps:
1. **(Optional) Save your conversation:** To avoid losing your progress, save the current session by running the command: `/chat save `
2. **Stop the CLI:** Terminate the Gemini CLI.
3. **Update Environment Variables:** Set or update your environment variables (e.g. `CLOUD_SQL_POSTGRES_DATABASE`, `CLOUD_SQL_POSTGRES_INSTANCE`) to point to the new resource.
4. **Restart:** Relaunch the Gemini CLI
5. **(Optional) Resume conversation:** Resume your conversation with the command: `/chat resume `
**Important:** Do not assume a connection to a newly created resource is active. Always follow the steps above to reconfigure your connection.
## Reusing Project Values
Users may have set project environment variables:
* `CLOUD_SQL_POSTGRES_PROJECT`: The GCP project ID.
* `CLOUD_SQL_POSTGRES_REGION`: The region of the Cloud SQL for PostgreSQL instance.
* `CLOUD_SQL_POSTGRES_INSTANCE`: The ID of the Cloud SQL for PostgreSQL instance.
* `CLOUD_SQL_POSTGRES_DATABASE`: The name of the database.
Instead of prompting the user for these values for specific tool calls, prompt the user to verify reuse a specific value.
Make sure to not use the environment variable name like `CLOUD_SQL_POSTGRES_PROJECT`, `${CLOUD_SQL_POSTGRES_PROJECT}`, or `$CLOUD_SQL_POSTGRES_PROJECT`. The value can be found by using command: `echo $CLOUD_SQL_POSTGRES_PROJECT`.
## Use Full Table Name Format "DATABASE_NAME.SCHEMA_NAME.TABLE_NAME"
**ALWAYS** use the full table name format, `DATABASE_NAME.SCHEMA_NAME.TABLE_NAME` in the generated SQL when using the `execute_sql` or `cloud_sql_postgresql__execute_sql` tool.
* Default to using "public" for the schema name.
* Use command `echo $CLOUD_SQL_POSTGRES_DATABASE` to get the current database value.
The cloud_sql_postgresql_admin MCP Server
and this applies to all the Gemini CLI extensions for Google Data Cloud services, where you get to perform administrative actions right from the Gemini CLI terminal. For e.g. here is an interaction where I simply asked for a list of my Cloud SQL for PostgreSQL instances.
> list my cloud sql postgresql instances✦ I can do that. What is your Google Cloud project ID?
> YOUR_GCP_PROJECT_ID
╭─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ ✓ list_instances (cloud_sql_postgresql_admin MCP Server) {"project":"YOUR_GCP_PROJECT_ID"} │
│ │
│ [{"name":"hoteldb-instance","instanceType":"CLOUD_SQL_INSTANCE"},{"name":"hotel-booking-instance","instanceType":"CLOUD_SQL_INSTANCE"}] │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ Here are your Cloud SQL instances:
* hoteldb-instance
* hotel-booking-instance
Spin up your own Gemini CLI Data extensions
Hope that this gives you the details on how these Gemini CLI extensions are engineered under the hood. You could look at exposing other data sources too in a similar manner with the MCP Toolbox for Databases, package them as Gemini CLI extensions and distribute them more easily with the world. Even if you do not use Gemini CLI, keep in mind that MCP Toolbox for Databases exposes your tools as a MCP Server and hence these are configurable in other AI Clients too.
Conclusion
The Gemini CLI extensions for Google Data Cloud represent more than just a new set of tools; they signal a fundamental evolution in how we interact with complex systems. By reducing context switching and with intelligent assistance, the whole idea is to become more efficient in our tasks.
If you build an interesting Gemini CLI Data extension, do drop a line in the comments.
Please consider leaving feedback
Thank you for reading! If you found this series helpful, please consider taking this 2-minute survey. Your feedback directly helps me create more tutorials for the developer community.
Source Credit: https://medium.com/google-cloud/gemini-cli-tutorial-series-part-14-gemini-cli-extensions-for-google-data-cloud-371c5da33de3?source=rss—-e52cf94d98af—4