Skip to main content
Glama

Send Email

send_email

Send emails through Gmail SMTP by providing recipient address, subject line, and message body content.

Instructions

Send an email using Gmail SMTP

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesRecipient email address
subjectYesEmail subject
bodyYesEmail body content

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
errorNoError message if failed
successYesWhether email was sent successfully
messageIdNoMessage ID from Gmail

Implementation Reference

  • MCP tool handler for 'send_email' that invokes the internal sendEmail function and returns formatted content with structured result.
    async ({ to, subject, body }) => {
      const result = await sendEmail(to, subject, body);
      
      return {
        content: [{
          type: 'text',
          text: result.success 
            ? `Email sent to ${to}. Message ID: ${result.messageId}`
            : `Failed to send email: ${result.error}`
        }],
        structuredContent: result
      };
    }
  • Input schema (to, subject, body with Zod validation) and output schema (success, messageId, error) for the send_email tool.
    inputSchema: {
      to: z.string().email().describe('Recipient email address'),
      subject: z.string().min(1).describe('Email subject'),
      body: z.string().min(1).describe('Email body content')
    },
    outputSchema: {
      success: z.boolean().describe('Whether email was sent successfully'),
      messageId: z.string().optional().describe('Message ID from Gmail'),
      error: z.string().optional().describe('Error message if failed')
    }
  • src/index.ts:54-83 (registration)
    Registration of the 'send_email' tool on the MCP server with schema and handler.
    server.registerTool(
      'send_email',
      {
        title: 'Send Email',
        description: 'Send an email using Gmail SMTP',
        inputSchema: {
          to: z.string().email().describe('Recipient email address'),
          subject: z.string().min(1).describe('Email subject'),
          body: z.string().min(1).describe('Email body content')
        },
        outputSchema: {
          success: z.boolean().describe('Whether email was sent successfully'),
          messageId: z.string().optional().describe('Message ID from Gmail'),
          error: z.string().optional().describe('Error message if failed')
        }
      },
      async ({ to, subject, body }) => {
        const result = await sendEmail(to, subject, body);
        
        return {
          content: [{
            type: 'text',
            text: result.success 
              ? `Email sent to ${to}. Message ID: ${result.messageId}`
              : `Failed to send email: ${result.error}`
          }],
          structuredContent: result
        };
      }
    );
  • Internal helper function that performs the actual email sending using nodemailer and Gmail transporter.
    async function sendEmail(to: string, subject: string, body: string) {
      const transporter = createEmailTransporter();
    
      try {
        const info = await transporter.sendMail({
          from: process.env.GMAIL_USER,
          to,
          subject,
          text: body,
        });
    
        return {
          success: true,
          messageId: info.messageId,
        };
      } catch (error) {
        return {
          success: false,
          error: error instanceof Error ? error.message : 'Unknown error',
        };
      }
    }
  • Helper function to create and configure the nodemailer transporter for Gmail SMTP using environment variables.
    function createEmailTransporter() {
      const user = process.env.GMAIL_USER;
      const pass = process.env.GMAIL_PASS;
    
      if (!user || !pass) {
        throw new Error('Gmail credentials not found. Set GMAIL_USER and GMAIL_PASS environment variables.');
      }
    
      return nodemailer.createTransport({
        service: 'gmail',
        auth: { user, pass },
      });
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states 'Send an email using Gmail SMTP,' which implies a write operation but doesn't cover critical aspects like authentication requirements, error handling, rate limits, or whether it's idempotent. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no wasted words. It's front-loaded with the core action and method, making it easy to scan. Every part of the sentence contributes essential information, earning its place without redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (a mutation with 3 parameters), no annotations, and an output schema present, the description is minimally adequate. It covers the basic purpose but lacks details on behavior, usage context, and error handling. The output schema might provide return values, but the description doesn't hint at this, leaving gaps in completeness.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with clear parameter definitions (to, subject, body). The description doesn't add any semantic details beyond what the schema provides, such as formatting examples or constraints. With high schema coverage, the baseline is 3, as the description doesn't compensate but also doesn't detract.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description 'Send an email using Gmail SMTP' clearly states the action (send) and resource (email), specifying the method (Gmail SMTP). It's specific enough to understand what the tool does, though without sibling tools, differentiation isn't needed. However, it could be more precise about the scope (e.g., whether it's for a single recipient or supports multiple).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives, prerequisites, or contextual constraints. It mentions Gmail SMTP, which implies a specific email service, but doesn't clarify if it's for personal or bulk emails, or if there are rate limits. Without siblings, explicit alternatives aren't required, but usage context is missing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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/PranavMishra28/gmail-mcp'

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