Initial commit: forge-tools-proxmox — MCP-сервер для Proxmox VE
This commit is contained in:
@@ -0,0 +1,44 @@
|
||||
package tools
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/modelcontextprotocol/go-sdk/mcp"
|
||||
)
|
||||
|
||||
// guest.go — взаимодействие с гостем через QEMU guest-agent.
|
||||
// Сознательно ограничено: только guest_ips (read-only обнаружение IP через
|
||||
// agent). Исполнение команд ВНУТРИ гостя (guest_exec) НЕ реализуем —
|
||||
// это зона ssh__run (remote exec), а не гипервизорного домена
|
||||
// (анти-дубликат). QEMU guest-agent работает только для QEMU-ВМ с agent=1.
|
||||
|
||||
func registerGuestTools(s *mcp.Server) {
|
||||
s.AddTool(&mcp.Tool{
|
||||
Name: "guest_ips",
|
||||
Description: "Get guest IP addresses via QEMU guest-agent (requires agent=1 and running VM). Read-only.",
|
||||
InputSchema: schema(map[string]any{
|
||||
"node": strProps("Node name", true),
|
||||
"vmid": strProps("VM ID", true),
|
||||
"host": strProps("Cluster alias (default: primary)", false),
|
||||
}, []string{"node", "vmid"}),
|
||||
}, guestIPsHandler)
|
||||
}
|
||||
|
||||
func guestIPsHandler(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
|
||||
t, err := tenantFor(ctx, req)
|
||||
if err != nil {
|
||||
return errorResult(err.Error()), nil
|
||||
}
|
||||
args := requestArgs(req)
|
||||
node, vmid, host, r := resolveVMArgs(t, args)
|
||||
if r != nil {
|
||||
return r, nil
|
||||
}
|
||||
cctx, cancel := timeout(ctx, t)
|
||||
defer cancel()
|
||||
data, err := t.GuestIPs(cctx, host, node, vmid)
|
||||
if err != nil {
|
||||
return errorResult(err.Error()), nil
|
||||
}
|
||||
return textResult(pretty(data)), nil
|
||||
}
|
||||
Reference in New Issue
Block a user