Skip to main content
Glama
modelcontextprotocol

Filesystem MCP Server

Official

move_file

Move or rename files and directories between locations. Specify source and destination paths to transfer files or change names in a single operation.

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. Works across different directories and can be used for simple renaming within the same directory. Both source and destination must be within allowed directories.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYes
destinationYes

Implementation Reference

  • The handler function for the 'move_file' tool. It validates the source and destination paths using validatePath, then uses Node.js fs.rename to perform the move operation. Finally, it returns a success message.
    async (args: z.infer<typeof MoveFileArgsSchema>) => { const validSourcePath = await validatePath(args.source); const validDestPath = await validatePath(args.destination); await fs.rename(validSourcePath, validDestPath); const text = `Successfully moved ${args.source} to ${args.destination}`; const contentBlock = { type: "text" as const, text }; return { content: [contentBlock], structuredContent: { content: text } }; }
  • Zod schema defining the input arguments for the move_file tool: source and destination paths as strings. Used for type inference in the handler.
    const MoveFileArgsSchema = z.object({ source: z.string(), destination: z.string(), });
  • Registration of the 'move_file' tool using server.registerTool, including title, description, inline inputSchema, outputSchema, annotations, and the inline handler function.
    server.registerTool( "move_file", { title: "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. Works across different directories and can be used " + "for simple renaming within the same directory. Both source and destination must be within allowed directories.", inputSchema: { source: z.string(), destination: z.string() }, outputSchema: { content: z.string() }, annotations: { readOnlyHint: false, idempotentHint: false, destructiveHint: false } }, async (args: z.infer<typeof MoveFileArgsSchema>) => { const validSourcePath = await validatePath(args.source); const validDestPath = await validatePath(args.destination); await fs.rename(validSourcePath, validDestPath); const text = `Successfully moved ${args.source} to ${args.destination}`; const contentBlock = { type: "text" as const, text }; return { content: [contentBlock], structuredContent: { content: text } }; } );

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/modelcontextprotocol/filesystem'

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