Skip to main content
Glama
owen-nash

Fastmail MCP Server

by owen-nash

send_draft

Send an existing draft email, moving it to the Sent folder and removing the draft status.

Instructions

Send an existing draft email. The draft must have recipients (to/cc/bcc) and a from address. After sending, the email is moved to the Sent folder and the draft keyword is removed.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailIdYesThe ID of the draft email to send

Implementation Reference

  • The MCP tool handler for 'send_draft'. Extracts emailId from args, validates it, and calls client.sendDraft(emailId). Returns success message with submission ID.
    case 'send_draft': {
      const { emailId } = args as any;
      if (!emailId) {
        throw new McpError(ErrorCode.InvalidParams, 'emailId is required');
      }
    
      const submissionId = await client.sendDraft(emailId);
    
      return {
        content: [
          {
            type: 'text',
            text: `Draft sent successfully. Submission ID: ${submissionId}`,
          },
        ],
      };
    }
  • The JMAP client method that executes the actual send_draft logic. Fetches the draft email, validates it's a draft, checks recipients and from address, resolves the identity, and submits the draft via EmailSubmission/set with onSuccessUpdateEmail to move to Sent folder and remove draft keyword.
    async sendDraft(emailId: string): Promise<string> {
      const session = await this.getSession();
    
      // Fetch the existing email to verify it's a draft
      const getRequest: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/get', {
            accountId: session.accountId,
            ids: [emailId],
            properties: ['id', 'from', 'to', 'cc', 'bcc', 'replyTo', 'keywords'],
          }, 'getEmail']
        ]
      };
    
      const getResponse = await this.makeRequest(getRequest);
      const email = this.getListResult(getResponse, 0)[0];
      if (!email) {
        throw new Error(`Email with ID '${emailId}' not found`);
      }
    
      if (!email.keywords?.$draft) {
        throw new Error('Cannot send a non-draft email');
      }
    
      // Collect all recipients for the envelope
      const allRecipients: { email: string }[] = [
        ...(email.to || []),
        ...(email.cc || []),
        ...(email.bcc || []),
      ];
    
      if (allRecipients.length === 0) {
        throw new Error('Draft has no recipients');
      }
    
      // Determine identity from the email's from field
      const fromEmail = email.from?.[0]?.email;
      if (!fromEmail) {
        throw new Error('Draft has no from address');
      }
    
      const identities = await this.getIdentities();
      const selectedIdentity = identities.find(id => matchesIdentity(id.email, fromEmail));
      if (!selectedIdentity) {
        throw new Error('From address on draft does not match any sending identity');
      }
    
      // Find the Sent mailbox
      const mailboxes = await this.getMailboxes();
      const sentMailbox = this.findMailboxByRoleOrName(mailboxes, 'sent', 'sent');
      if (!sentMailbox) {
        throw new Error('Could not find Sent mailbox');
      }
    
      const sentMailboxIds: Record<string, boolean> = {};
      sentMailboxIds[sentMailbox.id] = true;
    
      // Submit the draft
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail', 'urn:ietf:params:jmap:submission'],
        methodCalls: [
          ['EmailSubmission/set', {
            accountId: session.accountId,
            create: {
              submission: {
                emailId,
                identityId: selectedIdentity.id,
                envelope: {
                  mailFrom: { email: fromEmail },
                  rcptTo: allRecipients.map(addr => ({ email: addr.email })),
                }
              }
            },
            onSuccessUpdateEmail: {
              '#submission': {
                mailboxIds: sentMailboxIds,
                'keywords/$draft': null,
                'keywords/$seen': true,
              }
            }
          }, 'submitDraft']
        ]
      };
    
      const response = await this.makeRequest(request);
      const submissionResult = this.getMethodResult(response, 0);
      if (submissionResult.notCreated?.submission) {
        const err = submissionResult.notCreated.submission;
        throw new Error(`Failed to submit draft: ${err.type}${err.description ? ' - ' + err.description : ''}`);
      }
    
      const submissionId = submissionResult.created?.submission?.id;
      if (!submissionId) {
        throw new Error('Draft submission returned no submission ID');
      }
    
      return submissionId;
    }
  • src/index.ts:402-415 (registration)
    The tool registration and input schema for 'send_draft'. Defines the tool name, description, and input schema requiring emailId.
    {
      name: 'send_draft',
      description: 'Send an existing draft email. The draft must have recipients (to/cc/bcc) and a from address. After sending, the email is moved to the Sent folder and the draft keyword is removed.',
      inputSchema: {
        type: 'object',
        properties: {
          emailId: {
            type: 'string',
            description: 'The ID of the draft email to send',
          },
        },
        required: ['emailId'],
      },
    },
Behavior4/5

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

No annotations provided, so the description carries full burden. It discloses that after sending, the email is moved to Sent folder and draft keyword removed. This covers the key behavioral effects, though error handling is not mentioned.

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?

Two sentences with no wasted words. Front-loaded with the core action, then conditions and aftermath. Efficient and clear.

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

Completeness5/5

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

For a simple tool with one parameter and no output schema, the description covers purpose, prerequisites, and outcome. No gaps remain.

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?

Only one parameter with 100% schema coverage. The description does not add meaning beyond the schema, but the prerequisite conditions indirectly clarify the parameter's context. Baseline 3 is appropriate.

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 verb 'Send' and resource 'existing draft email', distinguishing it from siblings like 'create_draft' and 'send_email'. It also specifies prerequisites (recipients and from address).

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

Usage Guidelines4/5

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

The description provides explicit prerequisites (draft must have recipients and from address), guiding when to use. It does not explicitly name alternatives, but the context from sibling tools implies when not to use (e.g., use 'send_email' for non-drafts).

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/owen-nash/fastmail-mcp'

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