delete_file
Remove files while enforcing organizational policies on naming conventions, security, and compliance rules before deletion.
Instructions
Delete a file
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | File path |
Implementation Reference
- server.py:192-199 (handler)The handler logic for the 'delete_file' tool within the call_tool function. It resolves the provided path, checks if the file exists, deletes it using path.unlink() if it does, and returns an appropriate success or error message.elif name == "delete_file": path = resolve_path(arguments["path"]) if not path.exists(): return [TextContent(type="text", text=f"Error: File '{arguments['path']}' not found")] path.unlink() return [TextContent(type="text", text=f"✓ File deleted: {arguments['path']}")]
- server.py:112-122 (registration)Registration of the 'delete_file' tool in the list_tools() function, including name, description, and input schema.Tool( name="delete_file", description="Delete a file", inputSchema={ "type": "object", "properties": { "path": {"type": "string", "description": "File path"} }, "required": ["path"] } ),
- server.py:115-121 (schema)Input schema definition for the 'delete_file' tool, specifying the required 'path' parameter.inputSchema={ "type": "object", "properties": { "path": {"type": "string", "description": "File path"} }, "required": ["path"] }
- server.py:135-139 (helper)Helper function used by the delete_file handler (and others) to resolve relative paths to absolute paths within the protected directory, enforcing security.def resolve_path(relative_path: str) -> Path: full_path = (PROTECTED_DIR / relative_path).resolve() if not str(full_path).startswith(str(PROTECTED_DIR)): raise ValueError("Access denied: Path outside protected directory") return full_path