|
1 | | -# Gemini CLI Extension - Spanner |
| 1 | +# Spanner Agent Skills |
2 | 2 |
|
3 | 3 | > [!NOTE] |
4 | | -> This extension is currently in beta (pre-v1.0), and may see breaking changes until the first stable release (v1.0). |
| 4 | +> Currently in beta (pre-v1.0), and may see breaking changes until the first stable release (v1.0). |
5 | 5 |
|
6 | | -This Gemini CLI extension provides a set of tools to interact with [Google Cloud Spanner](https://cloud.google.com/spanner/docs) instances. It allows you to manage your databases, execute queries, and explore schemas directly from the [Gemini CLI](https://google-gemini.github.io/gemini-cli/), using natural language prompts. |
| 6 | +This repository provides a set of agent skills to interact with [Google Cloud Spanner](https://cloud.google.com/spanner/docs) instances. These skills can be used with various AI agents, including [Gemini CLI](https://google-gemini.github.io/gemini-cli/), Claude Code, and Codex, to manage your databases, execute queries, explore schemas, and troubleshoot issues using natural language prompts. |
7 | 7 |
|
8 | | -Learn more about [Gemini CLI Extensions](https://github.com/google-gemini/gemini-cli/blob/main/docs/extensions/index.md). |
9 | 8 | > [!IMPORTANT] |
10 | 9 | > **We Want Your Feedback!** |
11 | | -> Please share your thoughts with us by filling out our feedback [form][form]. |
| 10 | +> Please share your thoughts with us by filling out our feedback [form][form]. |
12 | 11 | > Your input is invaluable and helps us improve the project for everyone. |
13 | 12 |
|
14 | 13 | [form]: https://docs.google.com/forms/d/e/1FAIpQLSfEGmLR46iipyNTgwTmIDJqzkAwDPXxbocpXpUbHXydiN1RTw/viewform?usp=pp_url&entry.157487=spanner |
15 | 14 |
|
16 | | -## Why Use the Spanner Extension? |
17 | | - |
18 | | -* **Natural Language Management:** Stop wrestling with complex commands. Explore schemas and query data by describing what you want in plain English. |
19 | | -* **Seamless Workflow:** As a Google-developed extension, it integrates seamlessly into the Gemini CLI environment. No need to constantly switch contexts for common database tasks. |
20 | | -* **Code Generation:** Accelerate development by asking Gemini to generate data classes and other code snippets based on your table schemas. |
21 | | - |
| 15 | +## Table of Contents |
| 16 | + |
| 17 | +- [Why Use Spanner Agent Skills?](#why-use-spanner-agent-skills) |
| 18 | +- [Prerequisites](#prerequisites) |
| 19 | +- [Getting Started](#getting-started) |
| 20 | + - [Configuration](#configuration) |
| 21 | + - [Installation & Usage](#installation--usage) |
| 22 | + - [Gemini CLI](#gemini-cli) |
| 23 | + - [Claude Code](#claude-code) |
| 24 | + - [Codex](#codex) |
| 25 | + - [Antigravity](#antigravity) |
| 26 | +- [Usage Examples](#usage-examples) |
| 27 | +- [Supported Skills](#supported-skills) |
| 28 | +- [Additional Agent Skills](#additional-agent-skills) |
| 29 | +- [Troubleshooting](#troubleshooting) |
| 30 | + |
| 31 | +## Why Use Spanner Agent Skills? |
| 32 | + |
| 33 | +- **Seamless Workflow:** Integrates seamlessly into your AI agent's environment. No need to constantly switch contexts for common database tasks. |
| 34 | +- **Natural Language Queries:** Stop wrestling with complex commands. Explore schemas and query data by describing what you want in plain English. |
| 35 | +- **Full Lifecycle Control:** Manage your Spanner databases, from exploring schemas to running queries. |
| 36 | +- **Code Generation:** Accelerate development by asking your agent to generate data classes and other code snippets based on your table schemas. |
22 | 37 |
|
23 | 38 | ## Prerequisites |
24 | 39 |
|
25 | 40 | Before you begin, ensure you have the following: |
26 | 41 |
|
27 | | -* [Gemini CLI](https://github.com/google-gemini/gemini-cli) installed with version **+v0.6.0**. |
28 | | -* Setup Gemini CLI [Authentication](https://github.com/google-gemini/gemini-cli/tree/main?tab=readme-ov-file#-authentication-options). |
29 | | -* A Google Cloud project with the **Spanner API** enabled. |
30 | | -* Ensure [Application Default Credentials](https://cloud.google.com/docs/authentication/gcloud) are available in your environment. |
31 | | -* IAM Permissions |
32 | | - * Cloud Spanner Database Reader (`roles/spanner.databaseReader`) |
33 | | - * Cloud Spanner Database User (`roles/spanner.databaseUser`) |
| 42 | +- One of these AI agents installed |
| 43 | + - [Gemini CLI](https://github.com/google-gemini/gemini-cli) version **v0.6.0** or higher |
| 44 | + - [Claude Code](https://claude.com/product/claude-code) version **v2.1.94** or higher |
| 45 | + - [Codex](https://developers.openai.com/codex) **v0.117.0** or higher |
| 46 | + - [Antigravity](https://antigravity.google) **v1.14.2** or higher |
| 47 | +- A Google Cloud project with the **Spanner API** enabled. |
| 48 | +- Ensure [Application Default Credentials](https://cloud.google.com/docs/authentication/gcloud) are available in your environment. |
| 49 | +- IAM Permissions: |
| 50 | + - Cloud Spanner Database Reader (`roles/spanner.databaseReader`) |
| 51 | + - Cloud Spanner Database User (`roles/spanner.databaseUser`) |
34 | 52 |
|
35 | 53 | ## Getting Started |
36 | 54 |
|
37 | | -### Installation |
| 55 | +### Configuration |
38 | 56 |
|
39 | | -To install the extension, use the command: |
| 57 | +Please keep these env vars handy during the installation process: |
40 | 58 |
|
41 | | -```bash |
42 | | -gemini extensions install https://github.com/gemini-cli-extensions/spanner |
43 | | -``` |
| 59 | +- `SPANNER_PROJECT`: The GCP project ID. |
| 60 | +- `SPANNER_INSTANCE`: The Spanner instance ID. |
| 61 | +- `SPANNER_DATABASE`: The Spanner database ID. |
| 62 | +- `SPANNER_DIALECT`: (Optional) The SQL dialect of the Spanner Database: 'googlesql' or 'postgresql'. Defaults to "googlesql". |
44 | 63 |
|
45 | | -### Configuration |
| 64 | +> [!NOTE] |
| 65 | +> |
| 66 | +> - Ensure [Application Default Credentials](https://cloud.google.com/docs/authentication/gcloud) are available in your environment. |
46 | 67 |
|
47 | | -You will be prompted to configure the following settings during installation. These settings are saved in an `.env` file within the extension's directory. |
| 68 | +### Installation & Usage |
48 | 69 |
|
49 | | -* `SPANNER_PROJECT`: The GCP project ID. |
50 | | -* `SPANNER_INSTANCE`: The Spanner instance ID. |
51 | | -* `SPANNER_DATABASE`: The Spanner database ID. |
52 | | -* `SPANNER_DIALECT`: (Optional) The SQL dialect of the Spanner database: 'googlesql' or 'postgresql'. Defaults to "googlesql". |
| 70 | +To start interacting with your database, install the skills for your preferred AI agent, then launch the agent and use natural language to ask questions or perform tasks. |
53 | 71 |
|
54 | | -To view or update your configuration: |
| 72 | +For the latest version, check the [releases page][releases]. |
55 | 73 |
|
56 | | -**List Settings:** |
57 | | -* Terminal: `gemini extensions list` |
58 | | -* Gemini CLI: `/extensions list` |
| 74 | +[releases]: https://github.com/gemini-cli-extensions/spanner/releases |
59 | 75 |
|
60 | | -**Update Settings:** |
61 | | -* Terminal: `gemini extensions config spanner [setting name] [--scope <scope>]` |
62 | | - * `setting name`: (Optional) The single setting to configure. |
63 | | - * `scope`: (Optional) The scope of the setting in (`user` or `workspace`). Defaults to `user`. |
64 | | -* Currently, you must restart the Gemini CLI for changes to take effect. We recommend using `gemini --resume` to resume your session. |
| 76 | +<!-- {x-release-please-start-version} --> |
65 | 77 |
|
66 | | -Alternatively, you can manually set these environment variables before starting the Gemini CLI: |
| 78 | +<details open> |
| 79 | +<summary id="gemini-cli">Gemini CLI</summary> |
| 80 | + |
| 81 | +**1. Install the extension:** |
67 | 82 |
|
68 | 83 | ```bash |
69 | | -export SPANNER_PROJECT="<your-gcp-project-id>" |
70 | | -export SPANNER_INSTANCE="<your-spanner-instance-id>" |
71 | | -export SPANNER_DATABASE="<your-spanner-database-id>" |
72 | | -export SPANNER_DIALECT="googlesql" # Optional: "googlesql" or "postgresql". Defaults to "googlesql". |
| 84 | +gemini extensions install https://github.com/gemini-cli-extensions/spanner |
73 | 85 | ``` |
74 | 86 |
|
75 | | -> [!NOTE] |
76 | | -> * Ensure [Application Default Credentials](https://cloud.google.com/docs/authentication/gcloud) are available in your environment. |
77 | | -> * See [Troubleshooting](#troubleshooting) for debugging your configuration. |
| 87 | +During the installation, enter your environment vars as described in the [configuration section](#configuration). |
| 88 | + |
| 89 | +**2. (Optional) Manage Configuration:** |
| 90 | +To view or update your configuration in Gemini CLI: |
78 | 91 |
|
79 | | -### Start Gemini CLI |
| 92 | +- Terminal: `gemini extensions config spanner [setting name] [--scope <scope>]` |
| 93 | +- Gemini CLI: `/extensions list` |
80 | 94 |
|
81 | | -To start the Gemini CLI, use the following command: |
| 95 | +**3. Start the agent:** |
82 | 96 |
|
83 | 97 | ```bash |
84 | 98 | gemini |
85 | 99 | ``` |
86 | 100 |
|
| 101 | +_(Tip: Run `/extensions list` to verify your configuration and active extensions.)_ |
| 102 | + |
87 | 103 | > [!WARNING] |
88 | 104 | > **Changing Instance & Database Connections** |
89 | | -> Currently, the database connection must be configured before starting the Gemini CLI and can not be changed during a session. |
90 | | -> To save and resume conversation history use command: `/chat save <tag>` and `/chat resume <tag>`. |
| 105 | +> Currently, the database connection must be configured before starting the agent and can not be changed during a session. |
| 106 | +> To save and resume conversation history in Gemini CLI use command: `/chat save <tag>` and `/chat resume <tag>`. |
| 107 | +
|
| 108 | +</details> |
| 109 | + |
| 110 | +<details> |
| 111 | +<summary id="claude-code">Claude Code</summary> |
| 112 | + |
| 113 | +**1. Set env vars:** |
| 114 | +In your terminal, set your environment vars as described in the [configuration section](#configuration). |
| 115 | + |
| 116 | +**2. Start the agent:** |
| 117 | + |
| 118 | +```bash |
| 119 | +claude |
| 120 | +``` |
| 121 | + |
| 122 | +**3. Add the marketplace:** |
| 123 | + |
| 124 | +```bash |
| 125 | +/plugin marketplace add https://github.com/gemini-cli-extensions/spanner.git#0.2.6 |
| 126 | +``` |
| 127 | + |
| 128 | +**4. Install the plugin:** |
| 129 | + |
| 130 | +```bash |
| 131 | +/plugin install spanner@spanner-marketplace |
| 132 | +``` |
| 133 | + |
| 134 | +_(Tip: Run `/plugin list` inside Claude Code to verify the plugin is active, or `/reload-plugins` if you just installed it.)_ |
| 135 | + |
| 136 | +</details> |
| 137 | + |
| 138 | +<details> |
| 139 | +<summary id="codex">Codex</summary> |
| 140 | + |
| 141 | +**1. Clone the Repo:** |
| 142 | + |
| 143 | +```bash |
| 144 | +git clone --branch 0.2.6 git@github.com:gemini-cli-extensions/spanner.git |
| 145 | +``` |
| 146 | + |
| 147 | +**2. Install the plugin:** |
| 148 | + |
| 149 | +```bash |
| 150 | +mkdir -p ~/.codex/plugins |
| 151 | +cp -R /absolute/path/to/spanner ~/.codex/plugins/spanner |
| 152 | +``` |
| 153 | + |
| 154 | +**3. Set env vars:** |
| 155 | +Enter your environment vars as described in the [configuration section](#configuration). |
| 156 | + |
| 157 | +**4. Create or update marketplace.json:** |
| 158 | +`~/.agents/plugins/marketplace.json` |
| 159 | + |
| 160 | +```json |
| 161 | +{ |
| 162 | + "name": "my-data-cloud-google-marketplace", |
| 163 | + "interface": { |
| 164 | + "displayName": "Google Data Cloud Skills" |
| 165 | + }, |
| 166 | + "plugins": [ |
| 167 | + { |
| 168 | + "name": "spanner", |
| 169 | + "source": { |
| 170 | + "source": "local", |
| 171 | + "path": "./plugins/spanner" |
| 172 | + }, |
| 173 | + "policy": { |
| 174 | + "installation": "AVAILABLE", |
| 175 | + "authentication": "ON_INSTALL" |
| 176 | + }, |
| 177 | + "category": "Database" |
| 178 | + } |
| 179 | + ] |
| 180 | +} |
| 181 | +``` |
| 182 | + |
| 183 | +_(Tip: Run `codex plugin list` or use the `/plugins` interactive menu to verify your installed plugins.)_ |
| 184 | + |
| 185 | +</details> |
| 186 | + |
| 187 | +<details> |
| 188 | +<summary id="antigravity">Antigravity</summary> |
| 189 | + |
| 190 | +**1. Clone the Repo:** |
| 191 | + |
| 192 | +```bash |
| 193 | +git clone --branch 0.2.6 https://github.com/gemini-cli-extensions/spanner.git |
| 194 | +``` |
| 195 | + |
| 196 | +**2. Install the skills:** |
| 197 | + |
| 198 | +Choose a location for the skills: |
| 199 | +- **Global (all workspaces):** `~/.gemini/antigravity/skills/` |
| 200 | +- **Workspace-specific:** `<workspace-root>/.agents/skills/` |
| 201 | + |
| 202 | +Copy the skill folders from the cloned repository's `skills/` directory to your chosen location: |
| 203 | + |
| 204 | +```bash |
| 205 | +cp -R spanner/skills/* ~/.gemini/antigravity/skills/ |
| 206 | +``` |
| 207 | + |
| 208 | +**3. Set env vars:** |
| 209 | +Set your environment vars as described in the [configuration section](#configuration). |
| 210 | + |
| 211 | +_(Tip: Antigravity automatically discovers skills in these directories at the start of a session.)_ |
| 212 | + |
| 213 | +</details> |
| 214 | + |
| 215 | +<!-- {x-release-please-end} --> |
| 216 | + |
| 217 | +## Usage Examples |
| 218 | + |
| 219 | +Interact with Spanner using natural language: |
91 | 220 |
|
92 | | -## Usage |
| 221 | +- **Explore Schemas and Data:** |
| 222 | + - "Show me all tables in the 'orders' database." |
| 223 | + - "What are the columns in the 'products' table?" |
| 224 | + - "How many orders were placed in the last 30 days, and what were the top 5 most purchased items?" |
| 225 | +- **Generate Code:** |
| 226 | + - "Generate a Python dataclass to represent the 'customers' table." |
93 | 227 |
|
94 | | -* **Explore Schemas and Data:** |
95 | | - * "Show me all tables in the 'orders' database." |
96 | | - * "What are the columns in the 'products' table?" |
97 | | - * "How many orders were placed in the last 30 days, and what were the top 5 most purchased items?" |
| 228 | +## Supported Skills |
98 | 229 |
|
99 | | -* **Generate Code:** |
100 | | - * "Generate a Python dataclass to represent the 'customers' tab |
| 230 | +The following skills are available in this repository: |
101 | 231 |
|
102 | | -## Supported Tools |
| 232 | +- [Spanner Data](./skills/spanner-data/SKILL.md) - Use these skills when you need to explore the database structure, discover schema objects like tables and graphs, and execute custom SQL queries to interact with your data. |
103 | 233 |
|
104 | | -* `list_tables`: Use this tool to list tables and descriptions. |
105 | | -* `list_graphs`: Use this tool to lists graphs in the database. |
106 | | -* `execute_sql`: Use this tool to execute any SQL statement. |
107 | | -* `execute_sql_dql`: Use this tool to execute DQL SQL statement. |
| 234 | +## Additional Agent Skills |
108 | 235 |
|
109 | | -## Additional Extensions |
| 236 | +Find additional skills to support your entire software development lifecycle at [github.com/gemini-cli-extensions](https://github.com/gemini-cli-extensions), including: |
110 | 237 |
|
111 | | -Find additional extensions to support your entire software development lifecycle at [github.com/gemini-cli-extensions](https://github.com/gemini-cli-extensions). |
| 238 | +- [Generic PostgreSQL skills](https://github.com/gemini-cli-extensions/postgres) |
| 239 | +- [Cloud SQL for PostgreSQL skills](https://github.com/gemini-cli-extensions/cloud-sql-postgresql) |
| 240 | +- and more! |
112 | 241 |
|
113 | 242 | ## Troubleshooting |
114 | 243 |
|
115 | | -Use `gemini --debug` to enable debugging. |
| 244 | +Use the debug mode of your agent (e.g., `gemini --debug`) to enable debugging. |
116 | 245 |
|
117 | 246 | Common issues: |
118 | 247 |
|
119 | | -* "failed to find default credentials: google: could not find default credentials.": Ensure [Application Default Credentials](https://cloud.google.com/docs/authentication/gcloud) are available in your environment. See [Set up Application Default Credentials](https://cloud.google.com/docs/authentication/external/set-up-adc) for more information. |
120 | | -* "✖ 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. |
121 | | -* "✖ 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+. |
122 | | -* "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://mcp-toolbox.dev/documentation/introduction/#install-toolbox) for more information. |
| 248 | +- "failed to find default credentials: google: could not find default credentials.": Ensure [Application Default Credentials](https://cloud.google.com/docs/authentication/gcloud) are available in your environment. See [Set up Application Default Credentials](https://cloud.google.com/docs/authentication/external/set-up-adc) for more information. |
| 249 | +- "✖ 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. |
| 250 | +- "✖ MCP ERROR: Error: spawn .../toolbox ENOENT": The Toolbox binary did not download correctly. Ensure you are using the latest version of your agent. |
| 251 | +- "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://mcp-toolbox.dev/documentation/introduction/#install-toolbox) for more information. |
0 commit comments