-
Notifications
You must be signed in to change notification settings - Fork 169
feat(kubevirt): Add basic VM management toolset #386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
9aa2732 to
4eac816
Compare
| } | ||
|
|
||
| // extractDataSourceInfo extracts source information from a DataSource object | ||
| func extractDataSourceInfo(obj *unstructured.Unstructured) string { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to import here the CDI package and use structures from there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only if we really need it tbh, I don't think anything requires it just yet.
a135353 to
24ad072
Compare
This comment was marked as outdated.
This comment was marked as outdated.
@lyarwood +1 from my side on that being nice, the reason we haven't been able to add it there is that we use claude code in the non-interactive setup in |
| } | ||
| } | ||
|
|
||
| type vmParams struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I'd vote to name it as VirtualMachineParams.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was actually thinking of going the other way and reducing this to params as the package already highlights that this is for VMs.
| } | ||
|
|
||
| // createParameters holds parsed input parameters for VM creation | ||
| type createParameters struct { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CreateVirtualMachineParams? Keep it consistent with Params or Parameters.
| } | ||
|
|
||
| // parseCreateParameters parses and validates input parameters | ||
| func parseCreateParameters(params api.ToolHandlerParams) (*createParameters, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest naming it as parseCreateVirtualMachineParams. Even if it's a private function and not exposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, I think parseCreateParameters is enough given the package name context.
|
|
||
| workload := getOptionalString(params, "workload") | ||
| if workload == "" { | ||
| workload = "fedora" // Default to fedora if not specified |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not returning an error as well? This is parameters validation, not a VM specification that can contain defaults.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's optional, if anything getOptionalString should be extended to provide a default.
Introduce a comprehensive gevals testing framework to validate VM lifecycle operations including creation with various configurations (basic, Ubuntu, instancetypes, performance, sizing) and troubleshooting scenarios. This enables automated verification of the KubeVirt toolset's functionality and regression prevention. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
Introduces a new KubeVirt toolset providing virtual machine management capabilities through MCP tools. The vm_create tool generates comprehensive creation plans with pre-creation validation of instance types, preferences, and container disk images, enabling AI assistants to help users create VirtualMachines with appropriate resource configurations. The tool supports: - Workload specification via OS names or container disk URLs - Auto-selection of instance types based on size/performance hints - DataSource integration for common OS images - Comprehensive validation and planning before resource creation Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
Add lifecycle management tools for starting and stopping VirtualMachines. These tools provide simple, single-action operations that prevent destructive workarounds like delete/recreate. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
Add optional autostart parameter to vm_create tool that sets runStrategy to Always instead of Halted, allowing VMs to be created and started in a single operation. Assisted-By: Claude <noreply@anthropic.com> Signed-off-by: Lee Yarwood <lyarwood@redhat.com>
Summary
This PR introduces a comprehensive KubeVirt toolset for the kubernetes-mcp-server, enabling AI agents to create and manage virtual machines through MCP tools with near-perfect
reliability.
New Tools
vm_createCreates VirtualMachines with intelligent parameter handling:
fedora,ubuntu,rhel) or full container disk URLsrunStrategy: Always)Example:
{ "name": "vm_create", "arguments": { "namespace": "my-namespace", "name": "my-vm", "workload": "fedora", "size": "large", "performance": "compute-optimized" } }vm_startStarts halted VirtualMachines by changing runStrategy to Always. Idempotent and safe.
vm_stopStops running VirtualMachines by changing runStrategy to Halted. Idempotent and safe.
vm_troubleshootProvides comprehensive diagnostic guidance for broken VMs:
Key Features
Testing Results
Validated using the gevals (Generative AI Evaluations) framework across 5 different AI agents/models with 6 tasks each:
Agent Performance (Improved Toolset)
Key Achievement: The toolset enables even smaller models like Granite 3.3 8B (which failed all tasks without specialized tools) to achieve perfect success rates.
Design Principles
Implementation Details
A set of
gevalstest result/report documents is available outside of this PR underpkg/toolsets/kubevirt/tests/results/setting out howgevalshas been used to first introduce and then improve the new toolset.