Skip to content

Commit dcda57e

Browse files
committed
feat(kiali): Possibility of renaming Kiali in the downstream distribution
Signed-off-by: Alberto Gutierrez <aljesusg@gmail.com>
1 parent 6aee8d3 commit dcda57e

File tree

12 files changed

+112
-66
lines changed

12 files changed

+112
-66
lines changed

pkg/mcp/testdata/toolsets-kiali-tools.json

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,4 @@
11
[
2-
{
3-
"annotations": {
4-
"title": "Topology: Mesh, Graph, Health, and Status",
5-
"readOnlyHint": true,
6-
"destructiveHint": false,
7-
"openWorldHint": true
8-
},
9-
"description": "Returns the topology of a specific namespaces, health, status of the mesh and namespaces. Includes a mesh health summary overview with aggregated counts of healthy, degraded, and failing apps, workloads, and services. Use this for high-level overviews",
10-
"inputSchema": {
11-
"type": "object",
12-
"properties": {
13-
"graphType": {
14-
"default": "versionedApp",
15-
"description": "Type of graph to return: 'versionedApp', 'app', 'service', 'workload', 'mesh'",
16-
"type": "string"
17-
},
18-
"namespace": {
19-
"description": "Optional single namespace to include in the graph (alternative to namespaces)",
20-
"type": "string"
21-
},
22-
"namespaces": {
23-
"description": "Optional comma-separated list of namespaces to include in the graph",
24-
"type": "string"
25-
},
26-
"rateInterval": {
27-
"default": "10m",
28-
"description": "Rate interval for fetching (e.g., '10m', '5m', '1h').",
29-
"type": "string"
30-
}
31-
}
32-
},
33-
"name": "kiali_get_mesh_graph"
34-
},
352
{
363
"annotations": {
374
"title": "Get Metrics for a Resource",
@@ -249,6 +216,39 @@
249216
},
250217
"name": "kiali_manage_istio_config"
251218
},
219+
{
220+
"annotations": {
221+
"title": "Topology: Mesh, Graph, Health, and Status",
222+
"readOnlyHint": true,
223+
"destructiveHint": false,
224+
"openWorldHint": true
225+
},
226+
"description": "Returns the topology of a specific namespaces, health, status of the mesh and namespaces. Includes a mesh health summary overview with aggregated counts of healthy, degraded, and failing apps, workloads, and services. Use this for high-level overviews",
227+
"inputSchema": {
228+
"type": "object",
229+
"properties": {
230+
"graphType": {
231+
"default": "versionedApp",
232+
"description": "Type of graph to return: 'versionedApp', 'app', 'service', 'workload', 'mesh'",
233+
"type": "string"
234+
},
235+
"namespace": {
236+
"description": "Optional single namespace to include in the graph (alternative to namespaces)",
237+
"type": "string"
238+
},
239+
"namespaces": {
240+
"description": "Optional comma-separated list of namespaces to include in the graph",
241+
"type": "string"
242+
},
243+
"rateInterval": {
244+
"default": "10m",
245+
"description": "Rate interval for fetching (e.g., '10m', '5m', '1h').",
246+
"type": "string"
247+
}
248+
}
249+
},
250+
"name": "kiali_mesh_graph"
251+
},
252252
{
253253
"annotations": {
254254
"title": "Workload: Logs",
@@ -287,6 +287,6 @@
287287
"workload"
288288
]
289289
},
290-
"name": "workload_logs"
290+
"name": "kiali_workload_logs"
291291
}
292292
]
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package defaults
2+
3+
const (
4+
DefaultToolsetName = "kiali"
5+
DefaultToolsetDescription = "Most common tools for managing Kiali, check the [Kiali documentation](https://github.com/containers/kubernetes-mcp-server/blob/main/docs/KIALI.md) for more details."
6+
)
7+
8+
func ToolsetName() string {
9+
overrideName := ToolsetNameOverride()
10+
if overrideName != "" {
11+
return overrideName
12+
}
13+
return DefaultToolsetName
14+
}
15+
16+
func ToolsetDescription() string {
17+
overrideDescription := ToolsetDescriptionOverride()
18+
if overrideDescription != "" {
19+
return overrideDescription
20+
}
21+
return DefaultToolsetDescription
22+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package defaults
2+
3+
const (
4+
toolsetNameOverride = ""
5+
toolsetDescriptionOverride = ""
6+
)
7+
8+
func ToolsetNameOverride() string {
9+
return toolsetNameOverride
10+
}
11+
12+
func ToolsetDescriptionOverride() string {
13+
return toolsetDescriptionOverride
14+
}

pkg/toolsets/kiali/get_mesh_graph.go renamed to pkg/toolsets/kiali/tools/get_mesh_graph.go

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package kiali
1+
package tools
22

33
import (
44
"fmt"
@@ -9,13 +9,15 @@ import (
99

1010
"github.com/containers/kubernetes-mcp-server/pkg/api"
1111
kialiclient "github.com/containers/kubernetes-mcp-server/pkg/kiali"
12+
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
1213
)
1314

14-
func initGetMeshGraph() []api.ServerTool {
15+
func InitGetMeshGraph() []api.ServerTool {
1516
ret := make([]api.ServerTool, 0)
17+
name := defaults.ToolsetName() + "_mesh_graph"
1618
ret = append(ret, api.ServerTool{
1719
Tool: api.Tool{
18-
Name: "kiali_get_mesh_graph",
20+
Name: name,
1921
Description: "Returns the topology of a specific namespaces, health, status of the mesh and namespaces. Includes a mesh health summary overview with aggregated counts of healthy, degraded, and failing apps, workloads, and services. Use this for high-level overviews",
2022
InputSchema: &jsonschema.Schema{
2123
Type: "object",

pkg/toolsets/kiali/get_metrics.go renamed to pkg/toolsets/kiali/tools/get_metrics.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package kiali
1+
package tools
22

33
import (
44
"context"
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/containers/kubernetes-mcp-server/pkg/api"
1212
kialiclient "github.com/containers/kubernetes-mcp-server/pkg/kiali"
13+
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
1314
)
1415

1516
type resourceOperations struct {
@@ -32,12 +33,12 @@ var opsMap = map[string]resourceOperations{
3233
},
3334
}
3435

35-
func initGetMetrics() []api.ServerTool {
36+
func InitGetMetrics() []api.ServerTool {
3637
ret := make([]api.ServerTool, 0)
37-
38+
name := defaults.ToolsetName() + "_get_metrics"
3839
ret = append(ret, api.ServerTool{
3940
Tool: api.Tool{
40-
Name: "kiali_get_metrics",
41+
Name: name,
4142
Description: "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
4243
InputSchema: &jsonschema.Schema{
4344
Type: "object",

pkg/toolsets/kiali/get_resource_details.go renamed to pkg/toolsets/kiali/tools/get_resource_details.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package kiali
1+
package tools
22

33
import (
44
"context"
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/containers/kubernetes-mcp-server/pkg/api"
1212
kialiclient "github.com/containers/kubernetes-mcp-server/pkg/kiali"
13+
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
1314
)
1415

1516
type listDetailsOperations struct {
@@ -39,12 +40,12 @@ var listDetailsOpsMap = map[string]listDetailsOperations{
3940
},
4041
}
4142

42-
func initGetResourceDetails() []api.ServerTool {
43+
func InitGetResourceDetails() []api.ServerTool {
4344
ret := make([]api.ServerTool, 0)
44-
45+
name := defaults.ToolsetName() + "_get_resource_details"
4546
ret = append(ret, api.ServerTool{
4647
Tool: api.Tool{
47-
Name: "kiali_get_resource_details",
48+
Name: name,
4849
Description: "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
4950
InputSchema: &jsonschema.Schema{
5051
Type: "object",

pkg/toolsets/kiali/get_traces.go renamed to pkg/toolsets/kiali/tools/get_traces.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package kiali
1+
package tools
22

33
import (
44
"context"
@@ -12,6 +12,7 @@ import (
1212

1313
"github.com/containers/kubernetes-mcp-server/pkg/api"
1414
kialiclient "github.com/containers/kubernetes-mcp-server/pkg/kiali"
15+
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
1516
)
1617

1718
type tracesOperations struct {
@@ -40,12 +41,12 @@ var tracesOpsMap = map[string]tracesOperations{
4041
},
4142
}
4243

43-
func initGetTraces() []api.ServerTool {
44+
func InitGetTraces() []api.ServerTool {
4445
ret := make([]api.ServerTool, 0)
45-
46+
name := defaults.ToolsetName() + "_get_traces"
4647
ret = append(ret, api.ServerTool{
4748
Tool: api.Tool{
48-
Name: "kiali_get_traces",
49+
Name: name,
4950
Description: "Gets traces for a specific resource (app, service, workload) in a namespace, or gets detailed information for a specific trace by its ID. If traceId is provided, it returns detailed trace information and other parameters are not required.",
5051
InputSchema: &jsonschema.Schema{
5152
Type: "object",

pkg/toolsets/kiali/helpers.go renamed to pkg/toolsets/kiali/tools/helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package kiali
1+
package tools
22

33
import (
44
"encoding/json"

pkg/toolsets/kiali/helpers_test.go renamed to pkg/toolsets/kiali/tools/helpers_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package kiali
1+
package tools
22

33
import (
44
"encoding/json"

pkg/toolsets/kiali/logs.go renamed to pkg/toolsets/kiali/tools/logs.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package kiali
1+
package tools
22

33
import (
44
"encoding/json"
@@ -8,15 +8,16 @@ import (
88
"k8s.io/utils/ptr"
99

1010
"github.com/containers/kubernetes-mcp-server/pkg/api"
11+
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali/internal/defaults"
1112
)
1213

13-
func initLogs() []api.ServerTool {
14+
func InitLogs() []api.ServerTool {
1415
ret := make([]api.ServerTool, 0)
15-
16+
name := defaults.ToolsetName() + "_workload_logs"
1617
// Workload logs tool
1718
ret = append(ret, api.ServerTool{
1819
Tool: api.Tool{
19-
Name: "workload_logs",
20+
Name: name,
2021
Description: "Get logs for a specific workload's pods in a namespace. Only requires namespace and workload name - automatically discovers pods and containers. Optionally filter by container name, time range, and other parameters. Container is auto-detected if not specified.",
2122
InputSchema: &jsonschema.Schema{
2223
Type: "object",

0 commit comments

Comments
 (0)