Skip to main content
Glama

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
NameRequiredDescriptionDefault
fileIdYesID of the file to delete
permanentlyNoWhether to permanently delete the file or move it to trash

Implementation Reference

  • 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,
      };
    }
  • 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"],
      },
    };
  • 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
      );
  • 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")
      );
    }

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/vakharwalad23/google-mcp'

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