Skip to main content
Glama

send-email

Send emails from ClaudePost after confirming recipient details, subject, and content. Use this tool to dispatch verified email communications securely.

Instructions

CONFIRMATION STEP: Actually send the email after user confirms the details. Before calling this, first show the email details to the user for confirmation. Required fields: recipients (to), subject, and content. Optional: CC recipients.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
toYesList of recipient email addresses (confirmed)
subjectYesConfirmed email subject
contentYesConfirmed email content
ccNoList of CC recipient email addresses (optional, confirmed)

Implementation Reference

  • Dispatch handler logic within @server.call_tool() that validates arguments and invokes send_email_async for the send-email tool.
    if name == "send-email":
        to_addresses = arguments.get("to", [])
        subject = arguments.get("subject", "")
        content = arguments.get("content", "")
        cc_addresses = arguments.get("cc", [])
        
        if not to_addresses:
            return [types.TextContent(
                type="text",
                text="At least one recipient email address is required."
            )]
        
        try:
            logging.info("Attempting to send email")
            logging.info(f"To: {to_addresses}")
            logging.info(f"Subject: {subject}")
            logging.info(f"CC: {cc_addresses}")
            
            async with asyncio.timeout(SEARCH_TIMEOUT):
                await send_email_async(to_addresses, subject, content, cc_addresses)
                return [types.TextContent(
                    type="text",
                    text="Email sent successfully! Check email_client.log for detailed logs."
                )]
        except asyncio.TimeoutError:
            logging.error("Operation timed out while sending email")
            return [types.TextContent(
                type="text",
                text="Operation timed out while sending email."
            )]
        except Exception as e:
            error_msg = str(e)
            logging.error(f"Failed to send email: {error_msg}")
            return [types.TextContent(
                type="text",
                text=f"Failed to send email: {error_msg}\n\nPlease check:\n1. Email and password are correct in .env\n2. SMTP settings are correct\n3. Less secure app access is enabled (for Gmail)\n4. Using App Password if 2FA is enabled"
            )]
  • Core helper function that constructs and sends the email using SMTP with configuration from EMAIL_CONFIG.
    async def send_email_async(
        to_addresses: list[str],
        subject: str,
        content: str,
        cc_addresses: list[str] | None = None
    ) -> None:
        """Asynchronously send an email."""
        try:
            # Create message
            msg = MIMEMultipart()
            msg['From'] = EMAIL_CONFIG["email"]
            msg['To'] = ', '.join(to_addresses)
            if cc_addresses:
                msg['Cc'] = ', '.join(cc_addresses)
            msg['Subject'] = subject
            
            # Add body
            msg.attach(MIMEText(content, 'plain', 'utf-8'))
            
            # Connect to SMTP server and send email
            def send_sync():
                with smtplib.SMTP(EMAIL_CONFIG["smtp_server"], EMAIL_CONFIG["smtp_port"]) as server:
                    server.set_debuglevel(1)  # Enable debug output
                    logging.debug(f"Connecting to {EMAIL_CONFIG['smtp_server']}:{EMAIL_CONFIG['smtp_port']}")
                    
                    # Start TLS
                    logging.debug("Starting TLS")
                    server.starttls()
                    
                    # Login
                    logging.debug(f"Logging in as {EMAIL_CONFIG['email']}")
                    server.login(EMAIL_CONFIG["email"], EMAIL_CONFIG["password"])
                    
                    # Send email
                    all_recipients = to_addresses + (cc_addresses or [])
                    logging.debug(f"Sending email to: {all_recipients}")
                    result = server.send_message(msg, EMAIL_CONFIG["email"], all_recipients)
                    
                    if result:
                        # send_message returns a dict of failed recipients
                        raise Exception(f"Failed to send to some recipients: {result}")
                    
                    logging.debug("Email sent successfully")
            
            # Run the synchronous send function in the executor
            loop = asyncio.get_event_loop()
            await loop.run_in_executor(None, send_sync)
            
        except Exception as e:
            logging.error(f"Error in send_email_async: {str(e)}")
            raise
  • Registers the send-email tool in the @server.list_tools() handler, including its description and input schema.
    types.Tool(
        name="send-email",
        description="CONFIRMATION STEP: Actually send the email after user confirms the details. Before calling this, first show the email details to the user for confirmation. Required fields: recipients (to), subject, and content. Optional: CC recipients.",
        inputSchema={
            "type": "object",
            "properties": {
                "to": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "List of recipient email addresses (confirmed)",
                },
                "subject": {
                    "type": "string",
                    "description": "Confirmed email subject",
                },
                "content": {
                    "type": "string",
                    "description": "Confirmed email content",
                },
                "cc": {
                    "type": "array",
                    "items": {"type": "string"},
                    "description": "List of CC recipient email addresses (optional, confirmed)",
                },
            },
            "required": ["to", "subject", "content"],
        },
    ),
  • JSON Schema defining the input parameters for the send-email tool: required to, subject, content; optional cc.
        "type": "object",
        "properties": {
            "to": {
                "type": "array",
                "items": {"type": "string"},
                "description": "List of recipient email addresses (confirmed)",
            },
            "subject": {
                "type": "string",
                "description": "Confirmed email subject",
            },
            "content": {
                "type": "string",
                "description": "Confirmed email content",
            },
            "cc": {
                "type": "array",
                "items": {"type": "string"},
                "description": "List of CC recipient email addresses (optional, confirmed)",
            },
        },
        "required": ["to", "subject", "content"],
    },
Behavior3/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. It discloses the confirmation requirement and required/optional fields, which are useful behavioral traits. However, it doesn't mention potential side effects (e.g., email delivery, rate limits, authentication needs), leaving gaps for a mutation tool.

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

Conciseness4/5

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

The description is appropriately sized with three sentences that each serve a purpose: confirmation step, usage guidance, and parameter requirements. It's front-loaded with the most important information (confirmation requirement). Could be slightly more concise by combining sentences.

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?

For a mutation tool with no annotations and no output schema, the description provides good usage guidance but lacks information about behavioral aspects like error conditions, delivery confirmation, or response format. The confirmation requirement is well-documented, but other important context is missing.

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?

Schema description coverage is 100%, so the schema already documents all parameters thoroughly. The description adds minimal value by listing required vs. optional fields, but doesn't provide additional semantic context beyond what's in the schema descriptions (e.g., format of email addresses, content constraints).

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

Purpose5/5

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

The description clearly states the specific action ('send the email') and resource ('email'), distinguishing it from sibling tools like count-daily-emails, get-email-content, and search-emails which are read-only operations. It explicitly mentions the confirmation step, which adds important context about its purpose.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool: 'Actually send the email after user confirms the details. Before calling this, first show the email details to the user for confirmation.' This clearly distinguishes it from alternatives by emphasizing the confirmation requirement, though it doesn't explicitly name sibling tools as alternatives.

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/meyannis/mcpemail'

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