google_gmail_send_email
Send emails directly via Gmail by specifying recipients, subject, and content. Supports CC, BCC, and HTML formatting for efficient and customizable email communication.
Instructions
Send a new email
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bcc | No | BCC recipients email addresses | |
| body | Yes | Email body content (can be plain text or HTML) | |
| cc | No | CC recipients email addresses | |
| isHtml | No | Whether the body contains HTML | |
| subject | Yes | Email subject | |
| to | Yes | Recipients email addresses |
Implementation Reference
- handlers/gmail.ts:95-116 (handler)The handler function that performs input validation and executes the email sending logic by calling the GoogleGmail service instance.export async function handleGmailSendEmail( args: any, googleGmailInstance: GoogleGmail ) { if (!isSendEmailArgs(args)) { throw new Error("Invalid arguments for google_gmail_send_email"); } const { to, subject, body, cc, bcc, isHtml, attachments } = args; const result = await googleGmailInstance.sendEmail( to, subject, body, cc, bcc, isHtml, attachments ); return { content: [{ type: "text", text: result }], isError: false, }; }
- tools/gmail/index.ts:75-142 (schema)The MCP tool definition including the input schema (JSON Schema) for validating tool arguments.export const SEND_EMAIL_TOOL: Tool = { name: "google_gmail_send_email", description: "Send a new email", inputSchema: { type: "object", properties: { to: { type: "array", items: { type: "string" }, description: "Recipients email addresses", }, subject: { type: "string", description: "Email subject", }, body: { type: "string", description: "Email body content (can be plain text or HTML)", }, cc: { type: "array", items: { type: "string" }, description: "CC recipients email addresses", }, bcc: { type: "array", items: { type: "string" }, description: "BCC recipients email addresses", }, isHtml: { type: "boolean", description: "Whether the body contains HTML", }, attachments: { type: "array", items: { type: "object", properties: { filePath: { type: "string", description: "Local file path to attach (e.g., '/Users/username/Documents/file.pdf')", }, driveFileId: { type: "string", description: "Google Drive file ID to attach (alternative to filePath)", }, filename: { type: "string", description: "Custom filename for the attachment (optional, will use original filename if not provided)", }, mimeType: { type: "string", description: "MIME type of the attachment (optional, will be auto-detected)", }, }, oneOf: [{ required: ["filePath"] }, { required: ["driveFileId"] }], }, description: "Array of attachments to include with the email. Provide either filePath for local files or driveFileId for Google Drive files.", }, }, required: ["to", "subject", "body"], }, };
- server-setup.ts:154-158 (registration)Switch case in the central tool dispatcher that registers and routes calls to the specific Gmail send email handler.case "google_gmail_send_email": return await gmailHandlers.handleGmailSendEmail( args, googleGmailInstance );
- utils/helper.ts:161-185 (schema)Type guard function used in the handler for runtime input validation, matching the tool's input schema.export function isSendEmailArgs(args: any): args is { to: string[]; subject: string; body: string; cc?: string[]; bcc?: string[]; isHtml?: boolean; attachments?: Array<{ filePath?: string; driveFileId?: string; filename?: string; mimeType?: string; }>; } { return ( typeof args === "object" && Array.isArray(args.to) && typeof args.subject === "string" && typeof args.body === "string" && (args.cc === undefined || Array.isArray(args.cc)) && (args.bcc === undefined || Array.isArray(args.bcc)) && (args.isHtml === undefined || typeof args.isHtml === "boolean") && (args.attachments === undefined || Array.isArray(args.attachments)) ); }