Skip to main content
Glama
modelcontextprotocol

Filesystem MCP Server

Official

Move File

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

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
contentYes

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 }
        };
      }
    );
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations indicate this is a non-read-only, non-idempotent, non-destructive operation, and the description adds valuable behavioral context beyond that: it specifies that the operation fails if the destination exists, works across directories, and requires both paths to be within allowed directories. This provides practical constraints not covered by annotations, though it doesn't mention error handling details or performance characteristics.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is efficiently structured in three sentences: the first states the core functionality, the second adds key behavioral constraints, and the third specifies access limitations. Every sentence adds essential information without redundancy, making it front-loaded and appropriately sized for the tool's complexity.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's moderate complexity (2 parameters, mutation operation), the description covers purpose, key constraints, and usage context well. With annotations providing safety hints and an output schema presumably handling return values, the description focuses on operational semantics. It could slightly improve by mentioning prerequisites like path existence, but it's largely complete for agent use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the schema provides no parameter documentation. The description compensates by explaining that 'source' and 'destination' refer to file/directory paths and clarifies their roles in moving/renaming operations. However, it doesn't specify path format requirements, validation rules, or examples, leaving some semantic gaps.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the specific action ('move or rename files and directories') and resource ('files and directories'), distinguishing it from siblings like 'create_directory', 'edit_file', or 'write_file' which perform different operations. It explicitly mentions both moving between directories and renaming within the same directory, making the purpose unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context for when to use this tool ('move or rename files and directories', 'across different directories', 'simple renaming within the same directory') and mentions constraints ('both source and destination must be within allowed directories'). However, it doesn't explicitly state when NOT to use it or name specific alternatives like 'write_file' for creating new files or 'edit_file' for modifying content.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

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

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