Skip to content

Commit f2abcd6

Browse files
fix: Update local tools file and connection parameters (#6)
* Fix local tools file and connection parameters * Add all connection methods * Add env vars in gemini-extension.json * ci: add env var before extension installation (#7) --------- Co-authored-by: Matt Cornillon <cornillon@google.com> Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
1 parent f786135 commit f2abcd6

3 files changed

Lines changed: 214 additions & 115 deletions

File tree

README.md

Lines changed: 45 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,55 @@ gemini extensions install https://github.com/gemini-cli-extensions/oracledb
3939
### Configuration
4040

4141
Set the following environment variables before starting the Gemini CLI. These variables can be loaded from a `.env` file.
42-
4342
```bash
44-
export ORACLE_CONNECTION_STRING="<your-oracle-connection-string>"
4543
export ORACLE_USER="<your-oracle-sql-user>"
4644
export ORACLE_PASSWORD="<your-oracle-sql-password>"
47-
export ORACLE_USE_OCI="true or false- The flag true or false if your Oracle instance is deployed in cloud"
45+
```
4846

49-
# Optional Using Wallet based authentication for cloud based deployments that supports Wallet Authentication
50-
export ORACLE_WALLET="your-oracle-wallet-location":
51-
> [!NOTE]
52-
> If you run the Oracle DB instance in a cloud deployment model, uses private IPs, you must run Gemini CLI in the same Virtual Private Cloud (VPC) network.
47+
Then you need to choose one of the following connection methods:
48+
49+
1. Host, Port, and Service Name
50+
```bash
51+
export ORACLE_HOST="<your-oracle-host>"
52+
export ORACLE_PORT="<your-oracle-port>"
53+
export ORACLE_SERVICE_NAME="<your-oracle-service-name>"
54+
```
55+
56+
2. TNS Alias
57+
```bash
58+
export ORACLE_TNS_ALIAS="<the tns alias of your oracle database>"
59+
export ORACLE_TNS_ADMIN="<the path to the TNS directory>"
60+
```
61+
62+
3. Direct Connection String
63+
```bash
64+
export ORACLE_CONNECTION_STRING="<the connection string of your oracle database>"
65+
```
66+
67+
#### Oracle Wallet / OCI databases
68+
69+
If you wish to use the Oracle Wallet, you can configure the following variable:
70+
71+
```bash
72+
export ORACLE_WALLET="/path/to/my/wallet/directory"
73+
```
74+
75+
Example:
76+
77+
```bash
78+
export ORACLE_CONNECTION_STRING="127.0.0.1:1521/XEPDB1"
79+
export ORACLE_USER="myuser"
80+
export ORACLE_PASSWORD="mypassword"
81+
export ORACLE_TNS_ALIAS="SECURE_DB_ALIAS"
82+
export ORACLE_WALLET="/path/to/my/wallet/directory"
83+
```
84+
85+
For OCI-based databases, the wallet authentication is triggered by setting tnsAdmin to the wallet directory and connecting via a tnsAlias.
86+
You need to specify the following variable:
87+
88+
```bash
89+
export ORACLE_USE_OCI=true
90+
```
5391

5492
### Start Gemini CLI
5593

gemini-extension.json

Lines changed: 56 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"name": "oracle-gemini-extension",
2+
"name": "oracledb",
33
"version": "0.1.0",
44
"description": "Connect, query, and interact with Oracle Databases and their data within Gemini CLI.",
55
"mcpServers": {
@@ -10,14 +10,61 @@
1010
"${extensionPath}${/}oracledb.yaml",
1111
"--stdio"
1212
],
13-
"env": {
14-
"ORACLE_CONNECTION_STRING": "$ORACLE_CONNECTION_STRING",
15-
"ORACLE_USER": "$ORACLE_USER",
16-
"ORACLE_PASSWORD": "$ORACLE_PASSWORD",
17-
"ORACLE_USE_OCI": "$ORACLE_USE_OCI",
18-
"ORACLE_WALLET": "$ORACLE_WALLET"
19-
}
13+
"env": {}
2014
}
2115
},
22-
"contextFileName": "ORACLEDB.md"
16+
"contextFileName": "ORACLEDB.md",
17+
"settings": [
18+
{
19+
"name": "User",
20+
"description": "Username for the Oracle connection",
21+
"envVar": "ORACLE_USER"
22+
},
23+
{
24+
"name": "Password",
25+
"description": "Password for the Oracle connection",
26+
"envVar": "ORACLE_PASSWORD",
27+
"sensitive": true
28+
},
29+
{
30+
"name": "Use OCI",
31+
"description": "Set to true to use OCI driver (godror), false for pure Go driver",
32+
"envVar": "ORACLE_USE_OCI"
33+
},
34+
{
35+
"name": "Host",
36+
"description": "Oracle Database Host (for Host/Port/Service Name connection)",
37+
"envVar": "ORACLE_HOST"
38+
},
39+
{
40+
"name": "Port",
41+
"description": "Oracle Database Port (for Host/Port/Service Name connection)",
42+
"envVar": "ORACLE_PORT"
43+
},
44+
{
45+
"name": "Service Name",
46+
"description": "Oracle Service Name (for Host/Port/Service Name connection)",
47+
"envVar": "ORACLE_SERVICE_NAME"
48+
},
49+
{
50+
"name": "TNS Alias",
51+
"description": "TNS Alias (for TNS connection)",
52+
"envVar": "ORACLE_TNS_ALIAS"
53+
},
54+
{
55+
"name": "TNS Admin",
56+
"description": "Path to directory containing tnsnames.ora (required for TNS/Wallet with OCI)",
57+
"envVar": "ORACLE_TNS_ADMIN"
58+
},
59+
{
60+
"name": "Connection String",
61+
"description": "Direct Connection String (EZConnect or similar)",
62+
"envVar": "ORACLE_CONNECTION_STRING"
63+
},
64+
{
65+
"name": "Wallet Location",
66+
"description": "Path to Wallet directory (for pure Go driver with Wallet)",
67+
"envVar": "ORACLE_WALLET"
68+
}
69+
]
2370
}

oracledb.yaml

Lines changed: 113 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
# Copyright 2026 Google LLC
32
#
43
# Licensed under the Apache License, Version 2.0 (the "License");
@@ -14,109 +13,124 @@
1413
# limitations under the License.
1514

1615
sources:
17-
oracle-source:
18-
kind: "oracle"
19-
connectionString: ${ORACLE_CONNECTION_STRING}
20-
walletLocation: ${ORACLE_WALLET:}
21-
user: ${ORACLE_USER}
22-
password: ${ORACLE_PASSWORD}
23-
useOCI: ${ORACLE_USE_OCI:false}
16+
oracle-source:
17+
kind: oracle
18+
user: ${ORACLE_USER}
19+
password: ${ORACLE_PASSWORD}
20+
21+
# --- Choose one connection method ---
22+
# 1. Host, Port, and Service Name
23+
host: ${ORACLE_HOST:}
24+
port: ${ORACLE_PORT:0}
25+
serviceName: ${ORACLE_SERVICE_NAME:}
26+
# 2. TNS Alias
27+
tnsAlias: ${ORACLE_TNS_ALIAS:}
28+
tnsAdmin: ${ORACLE_TNS_ADMIN:}
29+
# 3. Direct Connection String
30+
connectionString: ${ORACLE_CONNECTION_STRING:}
31+
walletLocation: ${ORACLE_WALLET:}
32+
33+
useOCI: ${ORACLE_USE_OCI:false}
2434

2535
tools:
26-
27-
list_tables:
28-
kind: oracle-sql
29-
source: oracle-source
30-
description: "Lists all user tables in the connected schema, including segment size, row count, and last analyzed date. Filters by a comma-separated list of names. If names are omitted, lists all tables in the current user's schema."
31-
statement: SELECT table_name from user_tables;
36+
execute_sql:
37+
kind: oracle-execute-sql
38+
source: oracle-source
39+
description: Use this tool to execute SQL queries on the games rules table or any other table.
40+
41+
list_tables:
42+
kind: oracle-sql
43+
source: oracle-source
44+
description: "Lists all user tables in the connected schema, including segment size, row count, and last analyzed date. Filters by a comma-separated list of names. If names are omitted, lists all tables in the current user's schema"
45+
statement: SELECT table_name from user_tables;
46+
47+
list_active_sessions:
48+
kind: oracle-sql
49+
source: oracle-source
50+
description: "List the top N (default 50) currently running database sessions (STATUS='ACTIVE'), showing SID, OS User, Program, and the current SQL statement text."
51+
statement: SELECT
52+
s.sid,
53+
s.serial#,
54+
s.username,
55+
s.osuser,
56+
s.program,
57+
s.status,
58+
s.wait_class,
59+
s.event,
60+
sql.sql_text
61+
FROM
62+
v$session s,
63+
v$sql sql
64+
WHERE
65+
s.status = 'ACTIVE'
66+
AND s.sql_id = sql.sql_id (+)
67+
AND s.audsid != userenv('sessionid') -- Exclude current session
68+
ORDER BY s.last_call_et DESC
69+
FETCH FIRST COALESCE(10) ROWS ONLY;
3270

33-
list_active_sessions:
34-
kind: oracle-sql
35-
source: oracle-source
36-
description: "List the top N (default 50) currently running database sessions (STATUS='ACTIVE'), showing SID, OS User, Program, and the current SQL statement text."
37-
statement: SELECT
38-
s.sid,
39-
s.serial#,
40-
s.username,
41-
s.osuser,
42-
s.program,
43-
s.status,
44-
s.wait_class,
45-
s.event,
46-
sql.sql_text
47-
FROM
48-
v$session s,
49-
v$sql sql
50-
WHERE
51-
s.status = 'ACTIVE'
52-
AND s.sql_id = sql.sql_id (+)
53-
AND s.audsid != userenv('sessionid') -- Exclude current session
54-
ORDER BY s.last_call_et DESC
55-
FETCH FIRST COALESCE(10) ROWS ONLY;
71+
get_query_plan:
72+
kind: oracle-sql
73+
source: oracle-source
74+
description: "Generate a full execution plan for a single SQL statement. This can be used to analyze query performance without execution. Requires the SQL statement as input. following is an example EXPLAIN PLAN FOR {{&query}};"
75+
statement: SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
5676

57-
get_query_plan:
58-
kind: oracle-sql
59-
source: oracle-source
60-
description: "Generate a full execution plan for a single SQL statement. This can be used to analyze query performance without execution. Requires the SQL statement as input. following is an example EXPLAIN PLAN FOR {{&query}};"
61-
statement: SELECT PLAN_TABLE_OUTPUT FROM TABLE(DBMS_XPLAN.DISPLAY());
77+
list_top_sql_by_resource:
78+
kind: oracle-sql
79+
source: oracle-source
80+
description: "List the top N SQL statements from the library cache based on a chosen resource metric (CPU, I/O, or Elapsed Time), following is an example of the sql"
81+
statement: SELECT
82+
sql_id,
83+
executions,
84+
buffer_gets,
85+
disk_reads,
86+
cpu_time / 1000000 AS cpu_seconds,
87+
elapsed_time / 1000000 AS elapsed_seconds
88+
FROM
89+
v$sql
90+
FETCH FIRST 5 ROWS ONLY;
6291

63-
list_top_sql_by_resource:
64-
kind: oracle-sql
65-
source: oracle-source
66-
description: "List the top N SQL statements from the library cache based on a chosen resource metric (CPU, I/O, or Elapsed Time), following is an example of the sql"
67-
statement: SELECT
68-
sql_id,
69-
executions,
70-
buffer_gets,
71-
disk_reads,
72-
cpu_time / 1000000 AS cpu_seconds,
73-
elapsed_time / 1000000 AS elapsed_seconds
74-
FROM
75-
v$sql
76-
FETCH FIRST 5 ROWS ONLY;
77-
78-
list_tablespace_usage:
79-
kind: oracle-sql
80-
source: oracle-source
81-
description: "List tablespace names, total size, free space, and used percentage to monitor storage utilization."
82-
statement: SELECT
83-
t.tablespace_name,
84-
TO_CHAR(t.total_bytes / 1024 / 1024, '99,999.00') AS total_mb,
85-
TO_CHAR(SUM(d.bytes) / 1024 / 1024, '99,999.00') AS free_mb,
86-
TO_CHAR((t.total_bytes - SUM(d.bytes)) / t.total_bytes * 100, '99.00') AS used_pct
87-
FROM
88-
(SELECT tablespace_name, SUM(bytes) AS total_bytes FROM dba_data_files GROUP BY tablespace_name) t,
89-
dba_free_space d
90-
WHERE
91-
t.tablespace_name = d.tablespace_name (+)
92-
GROUP BY
93-
t.tablespace_name, t.total_bytes
94-
ORDER BY
95-
used_pct DESC;
92+
list_tablespace_usage:
93+
kind: oracle-sql
94+
source: oracle-source
95+
description: "List tablespace names, total size, free space, and used percentage to monitor storage utilization."
96+
statement: SELECT
97+
t.tablespace_name,
98+
TO_CHAR(t.total_bytes / 1024 / 1024, '99,999.00') AS total_mb,
99+
TO_CHAR(SUM(d.bytes) / 1024 / 1024, '99,999.00') AS free_mb,
100+
TO_CHAR((t.total_bytes - SUM(d.bytes)) / t.total_bytes * 100, '99.00') AS used_pct
101+
FROM
102+
(SELECT tablespace_name, SUM(bytes) AS total_bytes FROM dba_data_files GROUP BY tablespace_name) t,
103+
dba_free_space d
104+
WHERE
105+
t.tablespace_name = d.tablespace_name (+)
106+
GROUP BY
107+
t.tablespace_name, t.total_bytes
108+
ORDER BY
109+
used_pct DESC;
96110

97-
list_invalid_objects:
98-
kind: oracle-sql
99-
source: oracle-source
100-
description: "Lists all database objects that are in an invalid state, requiring recompilation (e.g., procedures, functions, views)."
101-
statement: SELECT
102-
owner,
103-
object_type,
104-
object_name,
105-
status
106-
FROM
107-
dba_objects
108-
WHERE
109-
status = 'INVALID'
110-
AND owner NOT IN ('SYS', 'SYSTEM') -- Exclude system schemas for clarity
111-
ORDER BY
112-
owner, object_type, object_name;
111+
list_invalid_objects:
112+
kind: oracle-sql
113+
source: oracle-source
114+
description: "Lists all database objects that are in an invalid state, requiring recompilation (e.g., procedures, functions, views)."
115+
statement: SELECT
116+
owner,
117+
object_type,
118+
object_name,
119+
status
120+
FROM
121+
dba_objects
122+
WHERE
123+
status = 'INVALID'
124+
AND owner NOT IN ('SYS', 'SYSTEM') -- Exclude system schemas for clarity
125+
ORDER BY
126+
owner, object_type, object_name;
113127

114128
toolsets:
115-
oracle_database_tools:
116-
- execute_sql
117-
- list_tables
118-
- list_active_sessions
119-
- get_query_plan
120-
- list_top_sql_by_resource
121-
- list_tablespace_usage
122-
- list_invalid_objects
129+
oracle_database_tools:
130+
- execute_sql
131+
- list_tables
132+
- list_active_sessions
133+
- get_query_plan
134+
- list_top_sql_by_resource
135+
- list_tablespace_usage
136+
- list_invalid_objects

0 commit comments

Comments
 (0)