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

Code before:
			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(),
	}

	// finish tool setup
	t := Tool{
		Name:             cfg.Name,
		Kind:             kind,
		Parameters:       parameters,
		AuthRequired:     cfg.AuthRequired,
		UseClientOAuth:   s.UseClientAuthorization(),
		ClientCreator:    s.BigQueryClientCreator(),
		Client:           s.BigQueryClient(),
		IsDatasetAllowed: s.IsDatasetAllowed,

Review comment (suggestion):
```suggestion
			datasetDescription += fmt.Sprintf(" Must be one of the allowed datasets: %s.", strings.Join(datasetDescriptions, ". "))
```

The datasetDescription will be as follow: "The dataset to list table ids. `dataset_one`, `dataset_two` from project `project1`. `dataset_three`, `dataset_four` from project `project2`."

Feel free to reject this suggestion if you think the comma makes more sense.

Code after:
			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,
		Parameters:       parameters,
		AuthRequired:     cfg.AuthRequired,
		UseClientOAuth:   s.UseClientAuthorization(),
		ClientCreator:    s.BigQueryClientCreator(),
		Client:           s.BigQueryClient(),
		IsDatasetAllowed: s.IsDatasetAllowed,
		manifest:         tools.Manifest{Description: cfg.Description, Parameters: parameters.Manifest(), AuthRequired: cfg.AuthRequired},
		mcpManifest:      mcpManifest,
	}
	return t, nil
}