Skip to content

Commit ea4952d

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 ea4952d

File tree

12 files changed

+160
-114
lines changed

12 files changed

+160
-114
lines changed

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

Lines changed: 82 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,85 @@
3030
}
3131
}
3232
},
33-
"name": "kiali_get_mesh_graph"
33+
"name": "kiali_graph"
34+
},
35+
{
36+
"annotations": {
37+
"title": "Manage Istio Config: List, Get, Create, Patch, Delete",
38+
"destructiveHint": true,
39+
"idempotentHint": true,
40+
"openWorldHint": true
41+
},
42+
"description": "Manages Istio configuration objects (Gateways, VirtualServices, etc.). Can list (objects and validations), get, create, patch, or delete objects",
43+
"inputSchema": {
44+
"type": "object",
45+
"properties": {
46+
"action": {
47+
"description": "Action to perform: list, get, create, patch, or delete",
48+
"type": "string"
49+
},
50+
"group": {
51+
"description": "API group of the Istio object (e.g., 'networking.istio.io', 'gateway.networking.k8s.io')",
52+
"type": "string"
53+
},
54+
"json_data": {
55+
"description": "JSON data to apply or create the object",
56+
"type": "string"
57+
},
58+
"kind": {
59+
"description": "Kind of the Istio object (e.g., 'DestinationRule', 'VirtualService', 'HTTPRoute', 'Gateway')",
60+
"type": "string"
61+
},
62+
"name": {
63+
"description": "Name of the Istio object",
64+
"type": "string"
65+
},
66+
"namespace": {
67+
"description": "Namespace containing the Istio object",
68+
"type": "string"
69+
},
70+
"version": {
71+
"description": "API version of the Istio object (e.g., 'v1', 'v1beta1')",
72+
"type": "string"
73+
}
74+
},
75+
"required": [
76+
"action"
77+
]
78+
},
79+
"name": "kiali_istio_object"
80+
},
81+
{
82+
"annotations": {
83+
"title": "List or Resource Details",
84+
"readOnlyHint": true,
85+
"destructiveHint": false,
86+
"idempotentHint": true,
87+
"openWorldHint": true
88+
},
89+
"description": "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
90+
"inputSchema": {
91+
"type": "object",
92+
"properties": {
93+
"namespaces": {
94+
"description": "Comma-separated list of namespaces to get services from (e.g. 'bookinfo' or 'bookinfo,default'). If not provided, will list services from all accessible namespaces",
95+
"type": "string"
96+
},
97+
"resource_name": {
98+
"description": "Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).",
99+
"type": "string"
100+
},
101+
"resource_type": {
102+
"description": "Type of resource to get details for (service, workload)",
103+
"enum": [
104+
"service",
105+
"workload"
106+
],
107+
"type": "string"
108+
}
109+
}
110+
},
111+
"name": "kiali_service_workload"
34112
},
35113
{
36114
"annotations": {
@@ -105,39 +183,7 @@
105183
"resource_name"
106184
]
107185
},
108-
"name": "kiali_get_metrics"
109-
},
110-
{
111-
"annotations": {
112-
"title": "List or Resource Details",
113-
"readOnlyHint": true,
114-
"destructiveHint": false,
115-
"idempotentHint": true,
116-
"openWorldHint": true
117-
},
118-
"description": "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
119-
"inputSchema": {
120-
"type": "object",
121-
"properties": {
122-
"namespaces": {
123-
"description": "Comma-separated list of namespaces to get services from (e.g. 'bookinfo' or 'bookinfo,default'). If not provided, will list services from all accessible namespaces",
124-
"type": "string"
125-
},
126-
"resource_name": {
127-
"description": "Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).",
128-
"type": "string"
129-
},
130-
"resource_type": {
131-
"description": "Type of resource to get details for (service, workload)",
132-
"enum": [
133-
"service",
134-
"workload"
135-
],
136-
"type": "string"
137-
}
138-
}
139-
},
140-
"name": "kiali_get_resource_details"
186+
"name": "kiali_service_workload_metrics"
141187
},
142188
{
143189
"annotations": {
@@ -201,53 +247,7 @@
201247
}
202248
}
203249
},
204-
"name": "kiali_get_traces"
205-
},
206-
{
207-
"annotations": {
208-
"title": "Manage Istio Config: List, Get, Create, Patch, Delete",
209-
"destructiveHint": true,
210-
"idempotentHint": true,
211-
"openWorldHint": true
212-
},
213-
"description": "Manages Istio configuration objects (Gateways, VirtualServices, etc.). Can list (objects and validations), get, create, patch, or delete objects",
214-
"inputSchema": {
215-
"type": "object",
216-
"properties": {
217-
"action": {
218-
"description": "Action to perform: list, get, create, patch, or delete",
219-
"type": "string"
220-
},
221-
"group": {
222-
"description": "API group of the Istio object (e.g., 'networking.istio.io', 'gateway.networking.k8s.io')",
223-
"type": "string"
224-
},
225-
"json_data": {
226-
"description": "JSON data to apply or create the object",
227-
"type": "string"
228-
},
229-
"kind": {
230-
"description": "Kind of the Istio object (e.g., 'DestinationRule', 'VirtualService', 'HTTPRoute', 'Gateway')",
231-
"type": "string"
232-
},
233-
"name": {
234-
"description": "Name of the Istio object",
235-
"type": "string"
236-
},
237-
"namespace": {
238-
"description": "Namespace containing the Istio object",
239-
"type": "string"
240-
},
241-
"version": {
242-
"description": "API version of the Istio object (e.g., 'v1', 'v1beta1')",
243-
"type": "string"
244-
}
245-
},
246-
"required": [
247-
"action"
248-
]
249-
},
250-
"name": "kiali_manage_istio_config"
250+
"name": "kiali_traces"
251251
},
252252
{
253253
"annotations": {
@@ -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() + "_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() + "_service_workload_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() + "_service_workload"
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() + "_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)