Skip to main content
Glama

get_email_content

Retrieve complete email thread content including full message bodies, attachments, and all conversation history using the Gmail thread ID for comprehensive email analysis and 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
NameRequiredDescriptionDefault
threadIdYesGmail thread ID (get this from search_gmail results)

Implementation Reference

  • Handler for the 'get_email_content' tool. It receives the tool arguments and forwards the request to the callAPI helper function with the action 'getEmailContent', which proxies to a Google Apps Script backend.
    case "get_email_content": result = await callAPI("getEmailContent", args); break;
  • index.js:351-364 (registration)
    Tool registration in the ListTools response, including name, description, and input schema specifying a required 'threadId' string parameter.
    { 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"] } },
  • Input schema for the get_email_content tool, defining the expected arguments.
    inputSchema: { type: "object", properties: { threadId: { type: "string", description: "Gmail thread ID (get this from search_gmail results)" } }, required: ["threadId"] }
  • The callAPI helper function implements the core logic for all proxied tools, including get_email_content. It sends a POST request with form-encoded data to the Google Apps Script URL and returns the parsed JSON response.
    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