Skip to content

Commit a837e06

Browse files
committed
feat: register vm_start, vm_stop, and vm_restart in kubevirt toolset
Update the kubevirt toolset to include the new VM lifecycle management tools. This commit: - Adds imports for vm_start, vm_stop, and vm_restart packages - Registers all three tools in the kubevirt toolset's GetTools() method - Updates test snapshot data to reflect the new tools These tools provide complete VM lifecycle management capabilities through the MCP server, allowing AI assistants to start, stop, and restart KubeVirt VirtualMachines. Code was assisted by Cursor AI
1 parent 3f367c7 commit a837e06

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed

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

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,85 @@
7777
]
7878
},
7979
"name": "vm_create"
80+
},
81+
{
82+
"annotations": {
83+
"title": "Virtual Machine: Restart",
84+
"destructiveHint": false,
85+
"openWorldHint": false
86+
},
87+
"description": "Restart a VirtualMachine using the /restart subresource API",
88+
"inputSchema": {
89+
"type": "object",
90+
"properties": {
91+
"name": {
92+
"description": "The name of the virtual machine to restart",
93+
"type": "string"
94+
},
95+
"namespace": {
96+
"description": "The namespace of the virtual machine",
97+
"type": "string"
98+
}
99+
},
100+
"required": [
101+
"namespace",
102+
"name"
103+
]
104+
},
105+
"name": "vm_restart"
106+
},
107+
{
108+
"annotations": {
109+
"title": "Virtual Machine: Start",
110+
"destructiveHint": false,
111+
"idempotentHint": true,
112+
"openWorldHint": false
113+
},
114+
"description": "Start a halted or stopped VirtualMachine by changing its runStrategy to Always",
115+
"inputSchema": {
116+
"type": "object",
117+
"properties": {
118+
"name": {
119+
"description": "The name of the virtual machine to start",
120+
"type": "string"
121+
},
122+
"namespace": {
123+
"description": "The namespace of the virtual machine",
124+
"type": "string"
125+
}
126+
},
127+
"required": [
128+
"namespace",
129+
"name"
130+
]
131+
},
132+
"name": "vm_start"
133+
},
134+
{
135+
"annotations": {
136+
"title": "Virtual Machine: Stop",
137+
"destructiveHint": false,
138+
"idempotentHint": true,
139+
"openWorldHint": false
140+
},
141+
"description": "Stop a running VirtualMachine by changing its runStrategy to Halted",
142+
"inputSchema": {
143+
"type": "object",
144+
"properties": {
145+
"name": {
146+
"description": "The name of the virtual machine to stop",
147+
"type": "string"
148+
},
149+
"namespace": {
150+
"description": "The namespace of the virtual machine",
151+
"type": "string"
152+
}
153+
},
154+
"required": [
155+
"namespace",
156+
"name"
157+
]
158+
},
159+
"name": "vm_stop"
80160
}
81161
]

pkg/toolsets/kubevirt/toolset.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ import (
77
internalk8s "github.com/containers/kubernetes-mcp-server/pkg/kubernetes"
88
"github.com/containers/kubernetes-mcp-server/pkg/toolsets"
99
vm_create "github.com/containers/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/create"
10+
vm_restart "github.com/containers/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/restart"
11+
vm_start "github.com/containers/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/start"
12+
vm_stop "github.com/containers/kubernetes-mcp-server/pkg/toolsets/kubevirt/vm/stop"
1013
)
1114

1215
type Toolset struct{}
@@ -24,6 +27,9 @@ func (t *Toolset) GetDescription() string {
2427
func (t *Toolset) GetTools(o internalk8s.Openshift) []api.ServerTool {
2528
return slices.Concat(
2629
vm_create.Tools(),
30+
vm_start.Tools(),
31+
vm_stop.Tools(),
32+
vm_restart.Tools(),
2733
)
2834
}
2935

0 commit comments

Comments
 (0)