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
feat(server): add support for toolset filtering in prebuilt CLI flag (googleapis#3245)
Toolset Filtering for Prebuilt Configs: Enabled loading specific
toolsets from a prebuilt configuration by appending a / suffix (e.g.,
--prebuilt sqlite/sqlite_database_tools), allowing users to load only a
subset of tools rather than the entire configuration.
---------
Co-authored-by: Averi Kitsch <akitsch@google.com>
Copy file name to clipboardExpand all lines: README.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -95,7 +95,7 @@ You can use the Toolbox in any MCP-compatible IDE or client (e.g., Gemini CLI, G
95
95
96
96
2. Set the appropriate environment variables to connect, see the [Prebuilt Tools Reference](https://mcp-toolbox.dev/documentation/configuration/prebuilt-configs/).
97
97
98
-
When you run Toolbox with a `--prebuilt=<database>` flag, you instantly get access to standard tools to interact with that database.
98
+
When you run Toolbox with a `--prebuilt=<database>` flag, you instantly get access to standard tools to interact with that database. You can also specify a specific toolset using the `--prebuilt=<database>/<toolset>` syntax (e.g., `--prebuilt=postgres/data` to only load SQL tools).
99
99
100
100
Supported databases currently include:
101
101
- **Google Cloud:** AlloyDB, BigQuery, Cloud SQL (PostgreSQL, MySQL, SQL Server), Spanner, Firestore, Knowledge Catalog (formerly known as Dataplex).
errMsg:=fmt.Errorf("toolset '%s' not found in prebuilt configuration '%s'. Available toolsets: %s", toolsetName, sourceName, strings.Join(available, ", "))
247
+
logger.ErrorContext(ctx, errMsg.Error())
248
+
returnisCustomConfigured, errMsg
249
+
}
250
+
251
+
// Filter tools to only include those in the target toolset
252
+
filteredTools:=make(server.ToolConfigs)
253
+
for_, tName:=rangetargetToolset.ToolNames {
254
+
iftCfg, tExists:=parsed.Tools[tName]; tExists {
255
+
filteredTools[tName] =tCfg
256
+
}
257
+
}
258
+
parsed.Tools=filteredTools
259
+
260
+
// Filter toolsets to only include the target toolset
wantErr: "toolset 'invalid-toolset' not found in prebuilt configuration 'postgres'. Available toolsets: data, health, monitor, replication, view-config",
89
+
},
90
+
{
91
+
desc: "invalid separator - dot",
92
+
prebuiltConfigs: []string{"postgres.sql"},
93
+
wantErr: "invalid prebuilt config format 'postgres.sql'. Did you mean 'postgres/sql'? Use '/' to specify a toolset",
94
+
},
95
+
{
96
+
desc: "invalid separator - colon",
97
+
prebuiltConfigs: []string{"postgres:sql"},
98
+
wantErr: "invalid prebuilt config format 'postgres:sql'. Did you mean 'postgres/sql'? Use '/' to specify a toolset",
99
+
},
100
+
{
101
+
desc: "invalid separator - at",
102
+
prebuiltConfigs: []string{"postgres@sql"},
103
+
wantErr: "invalid prebuilt config format 'postgres@sql'. Did you mean 'postgres/sql'? Use '/' to specify a toolset",
104
+
},
105
+
{
106
+
desc: "no warning on unrelated dots",
107
+
prebuiltConfigs: []string{"invalid-source.sql"},
108
+
wantErr: "prebuilt source tool for 'invalid-source.sql' not found",
Copy file name to clipboardExpand all lines: docs/en/documentation/configuration/prebuilt-configs/_index.md
+3Lines changed: 3 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -19,6 +19,9 @@ You can now use `--prebuilt` along `--config`, `--configs`, or
19
19
20
20
You can also combine multiple prebuilt configs.
21
21
22
+
**Filtering Toolsets:**
23
+
You can load a specific toolset from a prebuilt configuration by appending a `/` and the toolset name, for example: `--prebuilt=postgres/data` to only load the SQL tools.
24
+
22
25
See [Usage Examples](../../../reference/cli.md#usage-examples).
Copy file name to clipboardExpand all lines: docs/en/reference/cli.md
+5-2Lines changed: 5 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ description: >
21
21
|`-p`|`--port`| Port the server will listen on. |`5000`|
22
22
||`--tls-cert`| Path to the PEM-encoded TLS certificate file. ||
23
23
||`--tls-key`| Path to the PEM-encoded TLS private key file. ||
24
-
||`--prebuilt`| Use one or more prebuilt tool configuration by source type. See [Prebuilt Tools Reference](../documentation/configuration/prebuilt-configs/_index.md) for allowed values. ||
24
+
||`--prebuilt`| Use one or more prebuilt tool configuration by source type. Optionally specify a toolset suffix (e.g., `<source>/<toolset>`) to load only that toolset. See [Prebuilt Tools Reference](../documentation/configuration/prebuilt-configs/_index.md) for allowed values. ||
25
25
||`--stdio`| Listens via MCP STDIO instead of acting as a remote HTTP server. ||
26
26
||`--telemetry-gcp`| Enable exporting directly to Google Cloud Monitoring. ||
27
27
||`--telemetry-gcp-project`| Google Cloud project ID used for `--telemetry-gcp`; defaults to `GOOGLE_CLOUD_PROJECT` if not set. ||
@@ -161,6 +161,9 @@ By default, traffic is unencrypted (HTTP). In production or shared networks, you
# Server filtering a prebuilt configuration to load only a specific toolset
166
+
./toolbox --prebuilt alloydb-postgres/monitor
164
167
```
165
168
166
169
### Tool Configuration Sources
@@ -182,7 +185,7 @@ The CLI supports multiple mutually exclusive ways to specify tool configurations
182
185
**Prebuilt Configurations:**
183
186
184
187
-`--prebuilt`: Use one or more predefined configurations for specific database types (e.g.,
185
-
'bigquery', 'postgres', 'spanner'). See [Prebuilt Tools
188
+
'bigquery', 'postgres', 'spanner'), optionally appending a toolset name to filter the loaded tools (e.g., `alloydb-postgres/monitor`). See [Prebuilt Tools
186
189
Reference](../documentation/configuration/prebuilt-configs/_index.md) for allowed values.
0 commit comments