Skip to main content
Glama

google_gmail_delete_email

Delete or move Gmail emails to trash using the message ID; choose permanent deletion or temporary removal to declutter your inbox effectively.

Instructions

Delete or trash an email

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
messageIdYesID of the email to delete
permanentlyNoWhether to permanently delete or move to trash

Implementation Reference

  • The core handler function that executes the tool logic: validates arguments and calls the Gmail service to delete the email.
    export async function handleGmailDeleteEmail( args: any, googleGmailInstance: GoogleGmail ) { if (!isDeleteEmailArgs(args)) { throw new Error("Invalid arguments for google_gmail_delete_email"); } const { messageId, permanently } = args; const result = await googleGmailInstance.deleteEmail(messageId, permanently); return { content: [{ type: "text", text: result }], isError: false, }; }
  • The switch case in the main server request handler that routes the tool call to the specific Gmail delete handler.
    case "google_gmail_delete_email": return await gmailHandlers.handleGmailDeleteEmail( args, googleGmailInstance );
  • Tool definition including name, description, and input schema for validation.
    export const DELETE_EMAIL_TOOL: Tool = { name: "google_gmail_delete_email", description: "Delete or trash an email", inputSchema: { type: "object", properties: { messageId: { type: "string", description: "ID of the email to delete", }, permanently: { type: "boolean", description: "Whether to permanently delete or move to trash", }, }, required: ["messageId"], }, };
  • Argument validation type guard function used by the handler.
    export function isDeleteEmailArgs(args: any): args is { messageId: string; permanently?: boolean; } { return ( args && typeof args.messageId === "string" && (args.permanently === undefined || typeof args.permanently === "boolean") ); }
  • tools/index.ts:3-15 (registration)
    Includes Gmail tools (containing delete_email tool) in the central tools export used by the MCP server.
    import { gmailTools } from "./gmail/index"; import { driveTools } from "./drive/index"; import { tasksTools } from "./tasks/index"; const tools = [ // OAuth tools ...oauthTools, // Calendar tools ...calendarTools, // Gmail tools ...gmailTools,

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