Repository: googleapis/genai-toolbox
File: internal/tools/bigquery/bigquerylisttableids/bigquerylisttableids.go (Go)

Code before:

	defaultProjectID := s.BigQueryProject()
	projectDescription := "The Google Cloud project ID containing the dataset."
	datasetDescription := "The dataset to list table ids."
	var datasetParameter tools.Parameter
	allowedDatasets := s.BigQueryAllowedDatasets()
	if len(allowedDatasets) > 0 {
		if len(allowedDatasets) == 1 {
			parts := strings.Split(allowedDatasets[0], ".")
			defaultProjectID = parts[0]
			datasetID := parts[1]
			projectDescription += fmt.Sprintf(" Must be `%s`.", defaultProjectID)
			datasetDescription += fmt.Sprintf(" Must be `%s`.", datasetID)
			datasetParameter = tools.NewStringParameterWithDefault(datasetKey, datasetID, datasetDescription)
		} else {
			projectIDs := make(map[string]bool)
			datasetIDsByProject := make(map[string][]string)
			for _, ds := range allowedDatasets {
				parts := strings.Split(ds, ".")
				project := parts[0]
				dataset := parts[1]
				projectIDs[project] = true
				datasetIDsByProject[project] = append(datasetIDsByProject[project], fmt.Sprintf("`%s`", dataset))
			}

			var datasetDescriptions []string
			for project, datasets := range datasetIDsByProject {
				sort.Strings(datasets)
				datasetList := strings.Join(datasets, ", ")
				datasetDescriptions = append(datasetDescriptions, fmt.Sprintf("%s from project `%s`", datasetList, project))
			}

			var projectIDList []string
			for p := range projectIDs {
				projectIDList = append(projectIDList, fmt.Sprintf("`%s`", p))
			}
			projectDescription += fmt.Sprintf(" Must be one of the following: %s.", strings.Join(projectIDList, ", "))
			datasetDescription += fmt.Sprintf(" Must be one of the allowed datasets: %s.", strings.Join(datasetDescriptions, ", "))
			datasetParameter = tools.NewStringParameter(datasetKey, datasetDescription)
		}
	} else {
		datasetParameter = tools.NewStringParameter(datasetKey, datasetDescription)
	}
	projectParameter := tools.NewStringParameterWithDefault(projectKey, defaultProjectID, projectDescription)

	parameters := tools.Parameters{projectParameter, datasetParameter}

	mcpManifest := tools.McpManifest{
		Name:        cfg.Name,
		Description: cfg.Description,
		InputSchema: parameters.McpManifest(),

Review comment (suggestion):
```suggestion
			var datasetDescriptions, projectIDList []string
```

Code after:

	defaultProjectID := s.BigQueryProject()
	projectDescription := "The Google Cloud project ID containing the dataset."
	datasetDescription := "The dataset to list table ids."
	var datasetParameter tools.Parameter
	allowedDatasets := s.BigQueryAllowedDatasets()
	if len(allowedDatasets) > 0 {
		if len(allowedDatasets) == 1 {
			parts := strings.Split(allowedDatasets[0], ".")
			defaultProjectID = parts[0]
			datasetID := parts[1]
			projectDescription += fmt.Sprintf(" Must be `%s`.", defaultProjectID)
			datasetDescription += fmt.Sprintf(" Must be `%s`.", datasetID)
			datasetParameter = tools.NewStringParameterWithDefault(datasetKey, datasetID, datasetDescription)
		} else {
			datasetIDsByProject := make(map[string][]string)
			for _, ds := range allowedDatasets {
				parts := strings.Split(ds, ".")
				project := parts[0]
				dataset := parts[1]
				datasetIDsByProject[project] = append(datasetIDsByProject[project], fmt.Sprintf("`%s`", dataset))
			}

			var datasetDescriptions, projectIDList []string
			for project, datasets := range datasetIDsByProject {
				sort.Strings(datasets)
				projectIDList = append(projectIDList, fmt.Sprintf("`%s`", project))
				datasetList := strings.Join(datasets, ", ")
				datasetDescriptions = append(datasetDescriptions, fmt.Sprintf("%s from project `%s`", datasetList, project))
			}
			projectDescription += fmt.Sprintf(" Must be one of the following: %s.", strings.Join(projectIDList, ", "))
			datasetDescription += fmt.Sprintf(" Must be one of the allowed datasets: %s.", strings.Join(datasetDescriptions, "; "))
			datasetParameter = tools.NewStringParameter(datasetKey, datasetDescription)
		}
	} else {
		datasetParameter = tools.NewStringParameter(datasetKey, datasetDescription)
	}
	projectParameter := tools.NewStringParameterWithDefault(projectKey, defaultProjectID, projectDescription)

	parameters := tools.Parameters{projectParameter, datasetParameter}

	mcpManifest := tools.McpManifest{
		Name:        cfg.Name,
		Description: cfg.Description,
		InputSchema: parameters.McpManifest(),
	}

	// finish tool setup
	t := Tool{
		Name:             cfg.Name,
		Kind:             kind,