Skip to main content
Glama
Preston-Harrison

Filesystem MCP Server

move_file

Move or rename files within allowed directories. Specify source and destination paths to relocate or rename files while maintaining directory restrictions.

Instructions

Move or rename a file from source to destination.

Args: src (str): Source file path (absolute or relative to allowed directories) dst (str): Destination file path (absolute or relative to allowed directories)

Returns: str: Success message with source and destination paths, or error message if failed

Note: - Both paths must be within allowed directory roots - Fails if destination already exists - Creates parent directories for destination if needed

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
srcYes
dstYes

Implementation Reference

  • main.py:258-282 (handler)
    The handler function for the 'move_file' MCP tool, including its @mcp.tool decorator for registration. It resolves source and destination paths, checks if destination exists, creates necessary parent directories, renames/moves the file, and handles errors gracefully.
    @mcp.tool
    def move_file(src: str, dst: str) -> str:
        """Move or rename a file from source to destination.
    
        Args:
            src (str): Source file path (absolute or relative to allowed directories)
            dst (str): Destination file path (absolute or relative to allowed directories)
    
        Returns:
            str: Success message with source and destination paths, or error message if failed
    
        Note:
            - Both paths must be within allowed directory roots
            - Fails if destination already exists
            - Creates parent directories for destination if needed
        """
        try:
            src_p, dst_p = _resolve(src), _resolve(dst)
            if dst_p.exists():
                return f"Error moving file: destination '{dst_p}' already exists"
            dst_p.parent.mkdir(parents=True, exist_ok=True)
            src_p.rename(dst_p)
            return f"Moved {src_p} → {dst_p}"
        except Exception as e:
            return _human_error(e, "moving file")

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/Preston-Harrison/fs-mcp-py'

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