Skip to content

Commit 5196c6a

Browse files
averikitschYuan325
andauthored
feat(source/oss-db)!: restructure prebuilt toolsets (#2638)
## Description > Should include a concise description of the changes (bug or feature), it's > impact, along with a summary of the solution ## PR Checklist > Thank you for opening a Pull Request! Before submitting your PR, there are a > few things you can do to make sure it goes smoothly: - [ ] Make sure you reviewed [CONTRIBUTING.md](https://github.com/googleapis/genai-toolbox/blob/main/CONTRIBUTING.md) - [ ] Make sure to open an issue as a [bug/issue](https://github.com/googleapis/genai-toolbox/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) - [ ] Make sure to add `!` if this involve a breaking change 🛠️ Fixes #<issue_number_goes_here> --------- Co-authored-by: Yuan Teoh <45984206+Yuan325@users.noreply.github.com>
1 parent 99613dc commit 5196c6a

File tree

4 files changed

+261
-263
lines changed

4 files changed

+261
-263
lines changed

cmd/internal/tools_file_test.go

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1832,18 +1832,22 @@ func TestPrebuiltTools(t *testing.T) {
18321832
name: "mysql prebuilt tools",
18331833
in: mysql_config,
18341834
wantToolset: server.ToolsetConfigs{
1835-
"mysql_database_tools": tools.ToolsetConfig{
1836-
Name: "mysql_database_tools",
1837-
ToolNames: []string{"execute_sql", "list_tables", "get_query_plan", "list_active_queries", "list_tables_missing_unique_indexes", "list_table_fragmentation"},
1835+
"data": tools.ToolsetConfig{
1836+
Name: "data",
1837+
ToolNames: []string{"execute_sql", "list_tables", "get_query_plan", "list_active_queries"},
1838+
},
1839+
"monitor": tools.ToolsetConfig{
1840+
Name: "monitor",
1841+
ToolNames: []string{"get_query_plan", "list_active_queries", "list_table_fragmentation", "list_tables_missing_unique_indexes"},
18381842
},
18391843
},
18401844
},
18411845
{
18421846
name: "mssql prebuilt tools",
18431847
in: mssql_config,
18441848
wantToolset: server.ToolsetConfigs{
1845-
"mssql_database_tools": tools.ToolsetConfig{
1846-
Name: "mssql_database_tools",
1849+
"data": tools.ToolsetConfig{
1850+
Name: "data",
18471851
ToolNames: []string{"execute_sql", "list_tables"},
18481852
},
18491853
},
@@ -1882,9 +1886,25 @@ func TestPrebuiltTools(t *testing.T) {
18821886
name: "postgres prebuilt tools",
18831887
in: postgresconfig,
18841888
wantToolset: server.ToolsetConfigs{
1885-
"postgres_database_tools": tools.ToolsetConfig{
1886-
Name: "postgres_database_tools",
1887-
ToolNames: []string{"execute_sql", "list_tables", "list_active_queries", "list_available_extensions", "list_installed_extensions", "list_autovacuum_configurations", "list_memory_configurations", "list_top_bloated_tables", "list_replication_slots", "list_invalid_indexes", "get_query_plan", "list_views", "list_schemas", "database_overview", "list_triggers", "list_indexes", "list_sequences", "long_running_transactions", "list_locks", "replication_stats", "list_query_stats", "get_column_cardinality", "list_publication_tables", "list_tablespaces", "list_pg_settings", "list_database_stats", "list_roles", "list_table_stats", "list_stored_procedure"},
1889+
"data": tools.ToolsetConfig{
1890+
Name: "data",
1891+
ToolNames: []string{"execute_sql", "list_tables", "list_views", "list_schemas", "list_triggers", "list_indexes", "list_sequences", "list_stored_procedure"},
1892+
},
1893+
"monitor": tools.ToolsetConfig{
1894+
Name: "monitor",
1895+
ToolNames: []string{"list_query_stats", "get_query_plan", "list_database_stats", "list_active_queries", "long_running_transactions", "list_locks"},
1896+
},
1897+
"health": tools.ToolsetConfig{
1898+
Name: "health",
1899+
ToolNames: []string{"list_top_bloated_tables", "list_invalid_indexes", "list_table_stats", "get_column_cardinality", "list_autovacuum_configurations", "list_tablespaces", "database_overview", "list_pg_settings"},
1900+
},
1901+
"view-config": tools.ToolsetConfig{
1902+
Name: "view-config",
1903+
ToolNames: []string{"list_available_extensions", "list_installed_extensions", "list_memory_configurations", "list_pg_settings", "database_overview"},
1904+
},
1905+
"replication": tools.ToolsetConfig{
1906+
Name: "replication",
1907+
ToolNames: []string{"replication_stats", "list_replication_slots", "list_publication_tables", "list_roles", "list_pg_settings", "database_overview"},
18881908
},
18891909
},
18901910
},

internal/prebuiltconfigs/tools/mssql.yaml

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,25 +13,23 @@
1313
# limitations under the License.
1414

1515
sources:
16-
mssql-source:
17-
kind: mssql
18-
host: ${MSSQL_HOST:localhost}
19-
port: ${MSSQL_PORT:1433}
20-
database: ${MSSQL_DATABASE}
21-
user: ${MSSQL_USER}
22-
password: ${MSSQL_PASSWORD}
16+
mssql-source:
17+
kind: mssql
18+
host: ${MSSQL_HOST:localhost}
19+
port: ${MSSQL_PORT:1433}
20+
database: ${MSSQL_DATABASE}
21+
user: ${MSSQL_USER}
22+
password: ${MSSQL_PASSWORD}
2323
tools:
24-
execute_sql:
25-
kind: mssql-execute-sql
26-
source: mssql-source
27-
description: Use this tool to execute SQL.
28-
29-
list_tables:
30-
kind: mssql-list-tables
31-
source: mssql-source
32-
description: "Lists detailed schema information (object type, columns, constraints, indexes, triggers, comment) as JSON for user-created tables (ordinary or partitioned). Filters by a comma-separated list of names. If names are omitted, lists all tables in user schemas."
33-
24+
execute_sql:
25+
kind: mssql-execute-sql
26+
source: mssql-source
27+
description: Use this tool to execute SQL.
28+
list_tables:
29+
kind: mssql-list-tables
30+
source: mssql-source
31+
description: "Lists detailed schema information (object type, columns, constraints, indexes, triggers, comment) as JSON for user-created tables (ordinary or partitioned). Filters by a comma-separated list of names. If names are omitted, lists all tables in user schemas."
3432
toolsets:
35-
mssql_database_tools:
36-
- execute_sql
37-
- list_tables
33+
data:
34+
- execute_sql
35+
- list_tables

internal/prebuiltconfigs/tools/mysql.yaml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@ tools:
5151
kind: mysql-list-table-fragmentation
5252
source: mysql-source
5353
description: List table fragmentation in MySQL, by calculating the size of the data and index files and free space allocated to each table. The query calculates fragmentation percentage which represents the proportion of free space relative to the total data and index size. Storage can be reclaimed for tables with high fragmentation using OPTIMIZE TABLE.
54-
5554
toolsets:
56-
mysql_database_tools:
55+
data:
5756
- execute_sql
5857
- list_tables
5958
- get_query_plan
6059
- list_active_queries
61-
- list_tables_missing_unique_indexes
60+
monitor:
61+
- get_query_plan
62+
- list_active_queries
6263
- list_table_fragmentation
64+
- list_tables_missing_unique_indexes

0 commit comments

Comments
 (0)