Skip to main content
Glama

rename_file

Destructive

Rename files or folders directly via the dev-kit-mcp-server by specifying the path and new name, simplifying file management without using terminal commands.

Instructions

Use instead of terminal: Rename a file or folder.

    Args:
        path: Path to the file or folder to rename
        new_name: New name for the file or folder (not a full path, just the name)

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

    

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
new_nameNo
pathYes

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • The __call__ method serves as the main handler for the 'rename_file' tool, executing the rename operation and returning a success response.
    async def __call__(self, path: str, new_name: str = None) -> Dict[str, Any]:
        """Rename a file or folder.
    
        Args:
            path: Path to the file or folder to rename
            new_name: New name for the file or folder (not a full path, just the name)
    
        Returns:
            A dictionary containing the status and paths of the renamed file or folder
    
        """
        self._rename_file_or_folder(path, new_name)
        return {
            "status": "success",
            "message": f"Successfully renamed {path} to {new_name}",
            "path": path,
            "new_name": new_name,
        }
  • Helper method that implements the core logic for renaming a file or folder, including validation and the os.rename call.
    def _rename_file_or_folder(self, path: str, new_name: str) -> None:
        """Rename a file or folder.
    
        Args:
            path: Path to the file or folder to rename
            new_name: New name for the file or folder (not a full path, just the name)
    
        Raises:
            FileNotFoundError: If the path does not exist
            FileExistsError: If a file or folder with the new name already exists
    
        """
        root_path = self._root_path
        abs_path = self._validate_path_in_root(root_path, path)
    
        # Check if source exists
        source_path = Path(abs_path)
        if not source_path.exists():
            raise FileNotFoundError(f"Path does not exist: {path}")
    
        # Get the parent directory and create the new path
        parent_dir = source_path.parent
        new_path = parent_dir / new_name
    
        # Check if destination exists
        if new_path.exists():
            raise FileExistsError(f"A file or folder with the name '{new_name}' already exists in the same directory")
    
        # Rename the file or folder
        os.rename(str(source_path), str(new_path))
  • Import statement that registers the RenameOperation class as part of the tools package.
    from .file_sys.rename import RenameOperation
  • Assignment of the tool name 'rename_file' within the RenameOperation class.
    name = "rename_file"
Behavior4/5

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

The annotations provide destructiveHint=true, indicating this is a mutation operation. The description adds valuable context beyond this by specifying that new_name is 'not a full path, just the name' and mentioning the return format. However, it doesn't cover potential error conditions, permissions needed, or system-specific constraints.

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 well-structured with clear sections (Args, Returns) and uses minimal sentences. The 'Use instead of terminal' phrase could be slightly more integrated, but overall it's efficient and front-loaded with the core purpose.

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 destructiveHint annotation, 2 parameters with full semantic coverage in the description, and an output schema (which handles return values), the description is quite complete. It could be improved by mentioning error cases or prerequisites, but it covers the essential context well.

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

Parameters5/5

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

With 0% schema description coverage, the description fully compensates by clearly explaining both parameters: 'path' as 'Path to the file or folder to rename' and 'new_name' as 'New name for the file or folder (not a full path, just the name)'. This adds crucial semantic information not present in the schema.

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 ('Rename a file or folder') and distinguishes it from sibling tools like 'move_dir' (which likely changes location) and 'remove_file' (which deletes). The opening phrase 'Use instead of terminal' provides additional context about its role.

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

Usage Guidelines5/5

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

The description explicitly states 'Use instead of terminal' and distinguishes this tool from command-line alternatives. It also implicitly differentiates from siblings by focusing on renaming (vs. creating, moving, or removing files/folders), though it doesn't name specific alternatives.

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