Files
runtime/apps/cli/mcp/tools/move_file.go
zeekay ea80dc3638 feat: Add new Dockerfiles and improve containerization
- Add main Dockerfile for production builds
- Add Dockerfile.runtime for secure code execution
- Add Dockerfile.runtime.fixed with improved configuration
- Include .dockerignore for build optimization
- Add integration documentation and publishing guides
- Update API and CLI components for better runtime support
- Enhance sandbox and container management features
2025-08-16 23:03:39 -05:00

59 lines
2.0 KiB
Go

// Copyright 2025 Hanzo Industries Inc.
// SPDX-License-Identifier: AGPL-3.0
package tools
import (
"context"
"fmt"
"github.com/hanzoai/runtime/cli/apiclient"
"github.com/mark3labs/mcp-go/mcp"
log "github.com/sirupsen/logrus"
)
type MoveFileArgs struct {
Id *string `json:"id,omitempty"`
SourcePath *string `json:"sourcePath,omitempty"`
DestPath *string `json:"destPath,omitempty"`
}
func GetMoveFileTool() mcp.Tool {
return mcp.NewTool("move_file",
mcp.WithDescription("Move or rename a file in the Runtime sandbox."),
mcp.WithString("sourcePath", mcp.Required(), mcp.Description("Source path of the file to move.")),
mcp.WithString("destPath", mcp.Required(), mcp.Description("Destination path where to move the file.")),
mcp.WithString("id", mcp.Required(), mcp.Description("ID of the sandbox to move the file in.")),
)
}
func MoveFile(ctx context.Context, request mcp.CallToolRequest, args MoveFileArgs) (*mcp.CallToolResult, error) {
apiClient, err := apiclient.GetApiClient(nil, runtimeMCPHeaders)
if err != nil {
return &mcp.CallToolResult{IsError: true}, err
}
if args.Id == nil || *args.Id == "" {
return &mcp.CallToolResult{IsError: true}, fmt.Errorf("sandbox ID is required")
}
// Get source and destination paths from request arguments
if args.SourcePath == nil || *args.SourcePath == "" {
return &mcp.CallToolResult{IsError: true}, fmt.Errorf("sourcePath parameter is required")
}
if args.DestPath == nil || *args.DestPath == "" {
return &mcp.CallToolResult{IsError: true}, fmt.Errorf("destPath parameter is required")
}
_, err = apiClient.ToolboxAPI.MoveFile(ctx, *args.Id).Source(*args.SourcePath).Destination(*args.DestPath).Execute()
if err != nil {
return &mcp.CallToolResult{IsError: true}, fmt.Errorf("error moving file: %v", err)
}
log.Infof("Moved file from %s to %s", *args.SourcePath, *args.DestPath)
return mcp.NewToolResultText(fmt.Sprintf("Moved file from %s to %s", *args.SourcePath, *args.DestPath)), nil
}