Skip to content

Commit d25785c

Browse files
authored
Merge branch 'main' into ci-updates
2 parents 6b689f7 + 755dfab commit d25785c

8 files changed

Lines changed: 98 additions & 13 deletions

File tree

.github/workflows/json-lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
runs-on: ubuntu-latest
2424
steps:
2525
- name: Check out code
26-
uses: actions/checkout@v4
26+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
2727

2828
- name: Run JSON Lint
2929
run: jq . gemini-extension.json

.github/workflows/markdown-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ jobs:
2424
runs-on: ubuntu-latest
2525
steps:
2626
- name: Check out code
27-
uses: actions/checkout@v4
27+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
2828

2929
- name: Link Checker
30-
uses: lycheeverse/lychee-action@v2.0.2
30+
uses: lycheeverse/lychee-action@885c65f3dc543b57c898c8099f4e08c8afd178a2 # v2.6.1
3131
with:
3232
# There is no security token. So, it would fail on any links which aren't public.
3333
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=.

README.md

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,17 @@ Before you begin, ensure you have the following:
2323
* Cloud Spanner Database Reader (`roles/spanner.databaseReader`)
2424
* Cloud Spanner Database User (`roles/spanner.databaseUser`)
2525

26-
## Installation
26+
## Getting Started
27+
28+
### Installation
2729

2830
To install the extension, use the command:
2931

3032
```bash
3133
gemini extensions install https://github.com/gemini-cli-extensions/spanner
3234
```
3335

34-
## Configuration
36+
### Configuration
3537

3638
Set the following environment variables before starting the Gemini CLI:
3739

@@ -42,6 +44,19 @@ Set the following environment variables before starting the Gemini CLI:
4244

4345
Ensure [Application Default Credentials](https://cloud.google.com/docs/authentication/gcloud) are available in your environment.
4446

47+
### Start Gemini CLI
48+
49+
To start the Gemini CLI, use the following command:
50+
51+
```bash
52+
gemini
53+
```
54+
55+
> [!WARNING]
56+
> **Changing Instance & Database Connections**
57+
> Currently, the database connection must be configured before starting the Gemini CLI and can not be changed during a session.
58+
> To save and resume conversation history use command: `/chat save <tag>` and `/chat resume <tag>`.
59+
4560
## Usage
4661

4762
* **Explore Schemas and Data:**
@@ -64,4 +79,6 @@ Find additional extensions to support your entire software development lifecycle
6479

6580
## Troubleshooting
6681

67-
* "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.
82+
* "✖ 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.
83+
* "✖ MCP ERROR: Error: spawn /Users/<USER>/.gemini/extensions/spanner/toolbox ENOENT": The Toolbox binary did not download correctly. Ensure you are using Gemini CLI v0.6.0+.
84+
* "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.

SPANNER.md

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ software delivery cycle.
44

55
--
66

7+
# Setup
8+
9+
## Required Gemini CLI Version
10+
11+
To install this extension, the Gemini CLI version must be v0.6.0 or above. The version can be found by running: `gemini --version`.
712

813
## Spanner MCP Server (Data Plane: Connecting and Querying)
914

@@ -14,11 +19,37 @@ This section covers connecting to a Spanner instance.
1419
* `SPANNER_PROJECT`: The GCP project ID.
1520
* `SPANNER_INSTANCE`: The Spanner instance ID.
1621
* `SPANNER_DATABASE`: The Spanner database ID.
17-
* `SPANNER_DIALECT`: The Spanner database dialect e.g. "googlesql" or "postgresql"
22+
* `SPANNER_DIALECT`: The Spanner database dialect e.g. "googlesql" or "postgresql"
1823

1924
2. **Handle Missing Variables**: If a command fails with an error message containing a placeholder like `${SPANNER_PROJECT}`, it signifies a missing environment variable. Inform the user which variable is missing and instruct them to set it.
2025

2126
3. **Handle Permission Errors**: If you encounter permission errors, ensure the user has the correct Spanner permissions (e.g., `spanner.databases.get`, `spanner.databases.select`). The user likely lacks the role **Cloud Spanner Database User**
2227
(`roles/spanner.databaseUser`) or **Cloud Spanner Database Reader** (`roles/spanner.databaseReader`). You can provide these links for assistance:
2328
* Granting Roles: https://cloud.google.com/iam/docs/grant-role-console
2429
* Spanner Permissions: https://cloud.google.com/iam/docs/roles-permissions/spanner
30+
31+
---
32+
33+
# Usage Guidelines
34+
35+
## Connecting to New Resources
36+
37+
You will need to perform the following steps to change the current database connection:
38+
39+
1. **(Optional) Save your conversation:** To avoid losing your progress, save the current session by running the command: `/chat save <your-tag>`
40+
2. **Stop the CLI:** Terminate the Gemini CLI.
41+
3. **Update Environment Variables:** Set or update your environment variables (e.g. `SPANNER_INSTANCE`, `SPANNER_DATABASE`) to point to the new resource.
42+
4. **Restart:** Relaunch the Gemini CLI
43+
5. **(Optional) Resume conversation:** Resume your conversation with the command: `/chat resume <your-tag>`
44+
45+
## Reusing Project Values
46+
47+
Users may have set project environment variables:
48+
49+
* `SPANNER_PROJECT`: The GCP project ID.
50+
* `SPANNER_INSTANCE`: The Spanner instance ID.
51+
* `SPANNER_DATABASE`: The Spanner database ID.
52+
* `SPANNER_DIALECT`: The Spanner database dialect e.g. "googlesql" or "postgresql"
53+
54+
Instead of prompting the user for these values for specific tool calls, prompt the user to verify reuse a specific value.
55+
Make sure to not use the environment variable name like `SPANNER_PROJECT`, `${SPANNER_PROJECT}`, or `$SPANNER_PROJECT`. The value can be found by using command: `echo $SPANNER_PROJECT`.

gemini-extension.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.1.0",
44
"description": "Connect and interact with Spanner data using natural language.",
55
"mcpServers": {
6-
"Spanner": {
6+
"spanner": {
77
"command": "${extensionPath}${/}toolbox",
88
"args": [
99
"--prebuilt",

toolbox_version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0.15.0
1+
0.16.0

0 commit comments

Comments
 (0)