Skip to main content
Glama

move_file

Move or rename files and directories between locations. Handles file transfers and name changes in one operation while ensuring destination paths don't already exist.

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 for the 'move_file' tool. It extracts source and destination paths from arguments, ensures the destination directory exists using fs.mkdir, then performs the move/rename 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}`, }, ], }; }
  • Input schema definition for the 'move_file' tool, specifying source and destination paths as required string properties.
    { 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-262 (registration)
    Registration of all tools including 'move_file' via the TOOLS array returned in the ListToolsRequestSchema handler.
    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