move_file
Move a file to a new location within the allowed file operations root directory. Specify the source and destination paths.
Instructions
Move a file from source_path to destination_path inside MCP_FILE_OPS_ROOT.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| source_path | Yes | ||
| destination_path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |
Implementation Reference
- server.py:119-130 (handler)The core handler function for the 'move_file' tool. It resolves source/destination paths within MCP_FILE_OPS_ROOT, validates the source exists, creates parent directories if needed, and uses shutil.move to perform the file move.
@mcp.tool() def move_file(source_path: str, destination_path: str) -> str: """Move a file from source_path to destination_path inside MCP_FILE_OPS_ROOT.""" source = _resolve_file_ops_path(source_path) destination = _resolve_file_ops_path(destination_path) if not source.is_file(): raise ValueError(f"Source file does not exist: {source}") destination.parent.mkdir(parents=True, exist_ok=True) shutil.move(str(source), str(destination)) return f"Moved file from {source} to {destination}" - server.py:119-119 (registration)The @mcp.tool() decorator registers the 'move_file' function as an MCP tool on the FastMCP server instance.
@mcp.tool() - server.py:66-76 (helper)Helper function used by move_file to resolve and validate file system paths, ensuring they stay within the configured MCP_FILE_OPS_ROOT.
def _resolve_file_ops_path(path: str | None = None) -> Path: if not FILE_OPS_ROOT: raise ValueError("MCP_FILE_OPS_ROOT is not configured in .env.") root = Path(FILE_OPS_ROOT).expanduser().resolve() root.mkdir(parents=True, exist_ok=True) target = root if path is None else (root / path).resolve() if target != root and root not in target.parents: raise ValueError("Path escapes the configured MCP_FILE_OPS_ROOT.") return target