Skip to main content
Glama

mail_create_message

Create email messages with recipients, subject, and body content for sending through macOS Mail application.

Instructions

Create new email message with recipients, subject, and body

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesRecipient email address
subjectYesEmail subject
bodyYesEmail body content
ccNoCC recipient email address (optional)

Implementation Reference

  • The handler logic for the 'mail_create_message' tool. It validates input parameters (to, subject, body, optional cc), constructs an AppleScript command using osascript to create a new outgoing message in the Mail app, executes it, and returns the result or error.
    case 'mail_create_message': try { const to = (args?.to as string) || ''; const subject = (args?.subject as string) || ''; const body = (args?.body as string) || ''; const cc = (args?.cc as string) || ''; if (!to || !subject || !body) { return { content: [ { type: 'text', text: 'Error: to, subject, and body are required', }, ], }; } const command = `osascript -e 'on run argv set toAddress to item 1 of argv set mailSubject to item 2 of argv set mailBody to item 3 of argv set ccAddress to item 4 of argv tell application "Mail" set newMessage to make new outgoing message set subject of newMessage to mailSubject set content of newMessage to mailBody make new to recipient at end of to recipients of newMessage with properties {address:toAddress} if ccAddress is not "" then make new cc recipient at end of cc recipients of newMessage with properties {address:ccAddress} end if return "Message created - Subject: " & subject of newMessage & ", To: " & toAddress end tell end run' -- "${to}" "${subject}" "${body}" "${cc}"`; const { stdout, stderr } = await execAsync(command); if (stderr.trim()) { return { content: [ { type: 'text', text: `Error creating message: ${stderr.trim()}`, }, ], }; } return { content: [ { type: 'text', text: stdout.trim(), }, ], }; } catch (error: any) { return { content: [ { type: 'text', text: `Error executing mail create command: ${error.message}`, }, ], }; }
  • src/index.ts:297-321 (registration)
    Registration of the 'mail_create_message' tool in the ListTools handler, including its name, description, and input schema definition.
    name: 'mail_create_message', description: 'Create new email message with recipients, subject, and body', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient email address', }, subject: { type: 'string', description: 'Email subject', }, body: { type: 'string', description: 'Email body content', }, cc: { type: 'string', description: 'CC recipient email address (optional)', }, }, required: ['to', 'subject', 'body'], }, },
  • Input schema definition for the 'mail_create_message' tool, specifying properties and required fields.
    name: 'mail_create_message', description: 'Create new email message with recipients, subject, and body', inputSchema: { type: 'object', properties: { to: { type: 'string', description: 'Recipient email address', }, subject: { type: 'string', description: 'Email subject', }, body: { type: 'string', description: 'Email body content', }, cc: { type: 'string', description: 'CC recipient email address (optional)', }, }, required: ['to', 'subject', 'body'], }, },

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/samicokar/mcp-mac'

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