Skip to content

Commit 31bfc9e

Browse files
committed
feat(kiali): Possibility of renaming Kiali in the downstream distribution
Signed-off-by: Alberto Gutierrez <[email protected]>
1 parent 59510a9 commit 31bfc9e

File tree

8 files changed

+335
-294
lines changed

8 files changed

+335
-294
lines changed

pkg/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ type StaticConfig struct {
7979

8080
// Internal: the config.toml directory, to help resolve relative file paths
8181
configDirPath string
82+
// ToolsetKialiName allows overriding the registered name of the Kiali toolset downstream builds
83+
ToolsetKialiName string
8284
}
8385

8486
type GroupVersionKind struct {

pkg/toolsets/kiali/get_mesh_graph.go

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -10,44 +10,48 @@ import (
1010
"github.com/containers/kubernetes-mcp-server/pkg/api"
1111
)
1212

13-
func initGetMeshGraph() []api.ServerTool {
14-
ret := make([]api.ServerTool, 0)
15-
ret = append(ret, api.ServerTool{
16-
Tool: api.Tool{
17-
Name: "kiali_get_mesh_graph",
18-
Description: "Returns the topology of a specific namespaces, health, status of the mesh and namespaces. Use this for high-level overviews",
19-
InputSchema: &jsonschema.Schema{
20-
Type: "object",
21-
Properties: map[string]*jsonschema.Schema{
22-
"namespace": {
23-
Type: "string",
24-
Description: "Optional single namespace to include in the graph (alternative to namespaces)",
25-
},
26-
"namespaces": {
27-
Type: "string",
28-
Description: "Optional comma-separated list of namespaces to include in the graph",
29-
},
30-
"rateInterval": {
31-
Type: "string",
32-
Description: "Rate interval for fetching (e.g., '10m', '5m', '1h'). Default: '60s'",
33-
},
34-
"graphType": {
35-
Type: "string",
36-
Description: "Type of graph to return: 'versionedApp', 'app', 'service', 'workload', 'mesh'. Default: 'versionedApp'",
13+
func initGetMeshGraph(isOpenshift bool) []api.ServerTool {
14+
name := "kiali_get_mesh_graph"
15+
if isOpenshift {
16+
name = "ossm_get_mesh_graph"
17+
}
18+
return []api.ServerTool{
19+
{
20+
Tool: api.Tool{
21+
Name: name,
22+
Description: "Returns the topology of a specific namespaces, health, status of the mesh and namespaces. Use this for high-level overviews",
23+
InputSchema: &jsonschema.Schema{
24+
Type: "object",
25+
Properties: map[string]*jsonschema.Schema{
26+
"namespace": {
27+
Type: "string",
28+
Description: "Optional single namespace to include in the graph (alternative to namespaces)",
29+
},
30+
"namespaces": {
31+
Type: "string",
32+
Description: "Optional comma-separated list of namespaces to include in the graph",
33+
},
34+
"rateInterval": {
35+
Type: "string",
36+
Description: "Rate interval for fetching (e.g., '10m', '5m', '1h'). Default: '60s'",
37+
},
38+
"graphType": {
39+
Type: "string",
40+
Description: "Type of graph to return: 'versionedApp', 'app', 'service', 'workload', 'mesh'. Default: 'versionedApp'",
41+
},
3742
},
43+
Required: []string{},
44+
},
45+
Annotations: api.ToolAnnotations{
46+
Title: "Topology: Mesh, Graph, Health, and Status",
47+
ReadOnlyHint: ptr.To(true),
48+
DestructiveHint: ptr.To(false),
49+
IdempotentHint: ptr.To(false),
50+
OpenWorldHint: ptr.To(true),
3851
},
39-
Required: []string{},
40-
},
41-
Annotations: api.ToolAnnotations{
42-
Title: "Topology: Mesh, Graph, Health, and Status",
43-
ReadOnlyHint: ptr.To(true),
44-
DestructiveHint: ptr.To(false),
45-
IdempotentHint: ptr.To(false),
46-
OpenWorldHint: ptr.To(true),
47-
},
48-
}, Handler: getMeshGraphHandler,
49-
})
50-
return ret
52+
}, Handler: getMeshGraphHandler,
53+
},
54+
}
5155
}
5256

5357
func getMeshGraphHandler(params api.ToolHandlerParams) (*api.ToolCallResult, error) {

pkg/toolsets/kiali/get_metrics.go

Lines changed: 73 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -32,75 +32,82 @@ var opsMap = map[string]resourceOperations{
3232
},
3333
}
3434

35-
func initGetMetrics() []api.ServerTool {
36-
ret := make([]api.ServerTool, 0)
35+
func initGetMetrics(isOpenshift bool) []api.ServerTool {
36+
name := "kiali_get_metrics"
37+
if isOpenshift {
38+
name = "ossm_get_metrics"
39+
}
40+
desc := "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh"
41+
if isOpenshift {
42+
desc = strings.ReplaceAll(desc, "Kubernetes", "Openshift")
43+
}
3744

38-
ret = append(ret, api.ServerTool{
39-
Tool: api.Tool{
40-
Name: "kiali_get_metrics",
41-
Description: "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
42-
InputSchema: &jsonschema.Schema{
43-
Type: "object",
44-
Properties: map[string]*jsonschema.Schema{
45-
"resource_type": {
46-
Type: "string",
47-
Description: "Type of resource to get details for (service, workload)",
48-
Enum: []any{"service", "workload"},
49-
},
50-
"namespace": {
51-
Type: "string",
52-
Description: "Namespace to get resources from",
53-
},
54-
"resource_name": {
55-
Type: "string",
56-
Description: "Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).",
57-
},
58-
"duration": {
59-
Type: "string",
60-
Description: "Time range to get metrics for (optional string - if provided, gets metrics; if empty, get default 1800s).",
61-
},
62-
"step": {
63-
Type: "string",
64-
Description: "Step between data points in seconds (e.g., '15'). Optional, defaults to 15 seconds",
65-
},
66-
"rateInterval": {
67-
Type: "string",
68-
Description: "Rate interval for metrics (e.g., '1m', '5m'). Optional, defaults to '1m'",
69-
},
70-
"direction": {
71-
Type: "string",
72-
Description: "Traffic direction: 'inbound' or 'outbound'. Optional, defaults to 'outbound'",
73-
},
74-
"reporter": {
75-
Type: "string",
76-
Description: "Metrics reporter: 'source', 'destination', or 'both'. Optional, defaults to 'source'",
77-
},
78-
"requestProtocol": {
79-
Type: "string",
80-
Description: "Filter by request protocol (e.g., 'http', 'grpc', 'tcp'). Optional",
81-
},
82-
"quantiles": {
83-
Type: "string",
84-
Description: "Comma-separated list of quantiles for histogram metrics (e.g., '0.5,0.95,0.99'). Optional",
85-
},
86-
"byLabels": {
87-
Type: "string",
88-
Description: "Comma-separated list of labels to group metrics by (e.g., 'source_workload,destination_service'). Optional",
45+
return []api.ServerTool{
46+
{
47+
Tool: api.Tool{
48+
Name: name,
49+
Description: desc,
50+
InputSchema: &jsonschema.Schema{
51+
Type: "object",
52+
Properties: map[string]*jsonschema.Schema{
53+
"resource_type": {
54+
Type: "string",
55+
Description: "Type of resource to get details for (service, workload)",
56+
Enum: []any{"service", "workload"},
57+
},
58+
"namespace": {
59+
Type: "string",
60+
Description: "Namespace to get resources from",
61+
},
62+
"resource_name": {
63+
Type: "string",
64+
Description: "Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).",
65+
},
66+
"duration": {
67+
Type: "string",
68+
Description: "Time range to get metrics for (optional string - if provided, gets metrics; if empty, get default 1800s).",
69+
},
70+
"step": {
71+
Type: "string",
72+
Description: "Step between data points in seconds (e.g., '15'). Optional, defaults to 15 seconds",
73+
},
74+
"rateInterval": {
75+
Type: "string",
76+
Description: "Rate interval for metrics (e.g., '1m', '5m'). Optional, defaults to '1m'",
77+
},
78+
"direction": {
79+
Type: "string",
80+
Description: "Traffic direction: 'inbound' or 'outbound'. Optional, defaults to 'outbound'",
81+
},
82+
"reporter": {
83+
Type: "string",
84+
Description: "Metrics reporter: 'source', 'destination', or 'both'. Optional, defaults to 'source'",
85+
},
86+
"requestProtocol": {
87+
Type: "string",
88+
Description: "Filter by request protocol (e.g., 'http', 'grpc', 'tcp'). Optional",
89+
},
90+
"quantiles": {
91+
Type: "string",
92+
Description: "Comma-separated list of quantiles for histogram metrics (e.g., '0.5,0.95,0.99'). Optional",
93+
},
94+
"byLabels": {
95+
Type: "string",
96+
Description: "Comma-separated list of labels to group metrics by (e.g., 'source_workload,destination_service'). Optional",
97+
},
8998
},
99+
Required: []string{"resource_type", "namespace", "resource_name"},
90100
},
91-
Required: []string{"resource_type", "namespace", "resource_name"},
92-
},
93-
Annotations: api.ToolAnnotations{
94-
Title: "Get Metrics for a Resource",
95-
ReadOnlyHint: ptr.To(true),
96-
DestructiveHint: ptr.To(false),
97-
IdempotentHint: ptr.To(true),
98-
OpenWorldHint: ptr.To(true),
99-
},
100-
}, Handler: resourceMetricsHandler,
101-
})
102-
103-
return ret
101+
Annotations: api.ToolAnnotations{
102+
Title: "Get Metrics for a Resource",
103+
ReadOnlyHint: ptr.To(true),
104+
DestructiveHint: ptr.To(false),
105+
IdempotentHint: ptr.To(true),
106+
OpenWorldHint: ptr.To(true),
107+
},
108+
}, Handler: resourceMetricsHandler,
109+
},
110+
}
104111
}
105112

106113
func resourceMetricsHandler(params api.ToolHandlerParams) (*api.ToolCallResult, error) {

pkg/toolsets/kiali/get_resource_details.go

Lines changed: 40 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,49 @@ var listDetailsOpsMap = map[string]listDetailsOperations{
3939
},
4040
}
4141

42-
func initGetResourceDetails() []api.ServerTool {
43-
ret := make([]api.ServerTool, 0)
42+
func initGetResourceDetails(isOpenshift bool) []api.ServerTool {
43+
name := "kiali_get_resource_details"
44+
if isOpenshift {
45+
name = "ossm_get_resource_details"
46+
}
47+
desc := "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh"
48+
if isOpenshift {
49+
desc = strings.ReplaceAll(desc, "Kubernetes", "Openshift")
50+
}
4451

45-
ret = append(ret, api.ServerTool{
46-
Tool: api.Tool{
47-
Name: "kiali_get_resource_details",
48-
Description: "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
49-
InputSchema: &jsonschema.Schema{
50-
Type: "object",
51-
Properties: map[string]*jsonschema.Schema{
52-
"resource_type": {
53-
Type: "string",
54-
Description: "Type of resource to get details for (service, workload)",
55-
Enum: []any{"service", "workload"},
56-
},
57-
"namespaces": {
58-
Type: "string",
59-
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",
60-
},
61-
"resource_name": {
62-
Type: "string",
63-
Description: "Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).",
52+
return []api.ServerTool{
53+
{
54+
Tool: api.Tool{
55+
Name: name,
56+
Description: desc,
57+
InputSchema: &jsonschema.Schema{
58+
Type: "object",
59+
Properties: map[string]*jsonschema.Schema{
60+
"resource_type": {
61+
Type: "string",
62+
Description: "Type of resource to get details for (service, workload)",
63+
Enum: []any{"service", "workload"},
64+
},
65+
"namespaces": {
66+
Type: "string",
67+
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",
68+
},
69+
"resource_name": {
70+
Type: "string",
71+
Description: "Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).",
72+
},
6473
},
6574
},
66-
},
67-
Annotations: api.ToolAnnotations{
68-
Title: "List or Resource Details",
69-
ReadOnlyHint: ptr.To(true),
70-
DestructiveHint: ptr.To(false),
71-
IdempotentHint: ptr.To(true),
72-
OpenWorldHint: ptr.To(true),
73-
},
74-
}, Handler: resourceDetailsHandler,
75-
})
76-
77-
return ret
75+
Annotations: api.ToolAnnotations{
76+
Title: "List or Resource Details",
77+
ReadOnlyHint: ptr.To(true),
78+
DestructiveHint: ptr.To(false),
79+
IdempotentHint: ptr.To(true),
80+
OpenWorldHint: ptr.To(true),
81+
},
82+
}, Handler: resourceDetailsHandler,
83+
},
84+
}
7885
}
7986

8087
func resourceDetailsHandler(params api.ToolHandlerParams) (*api.ToolCallResult, error) {

0 commit comments

Comments
 (0)