delete_file
Remove a file or folder from Proton Drive by specifying its path. Use this tool to manage and organize your Proton Drive storage effectively.
Instructions
Delete a file or folder from Proton Drive
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes | Path to delete relative to Proton Drive root |
Implementation Reference
- src/index.ts:362-388 (handler)The handler for the 'delete_file' tool. Validates the path, determines if it's a file or directory, deletes using unlink for files or rm (recursive) for directories, and returns a success message or throws an error.case 'delete_file': { const deletePath = validatePath(args?.path as string); try { const stats = await stat(deletePath); if (stats.isDirectory()) { await rm(deletePath, { recursive: true, force: true }); } else { await unlink(deletePath); } return { content: [ { type: 'text', text: `Successfully deleted: ${getRelativePath(deletePath)}`, }, ], }; } catch (error: any) { throw new McpError( ErrorCode.InternalError, `Cannot delete: ${error.message}` ); } }
- src/index.ts:177-190 (registration)Registration of the 'delete_file' tool in the list_tools response, including name, description, and input schema requiring a 'path' parameter.{ name: 'delete_file', description: 'Delete a file or folder from Proton Drive', inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to delete relative to Proton Drive root' }, }, required: ['path'], }, },
- src/index.ts:180-189 (schema)Input schema for the 'delete_file' tool, defining an object with a required 'path' string property.inputSchema: { type: 'object', properties: { path: { type: 'string', description: 'Path to delete relative to Proton Drive root' }, }, required: ['path'], },
- src/index.ts:91-111 (helper)Helper function validatePath used by delete_file to ensure the path is within the Proton Drive directory and secure.function validatePath(relativePath: string): string { // Handle empty path if (!relativePath) { return PROTON_DRIVE_PATH; } // Clean the path - remove leading slashes and normalize const cleaned = relativePath .split(/[/\\]+/) .filter(Boolean) .join(sep); const fullPath = resolve(PROTON_DRIVE_PATH, cleaned); // Security check - ensure we're still within Proton Drive if (!fullPath.startsWith(PROTON_DRIVE_PATH)) { throw new Error('Invalid path: Access denied outside Proton Drive'); } return fullPath; }