diff --git a/internal/tools/looker/lookercreateagent/lookercreateagent.go b/internal/tools/looker/lookercreateagent/lookercreateagent.go index 4adc136bb406..3d85c886bae0 100644 --- a/internal/tools/looker/lookercreateagent/lookercreateagent.go +++ b/internal/tools/looker/lookercreateagent/lookercreateagent.go @@ -84,13 +84,12 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) codeInterpreterParameter := parameters.NewBooleanParameterWithDefault("code_interpreter", false, "Optional. Enables Code Interpreter for this Agent.") params := parameters.Parameters{nameParameter, instructionsParameter, sourcesParameter, codeInterpreterParameter} - annotations := cfg.Annotations - if annotations == nil { - readOnlyHint := false - annotations = &tools.ToolAnnotations{ - ReadOnlyHint: &readOnlyHint, - } + annotations := &tools.ToolAnnotations{} + if cfg.Annotations != nil { + *annotations = *cfg.Annotations } + readOnlyHint := false + annotations.ReadOnlyHint = &readOnlyHint mcpManifest := tools.GetMcpManifest(cfg.Name, cfg.Description, cfg.AuthRequired, params, annotations) diff --git a/internal/tools/looker/lookercreateagent/lookercreateagent_test.go b/internal/tools/looker/lookercreateagent/lookercreateagent_test.go index ffe8444b5805..536688ba8591 100644 --- a/internal/tools/looker/lookercreateagent/lookercreateagent_test.go +++ b/internal/tools/looker/lookercreateagent/lookercreateagent_test.go @@ -251,3 +251,32 @@ func TestMcpManifest(t *testing.T) { } } } + +func TestAnnotations(t *testing.T) { + readOnlyTrue := true + cfg := lkr.Config{ + Name: "test_tool", + Type: "looker-create-agent", + Source: "my-instance", + Description: "test description", + Annotations: &tools.ToolAnnotations{ + ReadOnlyHint: &readOnlyTrue, + }, + } + + tool, err := cfg.Initialize(nil) + if err != nil { + t.Fatalf("failed to initialize tool: %v", err) + } + + mcp := tool.McpManifest() + if mcp.Annotations == nil { + t.Fatal("mcp manifest annotations is nil") + } + if mcp.Annotations.ReadOnlyHint == nil { + t.Fatal("mcp manifest ReadOnlyHint is nil") + } + if *mcp.Annotations.ReadOnlyHint != false { + t.Errorf("ReadOnlyHint should be false, got %v", *mcp.Annotations.ReadOnlyHint) + } +} diff --git a/internal/tools/looker/lookerdeleteagent/lookerdeleteagent.go b/internal/tools/looker/lookerdeleteagent/lookerdeleteagent.go index c84dd250817d..fffdf9f6949a 100644 --- a/internal/tools/looker/lookerdeleteagent/lookerdeleteagent.go +++ b/internal/tools/looker/lookerdeleteagent/lookerdeleteagent.go @@ -72,15 +72,14 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) agentIdParameter := parameters.NewStringParameterWithDefault("agent_id", "", "The ID of the agent.") params := parameters.Parameters{agentIdParameter} - annotations := cfg.Annotations - if annotations == nil { - readOnlyHint := false - destructiveHint := true - annotations = &tools.ToolAnnotations{ - ReadOnlyHint: &readOnlyHint, - DestructiveHint: &destructiveHint, - } + annotations := &tools.ToolAnnotations{} + if cfg.Annotations != nil { + *annotations = *cfg.Annotations } + readOnlyHint := false + destructiveHint := true + annotations.ReadOnlyHint = &readOnlyHint + annotations.DestructiveHint = &destructiveHint mcpManifest := tools.GetMcpManifest(cfg.Name, cfg.Description, cfg.AuthRequired, params, annotations) diff --git a/internal/tools/looker/lookerdeleteagent/lookerdeleteagent_test.go b/internal/tools/looker/lookerdeleteagent/lookerdeleteagent_test.go index f4bbd34d0f30..0b5c2ab0a3c9 100644 --- a/internal/tools/looker/lookerdeleteagent/lookerdeleteagent_test.go +++ b/internal/tools/looker/lookerdeleteagent/lookerdeleteagent_test.go @@ -243,3 +243,40 @@ func TestMcpManifest(t *testing.T) { } } } + +func TestAnnotations(t *testing.T) { + readOnlyTrue := true + destructiveFalse := false + cfg := lkr.Config{ + Name: "test_tool", + Type: "looker-delete-agent", + Source: "my-instance", + Description: "test description", + Annotations: &tools.ToolAnnotations{ + ReadOnlyHint: &readOnlyTrue, + DestructiveHint: &destructiveFalse, + }, + } + + tool, err := cfg.Initialize(nil) + if err != nil { + t.Fatalf("failed to initialize tool: %v", err) + } + + mcp := tool.McpManifest() + if mcp.Annotations == nil { + t.Fatal("mcp manifest annotations is nil") + } + if mcp.Annotations.ReadOnlyHint == nil { + t.Fatal("mcp manifest ReadOnlyHint is nil") + } + if *mcp.Annotations.ReadOnlyHint != false { + t.Errorf("ReadOnlyHint should be false, got %v", *mcp.Annotations.ReadOnlyHint) + } + if mcp.Annotations.DestructiveHint == nil { + t.Fatal("mcp manifest DestructiveHint is nil") + } + if *mcp.Annotations.DestructiveHint != true { + t.Errorf("DestructiveHint should be true, got %v", *mcp.Annotations.DestructiveHint) + } +} diff --git a/internal/tools/looker/lookergetagent/lookergetagent.go b/internal/tools/looker/lookergetagent/lookergetagent.go index 726daa9cc462..0da8fdae87af 100644 --- a/internal/tools/looker/lookergetagent/lookergetagent.go +++ b/internal/tools/looker/lookergetagent/lookergetagent.go @@ -72,13 +72,12 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) agentIdParameter := parameters.NewStringParameterWithDefault("agent_id", "", "The ID of the agent.") params := parameters.Parameters{agentIdParameter} - annotations := cfg.Annotations - if annotations == nil { - readOnlyHint := true - annotations = &tools.ToolAnnotations{ - ReadOnlyHint: &readOnlyHint, - } + annotations := &tools.ToolAnnotations{} + if cfg.Annotations != nil { + *annotations = *cfg.Annotations } + readOnlyHint := true + annotations.ReadOnlyHint = &readOnlyHint mcpManifest := tools.GetMcpManifest(cfg.Name, cfg.Description, cfg.AuthRequired, params, annotations) diff --git a/internal/tools/looker/lookergetagent/lookergetagent_test.go b/internal/tools/looker/lookergetagent/lookergetagent_test.go index 692cc8d9179a..6fba53ced2af 100644 --- a/internal/tools/looker/lookergetagent/lookergetagent_test.go +++ b/internal/tools/looker/lookergetagent/lookergetagent_test.go @@ -243,3 +243,32 @@ func TestMcpManifest(t *testing.T) { } } } + +func TestAnnotations(t *testing.T) { + readOnlyFalse := false + cfg := lkr.Config{ + Name: "test_tool", + Type: "looker-get-agent", + Source: "my-instance", + Description: "test description", + Annotations: &tools.ToolAnnotations{ + ReadOnlyHint: &readOnlyFalse, + }, + } + + tool, err := cfg.Initialize(nil) + if err != nil { + t.Fatalf("failed to initialize tool: %v", err) + } + + mcp := tool.McpManifest() + if mcp.Annotations == nil { + t.Fatal("mcp manifest annotations is nil") + } + if mcp.Annotations.ReadOnlyHint == nil { + t.Fatal("mcp manifest ReadOnlyHint is nil") + } + if *mcp.Annotations.ReadOnlyHint != true { + t.Errorf("ReadOnlyHint should be true, got %v", *mcp.Annotations.ReadOnlyHint) + } +} diff --git a/internal/tools/looker/lookerlistagents/lookerlistagents.go b/internal/tools/looker/lookerlistagents/lookerlistagents.go index f2348e745deb..02eb774200bc 100644 --- a/internal/tools/looker/lookerlistagents/lookerlistagents.go +++ b/internal/tools/looker/lookerlistagents/lookerlistagents.go @@ -71,13 +71,12 @@ func (cfg Config) ToolConfigType() string { func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) { params := parameters.Parameters{} - annotations := cfg.Annotations - if annotations == nil { - readOnlyHint := true - annotations = &tools.ToolAnnotations{ - ReadOnlyHint: &readOnlyHint, - } + annotations := &tools.ToolAnnotations{} + if cfg.Annotations != nil { + *annotations = *cfg.Annotations } + readOnlyHint := true + annotations.ReadOnlyHint = &readOnlyHint mcpManifest := tools.GetMcpManifest(cfg.Name, cfg.Description, cfg.AuthRequired, params, annotations) diff --git a/internal/tools/looker/lookerlistagents/lookerlistagents_test.go b/internal/tools/looker/lookerlistagents/lookerlistagents_test.go index b72df442205c..1ab8ac9ffe0e 100644 --- a/internal/tools/looker/lookerlistagents/lookerlistagents_test.go +++ b/internal/tools/looker/lookerlistagents/lookerlistagents_test.go @@ -204,3 +204,32 @@ func TestMcpManifest(t *testing.T) { } } } + +func TestAnnotations(t *testing.T) { + readOnlyFalse := false + cfg := lkr.Config{ + Name: "test_tool", + Type: "looker-list-agents", + Source: "my-instance", + Description: "test description", + Annotations: &tools.ToolAnnotations{ + ReadOnlyHint: &readOnlyFalse, + }, + } + + tool, err := cfg.Initialize(nil) + if err != nil { + t.Fatalf("failed to initialize tool: %v", err) + } + + mcp := tool.McpManifest() + if mcp.Annotations == nil { + t.Fatal("mcp manifest annotations is nil") + } + if mcp.Annotations.ReadOnlyHint == nil { + t.Fatal("mcp manifest ReadOnlyHint is nil") + } + if *mcp.Annotations.ReadOnlyHint != true { + t.Errorf("ReadOnlyHint should be true, got %v", *mcp.Annotations.ReadOnlyHint) + } +} diff --git a/internal/tools/looker/lookerupdateagent/lookerupdateagent.go b/internal/tools/looker/lookerupdateagent/lookerupdateagent.go index bec0deb02d31..3410eb537fd4 100644 --- a/internal/tools/looker/lookerupdateagent/lookerupdateagent.go +++ b/internal/tools/looker/lookerupdateagent/lookerupdateagent.go @@ -85,13 +85,12 @@ func (cfg Config) Initialize(srcs map[string]sources.Source) (tools.Tool, error) codeInterpreterParameter := parameters.NewBooleanParameterWithDefault("code_interpreter", false, "Optional. Enables Code Interpreter for this Agent.") params := parameters.Parameters{agentIdParameter, nameParameter, instructionsParameter, sourcesParameter, codeInterpreterParameter} - annotations := cfg.Annotations - if annotations == nil { - readOnlyHint := false - annotations = &tools.ToolAnnotations{ - ReadOnlyHint: &readOnlyHint, - } + annotations := &tools.ToolAnnotations{} + if cfg.Annotations != nil { + *annotations = *cfg.Annotations } + readOnlyHint := false + annotations.ReadOnlyHint = &readOnlyHint mcpManifest := tools.GetMcpManifest(cfg.Name, cfg.Description, cfg.AuthRequired, params, annotations) diff --git a/internal/tools/looker/lookerupdateagent/lookerupdateagent_test.go b/internal/tools/looker/lookerupdateagent/lookerupdateagent_test.go index 26803d2125bc..b3405b9cedeb 100644 --- a/internal/tools/looker/lookerupdateagent/lookerupdateagent_test.go +++ b/internal/tools/looker/lookerupdateagent/lookerupdateagent_test.go @@ -251,3 +251,32 @@ func TestMcpManifest(t *testing.T) { } } } + +func TestAnnotations(t *testing.T) { + readOnlyTrue := true + cfg := lkr.Config{ + Name: "test_tool", + Type: "looker-update-agent", + Source: "my-instance", + Description: "test description", + Annotations: &tools.ToolAnnotations{ + ReadOnlyHint: &readOnlyTrue, + }, + } + + tool, err := cfg.Initialize(nil) + if err != nil { + t.Fatalf("failed to initialize tool: %v", err) + } + + mcp := tool.McpManifest() + if mcp.Annotations == nil { + t.Fatal("mcp manifest annotations is nil") + } + if mcp.Annotations.ReadOnlyHint == nil { + t.Fatal("mcp manifest ReadOnlyHint is nil") + } + if *mcp.Annotations.ReadOnlyHint != false { + t.Errorf("ReadOnlyHint should be false, got %v", *mcp.Annotations.ReadOnlyHint) + } +}