Skip to main content
Glama

move_file

Move or rename files and directories within allowed paths using a single operation. Ideal for organizing and managing files efficiently on your system with Desktop Commander MCP.

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
NameRequiredDescriptionDefault
destinationYes
sourceYes

Implementation Reference

  • Handler for the 'move_file' tool: parses input arguments using the schema, calls the moveFile helper function, and returns a 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}` }], }; }
  • Zod schema defining the input for move_file tool: source and destination paths as strings.
    export const MoveFileArgsSchema = z.object({ source: z.string(), destination: z.string(), });
  • src/server.ts:164-171 (registration)
    Registers the 'move_file' tool in the MCP server's tool list with name, description, and JSON schema derived from Zod schema.
    { 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), },
  • Core implementation of file move operation: validates paths for security and performs fs.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); }

Other Tools

Related 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/MrGNSS/ClaudeDesktopCommander'

If you have feedback or need assistance with the MCP directory API, please join our Discord server