diff --git a/cmd/root_test.go b/cmd/root_test.go index 4a66411df2..e33aee6445 100644 --- a/cmd/root_test.go +++ b/cmd/root_test.go @@ -869,7 +869,8 @@ func TestParseToolFile(t *testing.T) { ToolNames: []string{"example_tool"}, }, }, - Prompts: nil, + AuthServices: nil, + Prompts: nil, }, }, { @@ -973,7 +974,7 @@ func TestParseToolFile(t *testing.T) { }, }, Prompts: server.PromptConfigs{ - "code_review": custom.Config{ + "code_review": &custom.Config{ Name: "code_review", Description: "ask llm to analyze code quality", Arguments: prompts.Arguments{ @@ -989,8 +990,8 @@ func TestParseToolFile(t *testing.T) { { description: "only prompts", in: ` - kind: prompts - name: my-prompt + kind: prompts + name: my-prompt description: A prompt template for data analysis. arguments: - name: country @@ -1066,17 +1067,17 @@ func TestParseToolFileWithAuth(t *testing.T) { database: my_db user: my_user password: my_pass - --- +--- kind: authServices name: my-google-service type: google clientId: my-client-id - --- +--- kind: authServices name: other-google-service type: google clientId: other-client-id - --- +--- kind: tools name: example_tool type: postgres-sql @@ -1102,7 +1103,7 @@ func TestParseToolFileWithAuth(t *testing.T) { field: email - name: other-google-service field: other_email - --- +--- kind: toolsets name: example_toolset tools: @@ -1270,17 +1271,17 @@ func TestParseToolFileWithAuth(t *testing.T) { database: my_db user: my_user password: my_pass - --- +--- kind: authServices name: my-google-service type: google clientId: my-client-id - --- +--- kind: authServices name: other-google-service type: google clientId: other-client-id - --- +--- kind: tools name: example_tool type: postgres-sql @@ -1308,7 +1309,7 @@ func TestParseToolFileWithAuth(t *testing.T) { field: email - name: other-google-service field: other_email - --- +--- kind: toolsets name: example_toolset tools: @@ -1567,17 +1568,17 @@ func TestEnvVarReplacement(t *testing.T) { Authorization: ${TestHeader} queryParams: api-key: ${API_KEY} - --- +--- kind: authServices name: my-google-service type: google clientId: ${clientId} - --- +--- kind: authServices name: other-google-service type: google clientId: ${clientId2} - --- +--- kind: tools name: example_tool type: http @@ -1618,12 +1619,12 @@ func TestEnvVarReplacement(t *testing.T) { - name: Language type: string description: language string - --- +--- kind: toolsets name: ${toolset_name} tools: - example_tool - --- +--- kind: prompts name: ${prompt_name} description: A test prompt for {{.name}}. @@ -2601,6 +2602,7 @@ description: "Dummy" --- kind: toolsets name: sqlite_database_tools +tools: - dummy_tool ` toolsetConflictFile := filepath.Join(t.TempDir(), "toolset_conflict.yaml") diff --git a/docs/en/getting-started/introduction/_index.md b/docs/en/getting-started/introduction/_index.md index 5a42ca83a7..a5e282a25f 100644 --- a/docs/en/getting-started/introduction/_index.md +++ b/docs/en/getting-started/introduction/_index.md @@ -16,6 +16,12 @@ Databases” as its initial development predated MCP, but was renamed to align with recently added MCP compatibility. {{< /notice >}} +{{< notice note >}} +This document has been updated to support the configuration file v2 format. To +view documentation with configuration file v1 format, please navigate to the +top-right menu and select versions v0.26.0 or older. +{{< /notice >}} + ## Why Toolbox? Toolbox helps you build Gen AI tools that let your agents access data in your diff --git a/internal/server/config.go b/internal/server/config.go index 545d795957..5e0d3dcae9 100644 --- a/internal/server/config.go +++ b/internal/server/config.go @@ -136,12 +136,12 @@ type PromptsetConfigs map[string]prompts.PromptsetConfig func UnmarshalResourceConfig(ctx context.Context, raw []byte) (SourceConfigs, AuthServiceConfigs, EmbeddingModelConfigs, ToolConfigs, ToolsetConfigs, PromptConfigs, error) { // prepare configs map - sourceConfigs := make(map[string]sources.SourceConfig) - authServiceConfigs := make(AuthServiceConfigs) - embeddingModelConfigs := make(EmbeddingModelConfigs) - toolConfigs := make(ToolConfigs) - toolsetConfigs := make(ToolsetConfigs) - promptConfigs := make(PromptConfigs) + var sourceConfigs SourceConfigs + var authServiceConfigs AuthServiceConfigs + var embeddingModelConfigs EmbeddingModelConfigs + var toolConfigs ToolConfigs + var toolsetConfigs ToolsetConfigs + var promptConfigs PromptConfigs // promptset configs is not yet supported decoder := yaml.NewDecoder(bytes.NewReader(raw)) @@ -171,36 +171,54 @@ func UnmarshalResourceConfig(ctx context.Context, raw []byte) (SourceConfigs, Au if err != nil { return nil, nil, nil, nil, nil, nil, fmt.Errorf("error unmarshaling %s: %s", kind, err) } + if sourceConfigs == nil { + sourceConfigs = make(SourceConfigs) + } sourceConfigs[name] = c case "authServices": c, err := UnmarshalYAMLAuthServiceConfig(ctx, name, resource) if err != nil { return nil, nil, nil, nil, nil, nil, fmt.Errorf("error unmarshaling %s: %s", kind, err) } + if authServiceConfigs == nil { + authServiceConfigs = make(AuthServiceConfigs) + } authServiceConfigs[name] = c case "tools": c, err := UnmarshalYAMLToolConfig(ctx, name, resource) if err != nil { return nil, nil, nil, nil, nil, nil, fmt.Errorf("error unmarshaling %s: %s", kind, err) } + if toolConfigs == nil { + toolConfigs = make(ToolConfigs) + } toolConfigs[name] = c case "toolsets": c, err := UnmarshalYAMLToolsetConfig(ctx, name, resource) if err != nil { return nil, nil, nil, nil, nil, nil, fmt.Errorf("error unmarshaling %s: %s", kind, err) } + if toolsetConfigs == nil { + toolsetConfigs = make(ToolsetConfigs) + } toolsetConfigs[name] = c case "embeddingModels": c, err := UnmarshalYAMLEmbeddingModelConfig(ctx, name, resource) if err != nil { return nil, nil, nil, nil, nil, nil, fmt.Errorf("error unmarshaling %s: %s", kind, err) } + if embeddingModelConfigs == nil { + embeddingModelConfigs = make(EmbeddingModelConfigs) + } embeddingModelConfigs[name] = c case "prompts": c, err := UnmarshalYAMLPromptConfig(ctx, name, resource) if err != nil { return nil, nil, nil, nil, nil, nil, fmt.Errorf("error unmarshaling %s: %s", kind, err) } + if promptConfigs == nil { + promptConfigs = make(PromptConfigs) + } promptConfigs[name] = c default: return nil, nil, nil, nil, nil, nil, fmt.Errorf("invalid kind %s", kind) diff --git a/tests/cloudsql/cloud_sql_get_instances_test.go b/tests/cloudsql/cloud_sql_get_instances_test.go index 1c9e58b4c3..709a501450 100644 --- a/tests/cloudsql/cloud_sql_get_instances_test.go +++ b/tests/cloudsql/cloud_sql_get_instances_test.go @@ -53,7 +53,7 @@ func (t *getInstancesTransport) RoundTrip(req *http.Request) (*http.Response, er type instance struct { Name string `json:"name"` - Type string `json:"type"` + Kind string `json:"kind"` } type handler struct { @@ -95,7 +95,7 @@ func (h *handler) ServeHTTP(w http.ResponseWriter, r *http.Request) { func TestGetInstancesToolEndpoints(t *testing.T) { h := &handler{ instances: map[string]*instance{ - "instance-1": {Name: "instance-1", Type: "sql#instance"}, + "instance-1": {Name: "instance-1", Kind: "sql#instance"}, }, t: t, } @@ -151,7 +151,7 @@ func TestGetInstancesToolEndpoints(t *testing.T) { name: "successful get instance", toolName: "get-instance-1", body: `{"projectId": "p1", "instanceId": "instance-1"}`, - want: `{"name":"instance-1","type":"sql#instance"}`, + want: `{"name":"instance-1","kind":"sql#instance"}`, }, { name: "failed get instance",