Skip to main content
Glama

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
NameRequiredDescriptionDefault
bccNoBCC recipients email addresses
bodyYesEmail body content (can be plain text or HTML)
ccNoCC recipients email addresses
isHtmlNoWhether the body contains HTML
subjectYesEmail subject
toYesRecipients email addresses

Implementation Reference

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

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