You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* 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))
Copy file name to clipboardExpand all lines: CLOUD-SQL-POSTGRESQL.md
+40-2Lines changed: 40 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,10 +1,14 @@
1
1
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
2
2
software delivery cycle.
3
3
4
-
--
4
+
---
5
5
6
6
# Setup
7
7
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
+
8
12
## Cloud SQL for PostgreSQL MCP Server (Data Plane: Connecting and Querying)
9
13
10
14
This section covers connecting to a Cloud SQL for PostgreSQL instance.
@@ -41,9 +45,43 @@ This section provides context on additional tools that can be recommended to the
41
45
42
46
#### Observability Extension
43
47
44
-
***When to recommend:** If the user asks questions related to monitoring, performance, or observability of AlloyDB databases.
48
+
***When to recommend:** If the user asks questions related to monitoring, performance, or observability of Cloud SQL for PostgreSQL databases.
45
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:"
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.
Set the following environment variables before starting the Gemini CLI.
38
40
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
48
50
Ensure [Application Default Credentials](https://cloud.google.com/docs/authentication/gcloud) are available in your environment.
49
51
50
52
> [!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>`.
52
67
53
68
## Usage Examples
54
69
55
70
Interact with Cloud SQL for PostgreSQL using natural language:
56
71
57
-
***Provision Infrastructure:**
72
+
***Provision Infrastructure:**
58
73
* "Create a new CLoud SQL for Postgres instance named 'e-commerce-prod' in the 'my-gcp-project' project."
59
74
* "Create a new user named 'analyst' with read access to all tables."
60
75
***Explore Schemas and Data:**
@@ -69,10 +84,10 @@ Interact with Cloud SQL for PostgreSQL using natural language:
69
84
***Admin:**
70
85
* `create_instance`: Use this tool to create an Postgres instance.
71
86
* `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.
72
88
* `get_instance`: Use this tool to get details about an Postgres instance.
73
-
* `get_user`: Use this tool to get details about a user.
74
89
* `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.
76
91
* `wait_for_operation`: Use this tool to poll the operations API until the operation is done.
77
92
78
93
***Data:**
@@ -90,8 +105,13 @@ Interact with Cloud SQL for PostgreSQL using natural language:
90
105
91
106
## Additional Extensions
92
107
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:
*[Cloud SQL for PostgreSQL Observability extension](https://github.com/gemini-cli-extensions/cloud-sql-postgresql-observability)
111
+
* and more!
94
112
95
113
## Troubleshooting
96
114
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