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
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | The current path of the file/directory | |
| destination | Yes | The new path for the file/directory |
Implementation Reference
- src/index.ts:408-425 (handler)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}`, }, ], }; }
- src/index.ts:140-157 (schema)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 };