Skip to content

Commit 541997b

Browse files
committed
test(kiali): add toolset schema marshalling verification
Signed-off-by: Marc Nuri <[email protected]>
1 parent 59510a9 commit 541997b

File tree

2 files changed

+286
-0
lines changed

2 files changed

+286
-0
lines changed
Lines changed: 284 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,284 @@
1+
[
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. Use this for high-level overviews",
10+
"inputSchema": {
11+
"type": "object",
12+
"properties": {
13+
"graphType": {
14+
"description": "Type of graph to return: 'versionedApp', 'app', 'service', 'workload', 'mesh'. Default: 'versionedApp'",
15+
"type": "string"
16+
},
17+
"namespace": {
18+
"description": "Optional single namespace to include in the graph (alternative to namespaces)",
19+
"type": "string"
20+
},
21+
"namespaces": {
22+
"description": "Optional comma-separated list of namespaces to include in the graph",
23+
"type": "string"
24+
},
25+
"rateInterval": {
26+
"description": "Rate interval for fetching (e.g., '10m', '5m', '1h'). Default: '60s'",
27+
"type": "string"
28+
}
29+
}
30+
},
31+
"name": "kiali_get_mesh_graph"
32+
},
33+
{
34+
"annotations": {
35+
"title": "Get Metrics for a Resource",
36+
"readOnlyHint": true,
37+
"destructiveHint": false,
38+
"idempotentHint": true,
39+
"openWorldHint": true
40+
},
41+
"description": "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
42+
"inputSchema": {
43+
"type": "object",
44+
"properties": {
45+
"byLabels": {
46+
"description": "Comma-separated list of labels to group metrics by (e.g., 'source_workload,destination_service'). Optional",
47+
"type": "string"
48+
},
49+
"direction": {
50+
"description": "Traffic direction: 'inbound' or 'outbound'. Optional, defaults to 'outbound'",
51+
"type": "string"
52+
},
53+
"duration": {
54+
"description": "Time range to get metrics for (optional string - if provided, gets metrics; if empty, get default 1800s).",
55+
"type": "string"
56+
},
57+
"namespace": {
58+
"description": "Namespace to get resources from",
59+
"type": "string"
60+
},
61+
"quantiles": {
62+
"description": "Comma-separated list of quantiles for histogram metrics (e.g., '0.5,0.95,0.99'). Optional",
63+
"type": "string"
64+
},
65+
"rateInterval": {
66+
"description": "Rate interval for metrics (e.g., '1m', '5m'). Optional, defaults to '1m'",
67+
"type": "string"
68+
},
69+
"reporter": {
70+
"description": "Metrics reporter: 'source', 'destination', or 'both'. Optional, defaults to 'source'",
71+
"type": "string"
72+
},
73+
"requestProtocol": {
74+
"description": "Filter by request protocol (e.g., 'http', 'grpc', 'tcp'). Optional",
75+
"type": "string"
76+
},
77+
"resource_name": {
78+
"description": "Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).",
79+
"type": "string"
80+
},
81+
"resource_type": {
82+
"description": "Type of resource to get details for (service, workload)",
83+
"enum": [
84+
"service",
85+
"workload"
86+
],
87+
"type": "string"
88+
},
89+
"step": {
90+
"description": "Step between data points in seconds (e.g., '15'). Optional, defaults to 15 seconds",
91+
"type": "string"
92+
}
93+
},
94+
"required": [
95+
"resource_type",
96+
"namespace",
97+
"resource_name"
98+
]
99+
},
100+
"name": "kiali_get_metrics"
101+
},
102+
{
103+
"annotations": {
104+
"title": "List or Resource Details",
105+
"readOnlyHint": true,
106+
"destructiveHint": false,
107+
"idempotentHint": true,
108+
"openWorldHint": true
109+
},
110+
"description": "Gets lists or detailed info for Kubernetes resources (services, workloads) within the mesh",
111+
"inputSchema": {
112+
"type": "object",
113+
"properties": {
114+
"namespaces": {
115+
"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",
116+
"type": "string"
117+
},
118+
"resource_name": {
119+
"description": "Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).",
120+
"type": "string"
121+
},
122+
"resource_type": {
123+
"description": "Type of resource to get details for (service, workload)",
124+
"enum": [
125+
"service",
126+
"workload"
127+
],
128+
"type": "string"
129+
}
130+
}
131+
},
132+
"name": "kiali_get_resource_details"
133+
},
134+
{
135+
"annotations": {
136+
"title": "Get Traces for a Resource",
137+
"readOnlyHint": true,
138+
"destructiveHint": false,
139+
"idempotentHint": true,
140+
"openWorldHint": true
141+
},
142+
"description": "Gets traces for a specific resource (app, service, workload) in a namespace",
143+
"inputSchema": {
144+
"type": "object",
145+
"properties": {
146+
"clusterName": {
147+
"description": "Cluster name for multi-cluster environments (optional)",
148+
"type": "string"
149+
},
150+
"endMicros": {
151+
"description": "End time for traces in microseconds since epoch (optional)",
152+
"type": "string"
153+
},
154+
"limit": {
155+
"description": "Maximum number of traces to return (default: 100)",
156+
"minimum": 1,
157+
"type": "integer"
158+
},
159+
"minDuration": {
160+
"description": "Minimum trace duration in microseconds (optional)",
161+
"minimum": 0,
162+
"type": "integer"
163+
},
164+
"namespace": {
165+
"description": "Namespace to get resources from",
166+
"type": "string"
167+
},
168+
"resource_name": {
169+
"description": "Name of the resource to get details for (optional string - if provided, gets details; if empty, lists all).",
170+
"type": "string"
171+
},
172+
"resource_type": {
173+
"description": "Type of resource to get metrics for (app, service, workload)",
174+
"enum": [
175+
"app",
176+
"service",
177+
"workload"
178+
],
179+
"type": "string"
180+
},
181+
"startMicros": {
182+
"description": "Start time for traces in microseconds since epoch (optional)",
183+
"type": "string"
184+
},
185+
"tags": {
186+
"description": "JSON string of tags to filter traces (optional)",
187+
"type": "string"
188+
}
189+
},
190+
"required": [
191+
"resource_type",
192+
"namespace",
193+
"resource_name"
194+
]
195+
},
196+
"name": "kiali_get_traces"
197+
},
198+
{
199+
"annotations": {
200+
"title": "Manage Istio Config: List, Get, Create, Patch, Delete",
201+
"destructiveHint": true,
202+
"idempotentHint": true,
203+
"openWorldHint": true
204+
},
205+
"description": "Manages Istio configuration objects (Gateways, VirtualServices, etc.). Can list (objects and validations), get, create, patch, or delete objects",
206+
"inputSchema": {
207+
"type": "object",
208+
"properties": {
209+
"action": {
210+
"description": "Action to perform: list, get, create, patch, or delete",
211+
"type": "string"
212+
},
213+
"group": {
214+
"description": "API group of the Istio object (e.g., 'networking.istio.io', 'gateway.networking.k8s.io')",
215+
"type": "string"
216+
},
217+
"json_data": {
218+
"description": "JSON data to apply or create the object",
219+
"type": "string"
220+
},
221+
"kind": {
222+
"description": "Kind of the Istio object (e.g., 'DestinationRule', 'VirtualService', 'HTTPRoute', 'Gateway')",
223+
"type": "string"
224+
},
225+
"name": {
226+
"description": "Name of the Istio object",
227+
"type": "string"
228+
},
229+
"namespace": {
230+
"description": "Namespace containing the Istio object",
231+
"type": "string"
232+
},
233+
"version": {
234+
"description": "API version of the Istio object (e.g., 'v1', 'v1beta1')",
235+
"type": "string"
236+
}
237+
},
238+
"required": [
239+
"action"
240+
]
241+
},
242+
"name": "kiali_manage_istio_config"
243+
},
244+
{
245+
"annotations": {
246+
"title": "Workload: Logs",
247+
"readOnlyHint": true,
248+
"destructiveHint": false,
249+
"openWorldHint": true
250+
},
251+
"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.",
252+
"inputSchema": {
253+
"type": "object",
254+
"properties": {
255+
"container": {
256+
"description": "Optional container name to filter logs. If not provided, automatically detects and uses the main application container (excludes istio-proxy and istio-init)",
257+
"type": "string"
258+
},
259+
"namespace": {
260+
"description": "Namespace containing the workload",
261+
"type": "string"
262+
},
263+
"since": {
264+
"description": "Time duration to fetch logs from (e.g., '5m', '1h', '30s'). If not provided, returns recent logs",
265+
"type": "string"
266+
},
267+
"tail": {
268+
"description": "Number of lines to retrieve from the end of logs (default: 100)",
269+
"minimum": 1,
270+
"type": "integer"
271+
},
272+
"workload": {
273+
"description": "Name of the workload to get logs for",
274+
"type": "string"
275+
}
276+
},
277+
"required": [
278+
"namespace",
279+
"workload"
280+
]
281+
},
282+
"name": "workload_logs"
283+
}
284+
]

pkg/mcp/toolsets_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/config"
1313
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/core"
1414
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/helm"
15+
"github.com/containers/kubernetes-mcp-server/pkg/toolsets/kiali"
1516
"github.com/mark3labs/mcp-go/mcp"
1617
"github.com/stretchr/testify/suite"
1718
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
@@ -160,6 +161,7 @@ func (s *ToolsetsSuite) TestGranularToolsetsTools() {
160161
&core.Toolset{},
161162
&config.Toolset{},
162163
&helm.Toolset{},
164+
&kiali.Toolset{},
163165
}
164166
for _, testCase := range testCases {
165167
s.Run("Toolset "+testCase.GetName(), func() {

0 commit comments

Comments
 (0)