google_drive_delete_file
Remove a file from Google Drive by specifying its ID, with the option to permanently delete it or move it to trash. Simplifies file management within the Google MCP ecosystem.
Instructions
Delete a file from Google Drive
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| fileId | Yes | ID of the file to delete | |
| permanently | No | Whether to permanently delete the file or move it to trash |
Implementation Reference
- handlers/drive.ts:85-98 (handler)The handler function that executes the logic for the 'google_drive_delete_file' tool. It validates the input arguments using isDeleteFileArgs and calls the GoogleDrive instance's deleteFile method.export async function handleDriveDeleteFile( args: any, googleDriveInstance: GoogleDrive ) { if (!isDeleteFileArgs(args)) { throw new Error("Invalid arguments for google_drive_delete_file"); } const { fileId, permanently } = args; const result = await googleDriveInstance.deleteFile(fileId, permanently); return { content: [{ type: "text", text: result }], isError: false, }; }
- tools/drive/index.ts:98-116 (schema)The Tool object definition for 'google_drive_delete_file', including the input schema for validation.export const DELETE_FILE_TOOL: Tool = { name: "google_drive_delete_file", description: "Delete a file from Google Drive", inputSchema: { type: "object", properties: { fileId: { type: "string", description: "ID of the file to delete", }, permanently: { type: "boolean", description: "Whether to permanently delete the file or move it to trash", }, }, required: ["fileId"], }, };
- server-setup.ts:201-205 (registration)Switch case in the tool call handler that registers and routes 'google_drive_delete_file' calls to the appropriate handler function.case "google_drive_delete_file": return await driveHandlers.handleDriveDeleteFile( args, googleDriveInstance );
- utils/helper.ts:287-296 (helper)Type guard function used in the handler to validate arguments for 'google_drive_delete_file'.export function isDeleteFileArgs(args: any): args is { fileId: string; permanently?: boolean; } { return ( args && typeof args.fileId === "string" && (args.permanently === undefined || typeof args.permanently === "boolean") ); }