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
| Name | Required | Description | Default |
|---|---|---|---|
| messageId | Yes | ID of the email to delete | |
| permanently | No | Whether to permanently delete or move to trash |
Implementation Reference
- handlers/gmail.ts:141-154 (handler)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, }; }
- server-setup.ts:164-168 (registration)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 );
- tools/gmail/index.ts:213-230 (schema)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"], }, };
- utils/helper.ts:213-222 (helper)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,