Skip to main content
Glama

move_file

Move or rename files and directories on your PC. Transfer files between folders and rename them in one operation, with safety checks to prevent overwriting existing files.

Instructions

Move or rename files and directories. Can move files between directories and rename them in a single operation. If the destination exists, the operation will fail.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYesThe current path of the file/directory
destinationYesThe new path for the file/directory

Implementation Reference

  • The handler function for the 'move_file' tool. It ensures the destination directory exists using fs.mkdir (recursive), then moves or renames the source to destination using fs.rename, and returns a success message.
    case "move_file": { const source = args.source as string; const destination = args.destination as string; // Ensure destination directory exists const destDir = path.dirname(destination); await fs.mkdir(destDir, { recursive: true }); await fs.rename(source, destination); return { content: [ { type: "text", text: `Successfully moved ${source} to ${destination}`, }, ], }; }
  • The tool definition including name, description, and input schema for 'move_file'. This is part of the TOOLS array used for tool listing.
    { name: "move_file", description: "Move or rename files and directories. Can move files between directories and rename them in a single operation. If the destination exists, the operation will fail.", inputSchema: { type: "object", properties: { source: { type: "string", description: "The current path of the file/directory", }, destination: { type: "string", description: "The new path for the file/directory", }, }, required: ["source", "destination"], }, },
  • src/index.ts:261-263 (registration)
    Registration of the list tools handler which returns the TOOLS array containing the 'move_file' tool definition.
    server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: TOOLS }; });

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/koopatroopa787/first_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server