Skip to main content
Glama

move_dir

Destructive

Move files or folders from a source path to a destination path on the MCP server. Simplifies directory management without terminal commands, returning status and path details for the transferred items.

Instructions

Use instead of terminal: Move a file or folder from path1 to path2.

    Args:
        path1: Source path of the file or folder to move
        path2: Destination path where the file or folder will be moved to

    Returns:
        A dictionary containing the status and paths of the moved file or folder

    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
path1No
path2No

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The MoveDirOperation class implements the 'move_dir' tool logic. It defines the tool name, validates paths within the root directory, checks existence, creates parent dirs if needed, and moves using shutil.move. The __call__ method is the entrypoint invoked by the MCP server.
    @dataclass(unsafe_hash=True, slots=True)
    class MoveDirOperation(AsyncOperation):
        """Class to move a file or folder in the workspace."""
    
        name = "move_dir"
    
        def _move_folder(self, path1: str, path2: str) -> None:
            """Move a file or folder from path1 to path2.
    
            Args:
                path1: Source path
                path2: Destination path
    
            Raises:
                FileNotFoundError: If the source path does not exist
                FileExistsError: If the destination path already exists
    
            """
            root_path = self._root_path
            abs_path1 = self._validate_path_in_root(root_path, path1)
            abs_path2 = self._validate_path_in_root(root_path, path2)
    
            # Check if source exists
            source_path = Path(abs_path1)
            if not source_path.exists():
                raise FileNotFoundError(f"Source path does not exist: {path1}")
    
            # Check if destination exists
            dest_path = Path(abs_path2)
            if dest_path.exists():
                raise FileExistsError(f"Destination path already exists: {path2}")
    
            # Create parent directories of destination if they don't exist
            dest_path.parent.mkdir(parents=True, exist_ok=True)
    
            # Move the file or folder
            shutil.move(str(source_path), str(dest_path))
    
        async def __call__(self, path1: str = None, path2: str = None) -> Dict[str, Any]:
            """Move a file or folder from path1 to path2.
    
            Args:
                path1: Source path of the file or folder to move
                path2: Destination path where the file or folder will be moved to
    
            Returns:
                A dictionary containing the status and paths of the moved file or folder
    
            """
            # Handle both model and direct path input for backward compatibility
    
            self._move_folder(path1, path2)
            return {
                "status": "success",
                "message": f"Successfully moved from {path1} to {path2}",
                "path1": path1,
                "path2": path2,
            }
  • ToolFactory is instantiated and invoked with the 'dev_kit_mcp_server.tools' module, which transitively includes MoveDirOperation from file_sys.move, registering the 'move_dir' tool with the FastMCP server.
    # Register all tools
    tool_factory = ToolFactory(fastmcp)
    tool_factory(["dev_kit_mcp_server.tools"], root_dir=root_dir, commands_toml=commands_toml)
    return fastmcp
  • In _decorate_function, for each operation like MoveDirOperation, a Tool is created from its __call__ and name, then registered to the MCP server via add_fast_tool. This is where 'move_dir' gets registered.
    tool = self.create_tool(func)
    self.mcp.add_fast_tool(
        tool=tool,
    )
  • Private helper method in MoveDirOperation that performs path validation, existence checks, directory creation, and the actual shutil.move operation.
    def _move_folder(self, path1: str, path2: str) -> None:
        """Move a file or folder from path1 to path2.
    
        Args:
            path1: Source path
            path2: Destination path
    
        Raises:
            FileNotFoundError: If the source path does not exist
            FileExistsError: If the destination path already exists
    
        """
        root_path = self._root_path
        abs_path1 = self._validate_path_in_root(root_path, path1)
        abs_path2 = self._validate_path_in_root(root_path, path2)
    
        # Check if source exists
        source_path = Path(abs_path1)
        if not source_path.exists():
            raise FileNotFoundError(f"Source path does not exist: {path1}")
    
        # Check if destination exists
        dest_path = Path(abs_path2)
        if dest_path.exists():
            raise FileExistsError(f"Destination path already exists: {path2}")
    
        # Create parent directories of destination if they don't exist
        dest_path.parent.mkdir(parents=True, exist_ok=True)
    
        # Move the file or folder
        shutil.move(str(source_path), str(dest_path))
Behavior3/5

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

Annotations provide destructiveHint=true, indicating this is a mutation operation. The description adds that it moves files/folders, which implies destructive behavior, but doesn't elaborate on permissions needed, error handling, or rate limits. It doesn't contradict annotations, and adds minimal context beyond them, such as the return format, but could be more informative.

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 structured with a brief introductory sentence followed by Args and Returns sections, making it easy to parse. It's front-loaded with the main purpose. However, the formatting includes extra whitespace, and some sentences could be more tightly written, but overall it's efficient and well-organized.

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 has 2 parameters with 0% schema coverage, annotations for destructive behavior, and an output schema, the description does a good job. It explains the parameters, mentions the return type, and aligns with annotations. For a move operation, it's reasonably complete, though it could add more on error cases or usage constraints.

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

Parameters4/5

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

Schema description coverage is 0%, so the description carries the full burden. It clearly defines path1 as the source path and path2 as the destination path, adding semantic meaning beyond the schema's generic titles. This compensates well for the lack of schema descriptions, though it doesn't detail path formats or constraints.

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 verb 'move' and the resource 'a file or folder', specifying it moves from one path to another. It distinguishes from siblings like 'rename_file' by focusing on moving rather than renaming, though it doesn't explicitly contrast with 'create_dir' or 'remove_file'. The purpose is specific but could be more differentiated.

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

Usage Guidelines3/5

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

The description includes 'Use instead of terminal', which provides some context for when to use this tool over manual terminal commands. However, it lacks explicit guidance on when to choose this tool versus sibling tools like 'rename_file' or 'remove_file', and doesn't mention prerequisites or exclusions. Usage is implied but not fully detailed.

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

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/DanielAvdar/dev-kit-mcp-server'

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