move_file
Move or rename files and directories within allowed paths. Specify source and destination to transfer files between locations or rename them in one operation.
Instructions
Move or rename files and directories. Can move files between directories and rename them in a single operation. Both source and destination must be within allowed directories.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source | Yes | ||
| destination | Yes |
Implementation Reference
- src/tools/filesystem.ts:101-105 (handler)Core implementation of the move_file tool handler. Validates source and destination paths then renames the file using Node.js fs.promises.rename.export async function moveFile(sourcePath: string, destinationPath: string): Promise<void> { const validSourcePath = await validatePath(sourcePath); const validDestPath = await validatePath(destinationPath); await fs.rename(validSourcePath, validDestPath); }
- src/tools/schemas.ts:53-56 (schema)Zod schema defining the input arguments for the move_file tool: source and destination paths.export const MoveFileArgsSchema = z.object({ source: z.string(), destination: z.string(), });
- src/server.ts:164-171 (registration)Tool registration in the listTools handler, specifying name, description, and input schema for move_file.{ name: "move_file", description: "Move or rename files and directories. Can move files between directories " + "and rename them in a single operation. Both source and destination must be " + "within allowed directories.", inputSchema: zodToJsonSchema(MoveFileArgsSchema), },
- src/server.ts:301-307 (handler)Dispatcher case in the CallToolRequest handler that parses arguments, calls the moveFile function, and returns success message.case "move_file": { const parsed = MoveFileArgsSchema.parse(args); await moveFile(parsed.source, parsed.destination); return { content: [{ type: "text", text: `Successfully moved ${parsed.source} to ${parsed.destination}` }], }; }