Skip to main content
Glama

send_email

Send emails through Gmail to manage business communications, track leads, and handle customer outreach as part of revenue operations.

Instructions

Send an email via Gmail. ALWAYS get user approval before calling this.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
bodyYesEmail body content
subjectYesEmail subject line
toYesRecipient email address

Implementation Reference

  • Handler for the 'send_email' MCP tool. Forwards the tool arguments to an external Google Apps Script API endpoint via the shared callAPI helper function with action 'sendEmail'.
    case "send_email": result = await callAPI("sendEmail", args); break;
  • Input schema validation for the 'send_email' tool, defining required parameters: to (string), subject (string), body (string).
    inputSchema: { type: "object", properties: { to: { type: "string", description: "Recipient email address" }, subject: { type: "string", description: "Email subject line" }, body: { type: "string", description: "Email body content" } }, required: ["to", "subject", "body"] }
  • index.js:365-377 (registration)
    Registration of the 'send_email' tool in the MCP server's listTools response, including name, description, and input schema.
    { name: "send_email", description: "Send an email via Gmail. ALWAYS get user approval before calling this.", inputSchema: { type: "object", properties: { to: { type: "string", description: "Recipient email address" }, subject: { type: "string", description: "Email subject line" }, body: { type: "string", description: "Email body content" } }, required: ["to", "subject", "body"] } },
  • Shared helper function used by the 'send_email' handler (and other tools) to make HTTP POST requests to the Google Apps Script backend URL, passing the action ('sendEmail') and arguments as form data, with logging and error handling.
    async function callAPI(action, data = {}) { debugLog('=== API CALL START ==='); debugLog(`Action: ${action}`); debugLog(`Data: ${JSON.stringify(data)}`); try { // Build form-encoded body for POST const formData = new URLSearchParams(); formData.append('action', action); // Add all data fields to form for (const [key, value] of Object.entries(data)) { if (value !== undefined && value !== null) { formData.append(key, value.toString()); } } const formString = formData.toString(); debugLog(`FormData: ${formString}`); debugLog(`API_URL: ${API_URL}`); // Use POST with proper content type const response = await fetch(API_URL, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: formString }); debugLog(`Response status: ${response.status}`); debugLog(`Response ok: ${response.ok}`); if (!response.ok) { debugLog(`Response not OK: ${response.status} ${response.statusText}`); throw new Error(`API request failed: ${response.status} ${response.statusText}`); } const text = await response.text(); debugLog(`Response text length: ${text.length}`); debugLog(`Response text: ${text}`); if (!text) { debugLog('ERROR: Empty response from API'); throw new Error('Empty response from API'); } const parsed = JSON.parse(text); debugLog(`Parsed successfully: ${JSON.stringify(parsed)}`); debugLog('=== API CALL END ==='); return parsed; } catch (error) { debugLog(`ERROR in callAPI: ${error.message}`); debugLog(`ERROR stack: ${error.stack}`); throw error; } }

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/PromptishOperations/mcpSpec'

If you have feedback or need assistance with the MCP directory API, please join our Discord server