Skip to main content
Glama

create_email_draft

Generate and save an email draft in Outlook, including subject, body, recipient details, and optional file attachments, using file paths specified for attachments.

Instructions

Create an email draft with file path(s) as attachments

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_idYes
attachmentsNo
bodyYes
ccNo
subjectYes
toYes

Implementation Reference

  • The handler function decorated with @mcp.tool that implements the create_email_draft tool. It constructs the email message, handles small and large attachments differently, creates the draft via Microsoft Graph API, and uploads large attachments.
    @mcp.tool
    def create_email_draft(
        account_id: str,
        to: str | list[str],
        subject: str,
        body: str,
        cc: str | list[str] | None = None,
        attachments: str | list[str] | None = None,
    ) -> dict[str, Any]:
        """Create an email draft with file path(s) as attachments"""
        to_list = [to] if isinstance(to, str) else to
    
        message = {
            "subject": subject,
            "body": {"contentType": "Text", "content": body},
            "toRecipients": [{"emailAddress": {"address": addr}} for addr in to_list],
        }
    
        if cc:
            cc_list = [cc] if isinstance(cc, str) else cc
            message["ccRecipients"] = [
                {"emailAddress": {"address": addr}} for addr in cc_list
            ]
    
        small_attachments = []
        large_attachments = []
    
        if attachments:
            # Convert single path to list
            attachment_paths = (
                [attachments] if isinstance(attachments, str) else attachments
            )
            for file_path in attachment_paths:
                path = pl.Path(file_path).expanduser().resolve()
                content_bytes = path.read_bytes()
                att_size = len(content_bytes)
                att_name = path.name
    
                if att_size < 3 * 1024 * 1024:
                    small_attachments.append(
                        {
                            "@odata.type": "#microsoft.graph.fileAttachment",
                            "name": att_name,
                            "contentBytes": base64.b64encode(content_bytes).decode("utf-8"),
                        }
                    )
                else:
                    large_attachments.append(
                        {
                            "name": att_name,
                            "content_bytes": content_bytes,
                            "content_type": "application/octet-stream",
                        }
                    )
    
        if small_attachments:
            message["attachments"] = small_attachments
    
        result = graph.request("POST", "/me/messages", account_id, json=message)
        if not result:
            raise ValueError("Failed to create email draft")
    
        message_id = result["id"]
    
        for att in large_attachments:
            graph.upload_large_mail_attachment(
                message_id,
                att["name"],
                att["content_bytes"],
                account_id,
                att.get("content_type", "application/octet-stream"),
            )
    
        return result
Behavior2/5

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

With no annotations provided, the description carries full burden but only states the basic action. It doesn't disclose behavioral traits like whether this is a mutation (implied by 'create'), what permissions are needed, how drafts are stored, error handling, or rate limits. The mention of 'file path(s) as attachments' hints at input format but lacks depth.

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 zero waste. It's front-loaded with the core action and includes the key detail about attachments, making it appropriately sized for the tool's complexity.

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

Completeness2/5

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

For a mutation tool with 6 parameters, 0% schema coverage, no annotations, and no output schema, the description is incomplete. It lacks details on required inputs, error cases, return values, and how it integrates with sibling tools (e.g., 'send_email' for sending drafts).

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

Parameters2/5

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

Schema description coverage is 0%, so the description must compensate but only mentions 'attachments' parameter semantics. It doesn't explain the purpose of 'account_id', 'to', 'subject', 'body', or 'cc', leaving 5 out of 6 parameters without added meaning beyond the schema titles.

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 clearly states the verb ('create') and resource ('email draft') with the specific capability of adding attachments via file paths. It distinguishes from sibling tools like 'send_email' by focusing on draft creation rather than sending, though it doesn't explicitly contrast with other email-related tools.

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?

No guidance is provided on when to use this tool versus alternatives like 'send_email' or 'reply_to_email'. The description mentions attachments but doesn't specify prerequisites (e.g., whether authentication is required via 'authenticate_account') or constraints (e.g., file path formats).

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/elyxlz/microsoft-mcp'

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