google_gmail_draft_email
Create and manage draft emails directly in Gmail by specifying recipients, subject, body, and optional CC/BCC. Supports plain text or HTML content for efficient email drafting.
Instructions
Create a draft 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:118-139 (handler)The main handler function that executes the tool: validates arguments using isDraftEmailArgs and delegates to GoogleGmail.draftEmailexport async function handleGmailDraftEmail( args: any, googleGmailInstance: GoogleGmail ) { if (!isDraftEmailArgs(args)) { throw new Error("Invalid arguments for google_gmail_draft_email"); } const { to, subject, body, cc, bcc, isHtml, attachments } = args; const result = await googleGmailInstance.draftEmail( to, subject, body, cc, bcc, isHtml, attachments ); return { content: [{ type: "text", text: result }], isError: false, }; }
- tools/gmail/index.ts:144-211 (schema)Input schema definition for the google_gmail_draft_email tool, defining parameters like to, subject, body, attachments etc.export const DRAFT_EMAIL_TOOL: Tool = { name: "google_gmail_draft_email", description: "Create a draft 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:159-163 (registration)Registration/dispatch: switch case in the MCP server request handler that routes 'call tool' requests for this tool name to the gmail handler.case "google_gmail_draft_email": return await gmailHandlers.handleGmailDraftEmail( args, googleGmailInstance );