Skip to content

Commit 2ec5a01

Browse files
sradcocursoragent
andcommitted
feat(kubevirt): add vm_troubleshoot tool for automated VM diagnostics
Adds a new `vm_troubleshoot` MCP Tool that collects comprehensive diagnostic data for KubeVirt VirtualMachines including VM/VMI status, DataVolume/PVC state, cloud-init configuration, virt-launcher pod state, pod logs, and related events. Key features: - Targeted event collection using field selectors (no namespace-wide scan) - DataVolume/PVC status with StorageClass identification - Cloud-init extraction with sensitive field redaction (passwords, SSH keys) - Only falls back to PVC lookup when DataVolume is genuinely NotFound This tool enables AI assistants to proactively diagnose VM issues such as missing StorageClasses, invalid PVC specs, misconfigured cloud-init, and scheduling constraints without requiring the user to manually inspect resources. Complements the existing vm-troubleshoot Prompt with a proper Tool that LLMs can invoke automatically based on user intent. Signed-off-by: Shirly Radco <sradco@redhat.com> Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 28a4f1e commit 2ec5a01

4 files changed

Lines changed: 1326 additions & 0 deletions

File tree

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,5 +233,34 @@
233233
},
234234
"name": "vm_lifecycle",
235235
"title": "Virtual Machine: Lifecycle"
236+
},
237+
{
238+
"annotations": {
239+
"destructiveHint": false,
240+
"idempotentHint": true,
241+
"openWorldHint": true,
242+
"readOnlyHint": true,
243+
"title": "Virtual Machine: Troubleshoot"
244+
},
245+
"description": "Diagnose KubeVirt VirtualMachine issues by collecting VM status, VMI status, volumes, DataVolume/PVC state, cloud-init configuration, virt-launcher pod state, pod logs, and related events. Returns a structured diagnostic report with root-cause data that goes beyond what alerts provide. Use this tool FIRST whenever a user asks why a VM is not starting, stuck in Provisioning, crashlooping, failing to migrate, or exhibiting unexpected behavior. Identifies issues such as missing StorageClasses, invalid PVC specs, misconfigured cloud-init, and scheduling constraints.",
246+
"inputSchema": {
247+
"properties": {
248+
"name": {
249+
"description": "The name of the VirtualMachine to troubleshoot",
250+
"type": "string"
251+
},
252+
"namespace": {
253+
"description": "The namespace of the VirtualMachine to troubleshoot",
254+
"type": "string"
255+
}
256+
},
257+
"required": [
258+
"namespace",
259+
"name"
260+
],
261+
"type": "object"
262+
},
263+
"name": "vm_troubleshoot",
264+
"title": "Virtual Machine: Troubleshoot"
236265
}
237266
]

pkg/toolsets/kubevirt/toolset.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
vm_create "github.com/containers/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/create"
1111
vm_guestagent "github.com/containers/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/guestagent"
1212
vm_lifecycle "github.com/containers/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/lifecycle"
13+
vm_troubleshoot "github.com/containers/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/troubleshoot"
1314
)
1415

1516
type Toolset struct{}
@@ -30,6 +31,7 @@ func (t *Toolset) GetTools(_ api.Openshift) []api.ServerTool {
3031
vm_create.Tools(),
3132
vm_guestagent.Tools(),
3233
vm_lifecycle.Tools(),
34+
vm_troubleshoot.Tools(),
3335
)
3436
}
3537

0 commit comments

Comments
 (0)