send_tracked_email
Send emails with read tracking via Gmail to monitor when recipients open messages, including open counts and device information.
Instructions
Send an email with read tracking via Gmail. Body accepts markdown (converted to HTML automatically). The email is sent immediately via Gmail API.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | Yes | Recipient email address | |
| subject | Yes | Email subject | |
| body | Yes | Email body in markdown or HTML | |
| cc | No | CC recipients (comma-separated) | |
| bcc | No | BCC recipients (comma-separated) | |
| html | No | Treat body as raw HTML (skip markdown conversion) |
Implementation Reference
- mcp-server.js:17-60 (handler)The tool "send_tracked_email" is defined and implemented directly within mcp-server.js using server.tool(). It validates inputs using zod, performs markdown-to-HTML conversion, injects a tracking pixel, registers the tracking ID, and sends the email via the imported sendEmail helper.
server.tool( 'send_tracked_email', 'Send an email with read tracking via Gmail. Body accepts markdown (converted to HTML automatically). The email is sent immediately via Gmail API.', { to: z.string().describe('Recipient email address'), subject: z.string().describe('Email subject'), body: z.string().describe('Email body in markdown or HTML'), cc: z.string().optional().describe('CC recipients (comma-separated)'), bcc: z.string().optional().describe('BCC recipients (comma-separated)'), html: z.boolean().default(false).describe('Treat body as raw HTML (skip markdown conversion)'), }, async ({ to, subject, body, cc, bcc, html }) => { if (!isAuthenticated()) { return { content: [{ type: 'text', text: 'Not authenticated. Run `doubletick login` in the terminal first.' }] }; } // Convert body let htmlBody; if (html) { htmlBody = body; } else { htmlBody = await marked(body); if (!htmlBody.includes('<html')) { htmlBody = `<!DOCTYPE html><html><body>${htmlBody}</body></html>`; } } // Inject pixel const trackingId = generateTrackingId(); htmlBody = injectPixel(htmlBody, trackingId); // Register track await registerTrack({ trackingId, recipientEmail: to, emailSubject: subject }); // Send via Gmail API const result = await sendEmail({ to, subject, htmlBody, cc, bcc }); return { content: [{ type: 'text', text: `Email sent and tracking.\n\nTo: ${to}\nSubject: ${subject}\nTracking ID: ${trackingId}\n\nCheck status with check_tracking_status tool.`, }], }; } );