Skip to main content
Glama
ZilongXue

ClaudePost

by ZilongXue

send-email

Send confirmed emails securely using specified recipients, subject, and content. Optionally include CC recipients for efficient email distribution.

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
ccNoList of CC recipient email addresses (optional, confirmed)
contentYesConfirmed email content
subjectYesConfirmed email subject
toYesList of recipient email addresses (confirmed)

Implementation Reference

  • Core handler function that implements the logic to send an email using SMTP with TLS, handling to, cc, subject, and content.
    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
  • Registration of the 'send-email' tool in the list_tools handler, including name, 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"],
        },
    ),
  • Dispatch handler within call_tool that parses arguments, validates, calls send_email_async, and handles responses/errors.
    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"
            )]
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 behavioral traits. However, it doesn't mention other important aspects like authentication needs, rate limits, error handling, or what happens after sending (e.g., success confirmation, delivery status). For a mutation tool with zero annotation coverage, this leaves significant gaps.

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 appropriately sized and front-loaded with the most critical information (confirmation step and required fields). Every sentence earns its place by providing essential workflow guidance and parameter information without redundancy or unnecessary elaboration.

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 this is a mutation tool with no annotations and no output schema, the description should do more. It covers the confirmation workflow and parameter basics adequately, but lacks information about what happens after sending (response format, success indicators, error conditions). For a tool that performs an irreversible action like sending emails, this represents a meaningful gap 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?

Schema description coverage is 100%, so the schema already fully documents all 4 parameters. The description adds minimal value by listing required fields (to, subject, content) and optional CC recipients, but doesn't provide additional semantic context beyond what's in the schema descriptions (e.g., format expectations, constraints). Baseline 3 is appropriate when the schema does the heavy lifting.

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 tool's role in the email workflow.

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: 'after user confirms the details' and 'Before calling this, first show the email details to the user for confirmation.' It clearly establishes a prerequisite workflow step, distinguishing it from alternatives that might send emails without confirmation.

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

Related 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/ZilongXue/claude-post'

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