Skip to content

Commit cee26c1

Browse files
authored
Merge branch 'main' into pr-title-lint
2 parents bb25800 + bf9f6c1 commit cee26c1

13 files changed

+259
-27
lines changed

.github/renovate.json5

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
extends: [
3+
'config:recommended',
4+
':semanticCommitTypeAll(chore)',
5+
':ignoreUnstable',
6+
':separateMajorReleases',
7+
':prConcurrentLimitNone',
8+
':prHourlyLimitNone',
9+
':preserveSemverRanges',
10+
],
11+
rebaseWhen: 'conflicted',
12+
dependencyDashboardLabels: [
13+
'type: process',
14+
],
15+
packageRules: [
16+
{
17+
groupName: 'GitHub Actions',
18+
matchManagers: [
19+
'github-actions',
20+
],
21+
pinDigests: true,
22+
},
23+
],
24+
customManagers: [
25+
{
26+
customType: "regex",
27+
managerFilePatterns: ["/toolbox_version\\.txt$/"],
28+
matchStrings: ["(?<currentValue>[\\d\\.]+)"],
29+
datasourceTemplate: "github-releases",
30+
packageNameTemplate: "googleapis/genai-toolbox",
31+
extractVersionTemplate: "^v(?<version>.*)$",
32+
}
33+
]
34+
}

.github/workflows/json-lint.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Lint JSON
16+
17+
on:
18+
pull_request:
19+
branches: [ main ]
20+
21+
jobs:
22+
json-lint:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Check out code
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
27+
28+
- name: Run JSON Lint
29+
run: jq . gemini-extension.json
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
name: Lint Markdown
16+
17+
on:
18+
pull_request:
19+
branches: [ main ]
20+
21+
jobs:
22+
link-check:
23+
name: Run link check
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Check out code
27+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
28+
29+
- name: Link Checker
30+
uses: lycheeverse/lychee-action@885c65f3dc543b57c898c8099f4e08c8afd178a2 # v2.6.1
31+
with:
32+
# There is no security token. So, it would fail on any links which aren't public.
33+
args: "--verbose --no-progress **/*.md"

.github/workflows/package-and-upload-assets.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939

4040
steps:
4141
- name: Checkout code at the new tag
42-
uses: actions/checkout@v4
42+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
4343
with:
4444
ref: ${{ github.event.release.tag_name }}
4545

@@ -102,7 +102,7 @@ jobs:
102102
echo "ARCHIVE_PATH=${ARCHIVE_NAME}" >> $GITHUB_OUTPUT
103103
104104
- name: Upload archive as workflow artifact
105-
uses: actions/upload-artifact@v4
105+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
106106
with:
107107
name: ${{ steps.vars.outputs.archive_name }}
108108
path: ${{ steps.create_archive.outputs.ARCHIVE_PATH }}
@@ -116,10 +116,10 @@ jobs:
116116
contents: write
117117
steps:
118118
- name: Checkout code
119-
uses: actions/checkout@v4
119+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
120120

121121
- name: Download all archives from workflow artifacts
122-
uses: actions/download-artifact@v4
122+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
123123
with:
124124
path: release-archives
125125

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Copyright 2025 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# https://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
name: Presubmit Tests
15+
16+
on:
17+
pull_request:
18+
branches: [ main ]
19+
20+
jobs:
21+
run-presubmit-tests:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- name: Check out code
25+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
26+
27+
- name: Install Gemini CLI
28+
run: npm install @google/gemini-cli
29+
30+
- name: Install toolbox binary
31+
run: |
32+
VERSION=$(cat toolbox_version.txt)
33+
curl -L -o toolbox https://storage.googleapis.com/genai-toolbox/v$VERSION/linux/amd64/toolbox
34+
chmod +x toolbox
35+
36+
- name: Install Extension
37+
run: yes | npx gemini extensions install --path=.

.lycheeignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
https://github.com/gemini-cli-extensions/cloud-sql-postgresql/compare/

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "0.1.0"
2+
".": "0.1.1"
33
}

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## [0.1.1](https://github.com/gemini-cli-extensions/cloud-sql-postgresql/compare/0.1.0...0.1.1) (2025-09-30)
4+
5+
6+
### Features
7+
8+
* additional instructions for the context file ([#30](https://github.com/gemini-cli-extensions/cloud-sql-postgresql/issues/30)) ([9c87df1](https://github.com/gemini-cli-extensions/cloud-sql-postgresql/commit/9c87df1f1959686bf1efa863f463fa4e39882fe2))
9+
* standardize mcp server names ([#27](https://github.com/gemini-cli-extensions/cloud-sql-postgresql/issues/27)) ([eeeaf81](https://github.com/gemini-cli-extensions/cloud-sql-postgresql/commit/eeeaf813b802491e183a21fbfa23b2f684bda032))
10+
* update context file to recommend observability extension ([#17](https://github.com/gemini-cli-extensions/cloud-sql-postgresql/issues/17)) ([f4f7069](https://github.com/gemini-cli-extensions/cloud-sql-postgresql/commit/f4f7069a41dabfb995bf1728ed4e0a710cc0425e))
11+
* update context file to use full table name ([#31](https://github.com/gemini-cli-extensions/cloud-sql-postgresql/issues/31)) ([533a2f3](https://github.com/gemini-cli-extensions/cloud-sql-postgresql/commit/533a2f388fbf5b21484da904e46247d10cc43746))
12+
13+
314
## 0.1.0 (2025-09-20)
415

516

CLOUD-SQL-POSTGRESQL.md

Lines changed: 56 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,14 @@
11
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
22
software delivery cycle.
33

4-
--
4+
---
55

66
# Setup
77

8+
## Required Gemini CLI Version
9+
10+
To install this extension, the Gemini CLI version must be v0.6.0 or above. The version can be found by running: `gemini --version`.
11+
812
## Cloud SQL for PostgreSQL MCP Server (Data Plane: Connecting and Querying)
913

1014
This section covers connecting to a Cloud SQL for PostgreSQL instance.
@@ -30,5 +34,54 @@ This section covers administrative operations like managing clusters, instances,
3034
* For operations that create, get, list, delete, or update resources, the user needs the **Cloud SQL Admin** (`roles/cloudsql.admin`) role.
3135
* For read-only operations (get/list), the **Cloud SQL Viewer** (`roles/cloudsql.viewer`) role is sufficient.
3236
* If an operation fails due to permissions, identify the type of operation and recommend the appropriate role. You can provide these links for assistance:
33-
* Granting Roles: <https://cloud.google.com/iam/docs/grant-role-console>
34-
* Cloud SQL Permissions: <https://cloud.google.com/sql/docs/postgres/iam-permissions>
37+
* Granting Roles: https://cloud.google.com/iam/docs/grant-role-console
38+
* Cloud SQL Permissions: https://cloud.google.com/sql/docs/postgres/iam-permissions
39+
40+
---
41+
42+
# Additional Tools
43+
44+
This section provides context on additional tools that can be recommended to the user based on their queries.
45+
46+
#### Observability Extension
47+
48+
* **When to recommend:** If the user asks questions related to monitoring, performance, or observability of Cloud SQL for PostgreSQL databases.
49+
* **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:"
50+
* **Command:**
51+
```
52+
gemini extensions install https://github.com/gemini-cli-extensions/cloud-sql-postgresql-observability
53+
```
54+
55+
---
56+
57+
# Usage Guidelines
58+
59+
## Connecting to New Resources
60+
61+
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:
62+
63+
1. **(Optional) Save your conversation:** To avoid losing your progress, save the current session by running the command: `/chat save <your-tag>`
64+
2. **Stop the CLI:** Terminate the Gemini CLI.
65+
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.
66+
4. **Restart:** Relaunch the Gemini CLI
67+
5. **(Optional) Resume conversation:** Resume your conversation with the command: `/chat resume <your-tag>`
68+
69+
**Important:** Do not assume a connection to a newly created resource is active. Always follow the steps above to reconfigure your connection.
70+
71+
## Reusing Project Values
72+
73+
Users may have set project environment variables:
74+
75+
* `CLOUD_SQL_POSTGRES_PROJECT`: The GCP project ID.
76+
* `CLOUD_SQL_POSTGRES_REGION`: The region of the Cloud SQL for PostgreSQL instance.
77+
* `CLOUD_SQL_POSTGRES_INSTANCE`: The ID of the Cloud SQL for PostgreSQL instance.
78+
* `CLOUD_SQL_POSTGRES_DATABASE`: The name of the database.
79+
80+
Instead of prompting the user for these values for specific tool calls, prompt the user to verify reuse a specific value.
81+
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`.
82+
83+
## Use Full Table Name Format "DATABASE_NAME.SCHEMA_NAME.TABLE_NAME"
84+
85+
**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.
86+
* Default to using "public" for the schema name.
87+
* Use command `echo $CLOUD_SQL_POSTGRES_DATABASE` to get the current database value.

README.md

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
66
This Gemini CLI extension provides a set of tools to interact with [Cloud SQL for PostgreSQL](https://cloud.google.com/sql/docs/postgres) instances. It allows you to manage your databases, execute queries, explore schemas, and troubleshoot issues directly from the [Gemini CLI](https://google-gemini.github.io/gemini-cli/), using natural language prompts.
77

8-
Learn more about [Gemini CLI Extensions](https://github.com/google-gemini/gemini-cli/blob/main/docs/extension.md).
8+
Learn more about [Gemini CLI Extensions](https://github.com/google-gemini/gemini-cli/blob/main/docs/extensions/index.md).
99

1010
## Why Use the Cloud SQL for PostgreSQL Extension?
1111

@@ -24,15 +24,17 @@ Before you begin, ensure you have the following:
2424
* Cloud SQL Client (`roles/cloudsql.client`)
2525
* Cloud SQL Admin (`roles/cloudsql.admin`)
2626

27-
## Installation
27+
## Getting Started
28+
29+
### Installation
2830

2931
To install the extension, use the command:
3032

3133
```bash
3234
gemini extensions install https://github.com/gemini-cli-extensions/cloud-sql-postgresql
3335
```
3436

35-
## Configuration
37+
### Configuration
3638

3739
Set the following environment variables before starting the Gemini CLI.
3840
This configuration is not required if utilizing the [Admin toolset](#supported-tools).
@@ -48,13 +50,26 @@ This configuration is not required if utilizing the [Admin toolset](#supported-t
4850
Ensure [Application Default Credentials](https://cloud.google.com/docs/authentication/gcloud) are available in your environment.
4951

5052
> [!NOTE]
51-
> When using private IPs with Cloud SQL for PostgreSQL, you must use a Virtual Private Cloud (VPC) network.
53+
> If your Cloud SQL for PostgreSQL instance uses private IPs, you must run Gemini CLI in the same Virtual Private Cloud (VPC) network.
54+
55+
### Start Gemini CLI
56+
57+
To start the Gemini CLI, use the following command:
58+
59+
```bash
60+
gemini
61+
```
62+
63+
> [!WARNING]
64+
> **Changing Instance & Database Connections**
65+
> Currently, the database connection must be configured before starting the Gemini CLI and can not be changed during a session.
66+
> To save and resume conversation history use command: `/chat save <tag>` and `/chat resume <tag>`.
5267
5368
## Usage Examples
5469

5570
Interact with Cloud SQL for PostgreSQL using natural language:
5671

57-
* **Provision Infrastructure:**
72+
* **Provision Infrastructure:**
5873
* "Create a new CLoud SQL for Postgres instance named 'e-commerce-prod' in the 'my-gcp-project' project."
5974
* "Create a new user named 'analyst' with read access to all tables."
6075
* **Explore Schemas and Data:**
@@ -69,10 +84,10 @@ Interact with Cloud SQL for PostgreSQL using natural language:
6984
* **Admin:**
7085
* `create_instance`: Use this tool to create an Postgres instance.
7186
* `create_user`: Use this tool to create Postgres-BUILT-IN or IAM-based users.
87+
* `create_database`: Creates a new database in a Cloud SQL instance.
7288
* `get_instance`: Use this tool to get details about an Postgres instance.
73-
* `get_user`: Use this tool to get details about a user.
7489
* `list_instances`: Use this tool to list instances in a given project and location.
75-
* `list_users`: Use this tool to list users in a given project and location.
90+
* `list_databases`: Lists all databases for a Cloud SQL instance.
7691
* `wait_for_operation`: Use this tool to poll the operations API until the operation is done.
7792

7893
* **Data:**
@@ -90,8 +105,13 @@ Interact with Cloud SQL for PostgreSQL using natural language:
90105

91106
## Additional Extensions
92107

93-
Find additional extensions to support your entire software development lifecycle at [github.com/gemini-cli-extensions](https://github.com/gemini-cli-extensions), including a generic [PostgreSQL extension](https://github.com/gemini-cli-extensions/postgres).
108+
Find additional extensions to support your entire software development lifecycle at [github.com/gemini-cli-extensions](https://github.com/gemini-cli-extensions), including:
109+
* [Generic PostgreSQL extension](https://github.com/gemini-cli-extensions/postgres)
110+
* [Cloud SQL for PostgreSQL Observability extension](https://github.com/gemini-cli-extensions/cloud-sql-postgresql-observability)
111+
* and more!
94112

95113
## Troubleshooting
96114

97-
* "cannot execute binary file": Ensure the correct binary for your OS/Architecture has been downloaded. See [Installing the server](https://googleapis.github.io/genai-toolbox/getting-started/introduction/#installing-the-server) for more information.
115+
* "✖ Error during discovery for server: MCP error -32000: Connection closed": The database connection has not been established. Ensure your configuration is set via environment variables.
116+
* "✖ MCP ERROR: Error: spawn /Users/<USER>/.gemini/extensions/cloud-sql-postgresql/toolbox ENOENT": The Toolbox binary did not download correctly. Ensure you are using Gemini CLI v0.6.0+.
117+
* "cannot execute binary file": The Toolbox binary did not download correctly. Ensure the correct binary for your OS/Architecture has been downloaded. See [Installing the server](https://googleapis.github.io/genai-toolbox/getting-started/introduction/#installing-the-server) for more information.

0 commit comments

Comments
 (0)