get_email_content
Retrieve complete email thread content including body text, attachments, and all messages using a Gmail thread ID for revenue tracking and business management.
Instructions
Get full content of an email thread by ID. Returns complete email body, attachments info, and all messages in the thread.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| threadId | Yes | Gmail thread ID (get this from search_gmail results) |
Implementation Reference
- index.js:682-684 (handler)Handler case for the 'get_email_content' MCP tool. Delegates execution to the shared callAPI function, passing 'getEmailContent' action and input arguments.case "get_email_content": result = await callAPI("getEmailContent", args); break;
- index.js:354-363 (schema)Input schema definition for the 'get_email_content' tool, specifying required 'threadId' parameter.inputSchema: { type: "object", properties: { threadId: { type: "string", description: "Gmail thread ID (get this from search_gmail results)" } }, required: ["threadId"] }
- index.js:351-364 (registration)Tool registration object for 'get_email_content' in the ListTools response, including name, description, and input schema.{ name: "get_email_content", description: "Get full content of an email thread by ID. Returns complete email body, attachments info, and all messages in the thread.", inputSchema: { type: "object", properties: { threadId: { type: "string", description: "Gmail thread ID (get this from search_gmail results)" } }, required: ["threadId"] } },
- index.js:74-131 (helper)Shared helper function callAPI that all proxied tools (including get_email_content) use to forward requests to the backend Google Apps Script API at the configured URL.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; } }