move_file
Transfer files or directories from one location to another, or rename them by specifying source and destination paths within allowed filesystem limits.
Instructions
Move or rename files and directories
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| destination | Yes | Destination path | |
| source | Yes | Source path |
Implementation Reference
- src/index.ts:341-370 (handler)The handler function for the 'move_file' tool. Validates source and destination paths, checks if destination exists (throws if it does), ensures the parent directory of destination exists, moves the file using fs.move, and returns a 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-189 (registration)Registration of the 'move_file' tool in the listTools response, including its name, description, and input schema.{ 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'], }, },
- src/index.ts:175-188 (schema)Input schema definition for the 'move_file' tool, specifying source and destination paths as required string properties.inputSchema: { type: 'object', properties: { source: { type: 'string', description: 'Source path', }, destination: { type: 'string', description: 'Destination path', }, }, required: ['source', 'destination'], },