From bfbc1a4b1bdd5ab7efd69ca788a02268426aba2b Mon Sep 17 00:00:00 2001 From: Mladen Todorovic Date: Tue, 28 Apr 2026 14:42:13 +0200 Subject: [PATCH] Rename list clusters tool --- docs/architecture.md | 4 ++-- e2e-tests/README.md | 4 ++-- e2e-tests/mcpchecker/eval.yaml | 4 ++-- integration/integration_test.go | 6 +++--- internal/toolsets/config/tools.go | 21 ++++++++++----------- internal/toolsets/config/tools_test.go | 6 +++--- internal/toolsets/config/toolset_test.go | 4 ++-- smoke/smoke_test.go | 2 +- 8 files changed, 25 insertions(+), 26 deletions(-) diff --git a/docs/architecture.md b/docs/architecture.md index 698d3e7..7f30c74 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -86,7 +86,7 @@ Central registry that manages all available toolsets and their tools. - `get_clusters_with_orchestrator_cve`: Find clusters where vulnerability is detected in orchestrator components 2. **Config Manager Toolset**: Manage cluster configurations - - `list_clusters`: List all managed clusters with pagination + - `list_secured_clusters`: List all managed clusters with pagination ### StackRox Client @@ -234,7 +234,7 @@ All errors are converted to user-friendly messages with: ### Config Management Tools -**list_clusters** +**list_secured_clusters** - List all clusters managed by StackRox - Client-side pagination support - Returns cluster metadata and status diff --git a/e2e-tests/README.md b/e2e-tests/README.md index 33a9ab8..fcbef57 100644 --- a/e2e-tests/README.md +++ b/e2e-tests/README.md @@ -80,12 +80,12 @@ jq '[.[] | .callHistory.ToolCalls[]? | {name: .request.Params.name, arguments: . | Test | Description | Tool | |------|-------------|------| -| `list-clusters` | List all clusters | `list_clusters` | - | +| `list-clusters` | List all clusters | `list_secured_clusters` | - | | `cve-detected-workloads` | CVE detected in deployments | `get_deployments_for_cve` | | `cve-detected-clusters` | CVE detected in clusters | `get_clusters_with_orchestrator_cve` | | `cve-nonexistent` | Handle non-existent CVE | `get_clusters_with_orchestrator_cve` | | `cve-cluster-does-exist` | CVE with cluster filter | `get_clusters_with_orchestrator_cve` | -| `cve-cluster-does-not-exist` | CVE with non-existent cluster | `list_clusters` | +| `cve-cluster-does-not-exist` | CVE with non-existent cluster | `list_secured_clusters` | | `cve-clusters-general` | General CVE query | `get_clusters_with_orchestrator_cve` | | `cve-cluster-list` | CVE across clusters | `get_clusters_with_orchestrator_cve` | | `cve-log4shell` | Well-known CVE (log4shell) | `get_deployments_for_cve` | diff --git a/e2e-tests/mcpchecker/eval.yaml b/e2e-tests/mcpchecker/eval.yaml index 8d4303f..0888037 100644 --- a/e2e-tests/mcpchecker/eval.yaml +++ b/e2e-tests/mcpchecker/eval.yaml @@ -25,7 +25,7 @@ config: assertions: toolsUsed: - server: stackrox-mcp - toolPattern: "list_clusters" + toolPattern: "list_secured_clusters" minToolCalls: 1 maxToolCalls: 1 @@ -83,7 +83,7 @@ config: assertions: toolsUsed: - server: stackrox-mcp - toolPattern: "get_clusters_with_orchestrator_cve|list_clusters" + toolPattern: "get_clusters_with_orchestrator_cve|list_secured_clusters" minToolCalls: 1 maxToolCalls: 5 diff --git a/integration/integration_test.go b/integration/integration_test.go index f7884ca..6e063f9 100644 --- a/integration/integration_test.go +++ b/integration/integration_test.go @@ -30,7 +30,7 @@ func TestIntegration_ListTools(t *testing.T) { } assert.Contains(t, toolNames, "get_deployments_for_cve", "should have get_deployments_for_cve tool") - assert.Contains(t, toolNames, "list_clusters", "should have list_clusters tool") + assert.Contains(t, toolNames, "list_secured_clusters", "should have list_secured_clusters tool") } // TestIntegration_ToolCalls tests successful tool calls using table-driven tests. @@ -50,8 +50,8 @@ func TestIntegration_ToolCalls(t *testing.T) { args: map[string]any{"cveName": "CVE-9999-99999"}, expectedJSON: EmptyDeploymentsJSON, }, - "list_clusters": { - toolName: "list_clusters", + "list_secured_clusters": { + toolName: "list_secured_clusters", args: map[string]any{}, expectedJSON: AllClustersFixture.ExpectedJSON, }, diff --git a/internal/toolsets/config/tools.go b/internal/toolsets/config/tools.go index 4806125..bb2bdd4 100644 --- a/internal/toolsets/config/tools.go +++ b/internal/toolsets/config/tools.go @@ -21,7 +21,7 @@ const ( defaultLimit = 0 ) -// listClustersInput defines the input parameters for list_clusters tool. +// listClustersInput defines the input parameters for list_secured_clusters tool. type listClustersInput struct { Offset int `json:"offset,omitempty"` Limit int `json:"limit,omitempty"` @@ -34,7 +34,7 @@ type ClusterInfo struct { Type string `json:"type"` } -// listClustersOutput defines the output structure for list_clusters tool. +// listClustersOutput defines the output structure for list_secured_clusters tool. type listClustersOutput struct { Clusters []ClusterInfo `json:"clusters"` TotalCount int `json:"totalCount"` @@ -42,16 +42,16 @@ type listClustersOutput struct { Limit int `json:"limit"` } -// listClustersTool implements the list_clusters tool. +// listClustersTool implements the list_secured_clusters tool. type listClustersTool struct { name string client *client.Client } -// NewListClustersTool creates a new list_clusters tool. +// NewListClustersTool creates a new list_secured_clusters tool. func NewListClustersTool(c *client.Client) toolsets.Tool { return &listClustersTool{ - name: "list_clusters", + name: "list_secured_clusters", client: c, } } @@ -70,9 +70,8 @@ func (t *listClustersTool) GetName() string { func (t *listClustersTool) GetTool() *mcp.Tool { return &mcp.Tool{ Name: t.name, - Description: "List all clusters secured by " + config.GetProductDisplayName() + - " with their IDs, names, and types. Use this tool to get cluster information," + - " or when you need to map a cluster name to its cluster ID for use in other tools.", + Description: "List all clusters secured by " + config.GetProductDisplayName() + "." + + " Returns cluster IDs, names, and types. Use this tool to discover available clusters.", InputSchema: listClustersInputSchema(), } } @@ -80,7 +79,7 @@ func (t *listClustersTool) GetTool() *mcp.Tool { func listClustersInputSchema() *jsonschema.Schema { schema, err := jsonschema.For[listClustersInput](nil) if err != nil { - logging.Fatal("Could not get jsonschema for list_clusters input", err) + logging.Fatal("Could not get jsonschema for list_secured_clusters input", err) return nil } @@ -98,7 +97,7 @@ func listClustersInputSchema() *jsonschema.Schema { return schema } -// RegisterWith registers the list_clusters tool handler with the MCP server. +// RegisterWith registers the list_secured_clusters tool handler with the MCP server. func (t *listClustersTool) RegisterWith(server *mcp.Server) { mcp.AddTool(server, t.GetTool(), t.handle) } @@ -137,7 +136,7 @@ func (t *listClustersTool) getClusters(ctx context.Context, req *mcp.CallToolReq return allClusters, nil } -// handle is the handler for list_clusters tool. +// handle is the handler for list_secured_clusters tool. func (t *listClustersTool) handle( ctx context.Context, req *mcp.CallToolRequest, diff --git a/internal/toolsets/config/tools_test.go b/internal/toolsets/config/tools_test.go index c2b08ec..9011ed1 100644 --- a/internal/toolsets/config/tools_test.go +++ b/internal/toolsets/config/tools_test.go @@ -24,13 +24,13 @@ func TestNewListClustersTool(t *testing.T) { tool := NewListClustersTool(&client.Client{}) require.NotNil(t, tool) - assert.Equal(t, "list_clusters", tool.GetName()) + assert.Equal(t, "list_secured_clusters", tool.GetName()) } func TestListClustersTool_IsReadOnly(t *testing.T) { tool := NewListClustersTool(&client.Client{}) - assert.True(t, tool.IsReadOnly(), "list_clusters should be read-only") + assert.True(t, tool.IsReadOnly(), "list_secured_clusters should be read-only") } func TestListClustersTool_GetTool(t *testing.T) { @@ -39,7 +39,7 @@ func TestListClustersTool_GetTool(t *testing.T) { mcpTool := tool.GetTool() require.NotNil(t, mcpTool) - assert.Equal(t, "list_clusters", mcpTool.Name) + assert.Equal(t, "list_secured_clusters", mcpTool.Name) assert.NotEmpty(t, mcpTool.Description) require.NotNil(t, mcpTool.InputSchema, "InputSchema should be defined") } diff --git a/internal/toolsets/config/toolset_test.go b/internal/toolsets/config/toolset_test.go index f12b3d2..4881bb3 100644 --- a/internal/toolsets/config/toolset_test.go +++ b/internal/toolsets/config/toolset_test.go @@ -29,8 +29,8 @@ func TestToolset_IsEnabled_True(t *testing.T) { tools := toolset.GetTools() require.NotEmpty(t, tools, "Should return tools when enabled") - require.Len(t, tools, 1, "Should have list_clusters tool") - assert.Equal(t, "list_clusters", tools[0].GetName()) + require.Len(t, tools, 1, "Should have list_secured_clusters tool") + assert.Equal(t, "list_secured_clusters", tools[0].GetName()) } func TestToolset_IsEnabled_False(t *testing.T) { diff --git a/smoke/smoke_test.go b/smoke/smoke_test.go index 395faf6..64c3006 100644 --- a/smoke/smoke_test.go +++ b/smoke/smoke_test.go @@ -47,7 +47,7 @@ func TestSmoke_RealCluster(t *testing.T) { client := createSmokeTestClient(t, endpoint, apiToken) - result := testutil.CallToolAndGetResult(t, client, "list_clusters", map[string]any{}) + result := testutil.CallToolAndGetResult(t, client, "list_secured_clusters", map[string]any{}) responseText := testutil.GetTextContent(t, result) var data struct {