Skip to main content
Glama

Gmail AutoAuth MCP Server

MIT License
2,386
  • Linux
  • Apple
utl.ts1.63 kB
/** * Helper function to encode email headers containing non-ASCII characters * according to RFC 2047 MIME specification */ function encodeEmailHeader(text: string): string { // Only encode if the text contains non-ASCII characters if (/[^\x00-\x7F]/.test(text)) { // Use MIME Words encoding (RFC 2047) return '=?UTF-8?B?' + Buffer.from(text).toString('base64') + '?='; } return text; } export const validateEmail = (email: string): boolean => { const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; return emailRegex.test(email); }; export function createEmailMessage(validatedArgs: any): string { const encodedSubject = encodeEmailHeader(validatedArgs.subject); (validatedArgs.to as string[]).forEach(email => { if (!validateEmail(email)) { throw new Error(`Recipient email address is invalid: ${email}`); } }); const emailParts = [ 'From: me', `To: ${validatedArgs.to.join(', ')}`, validatedArgs.cc ? `Cc: ${validatedArgs.cc.join(', ')}` : '', validatedArgs.bcc ? `Bcc: ${validatedArgs.bcc.join(', ')}` : '', `Subject: ${encodedSubject}`, // Add thread-related headers if specified validatedArgs.inReplyTo ? `In-Reply-To: ${validatedArgs.inReplyTo}` : '', validatedArgs.inReplyTo ? `References: ${validatedArgs.inReplyTo}` : '', 'MIME-Version: 1.0', 'Content-Type: text/plain; charset=UTF-8', 'Content-Transfer-Encoding: 7bit', ].filter(Boolean); emailParts.push('') emailParts.push(validatedArgs.body); return emailParts.join('\r\n'); }

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/NandiniLReddy/MCP-Gmail-Setup'

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