move_file
Move or rename files and directories by specifying source and destination paths to reorganize your filesystem structure.
Instructions
Move or rename files and directories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | Source path | |
| destination | Yes | Destination path |
Implementation Reference
- src/index.ts:341-370 (handler)Handler for the move_file tool: extracts source and destination paths, validates them, checks if destination exists (throws if yes), ensures parent directory exists, moves the file using fs.move, and returns success message.case 'move_file': { const { source, destination } = request.params.arguments as { source: string; destination: string }; validatePath(source); validatePath(destination); // Check if destination exists const destinationExists = await fs.pathExists(destination); if (destinationExists) { throw new McpError( ErrorCode.InvalidRequest, `Destination already exists: ${destination}` ); } // Ensure parent directory of destination exists await fs.ensureDir(path.dirname(destination)); await fs.move(source, destination); return { content: [ { type: 'text', text: `Successfully moved ${source} to ${destination}`, }, ], }; }
- src/index.ts:172-188 (schema)Schema definition for the move_file tool, including name, description, and inputSchema specifying source and destination paths as required strings.{ name: 'move_file', description: 'Move or rename files and directories', inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'Source path', }, destination: { type: 'string', description: 'Destination path', }, }, required: ['source', 'destination'], },