Skip to main content
Glama
safurrier

MCP Filesystem Server

move_file

Move or rename files and directories by specifying source and destination paths, with optional overwrite protection for existing files.

Instructions

Move or rename files and directories.

Args:
    source: Source path
    destination: Destination path
    overwrite: Whether to overwrite existing destination
    ctx: MCP context

Returns:
    Success or error message

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceYes
destinationYes
overwriteNo

Implementation Reference

  • MCP tool handler for 'move_file'. This is the entry point decorated with @mcp.tool(), handling input parameters, error catching, and delegating to the core operations.move_file method.
    @mcp.tool()
    async def move_file(
        source: str,
        destination: str,
        ctx: Context,
        overwrite: bool = False,
    ) -> str:
        """Move or rename files and directories.
    
        Args:
            source: Source path
            destination: Destination path
            overwrite: Whether to overwrite existing destination
            ctx: MCP context
    
        Returns:
            Success or error message
        """
        try:
            components = get_components()
            await components["operations"].move_file(source, destination, overwrite)
            return f"Successfully moved {source} to {destination}"
        except Exception as e:
            return f"Error moving file: {str(e)}"
  • Core implementation of the move_file logic in FileOperations class. Validates paths using PathValidator, checks existence and overwrite conditions, then performs the move using shutil.move in a thread.
    async def move_file(
        self,
        source: Union[str, Path],
        destination: Union[str, Path],
        overwrite: bool = False,
    ) -> None:
        """Move or rename a file or directory.
    
        Args:
            source: Source path
            destination: Destination path
            overwrite: Whether to overwrite destination if it exists
    
        Raises:
            ValueError: If paths are outside allowed directories
            FileNotFoundError: If source does not exist
            FileExistsError: If destination exists and overwrite is False
        """
        source_path, source_allowed = await self.validator.validate_path(source)
        if not source_allowed:
            raise ValueError(f"Source path outside allowed directories: {source}")
    
        dest_path, dest_allowed = await self.validator.validate_path(destination)
        if not dest_allowed:
            raise ValueError(
                f"Destination path outside allowed directories: {destination}"
            )
    
        # Check if source exists
        if not source_path.exists():
            raise FileNotFoundError(f"Source does not exist: {source}")
    
        # Check if destination exists and we're not overwriting
        if dest_path.exists() and not overwrite:
            raise FileExistsError(f"Destination already exists: {destination}")
    
        try:
            # Use shutil.move which handles cross-filesystem moves
            await anyio.to_thread.run_sync(shutil.move, source_path, dest_path)
        except (PermissionError, shutil.Error) as e:
            raise ValueError(f"Cannot move file: {e}")
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions 'overwrite' behavior but doesn't explain what happens when overwrite=false and destination exists, whether the operation is atomic, if it preserves metadata/permissions, or what specific error messages might be returned. For a file system mutation tool with zero annotation coverage, this leaves significant behavioral gaps.

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

Conciseness4/5

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

The description is appropriately sized with clear sections (purpose, args, returns). The first sentence states the core functionality, followed by parameter documentation. However, the inclusion of 'ctx: MCP context' in the args section seems extraneous since it doesn't appear in the input schema, slightly reducing efficiency.

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

Completeness2/5

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

For a file system mutation tool with 3 parameters, 0% schema coverage, no annotations, and no output schema, the description is insufficient. It doesn't explain error conditions, return value format beyond 'success or error message', path semantics, or how renaming versus moving differs. The mismatch between described parameters (4 including 'ctx') and schema parameters (3) creates confusion.

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?

Schema description coverage is 0%, so the description must compensate. It lists all three parameters with brief explanations, adding meaning beyond the bare schema. However, it doesn't explain path format requirements, what 'ctx' parameter does (appears to be an undocumented fourth parameter in the description), or provide examples. The coverage partially compensates but remains incomplete.

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

Purpose4/5

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

The description clearly states the tool's purpose: 'Move or rename files and directories.' This is a specific verb+resource combination that distinguishes it from siblings like 'copy_file' (if it existed) or 'delete_file'. However, it doesn't explicitly differentiate from similar operations in the sibling list, which includes file manipulation tools like edit_file, write_file, and create_directory.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. With siblings like 'edit_file', 'write_file', and 'create_directory', there's no indication of when moving/renaming is appropriate versus editing content or creating new files. No prerequisites, exclusions, or alternative tools are mentioned.

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/safurrier/mcp-filesystem'

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