Skip to main content
Glama
as-j

Fastmail MCP Server

by as-j

move_email

Idempotent

Move a specific email to a different Fastmail mailbox. Use to file a single message into another mailbox without adding extra labels.

Instructions

Move one email to a different Fastmail mailbox. Use when the user wants a specific message filed into another mailbox. Do not use to add extra labels while keeping the current mailbox membership; use add_labels.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
emailIdYesID of the email to move
targetMailboxIdYesID of the target mailbox

Implementation Reference

  • Handler for the 'move_email' tool. Extracts emailId and targetMailboxId from args, validates them, calls client.moveEmail(), and returns a success message.
    case 'move_email': {
      const { emailId, targetMailboxId } = args as any;
      if (!emailId || !targetMailboxId) throw new McpError(ErrorCode.InvalidParams, 'emailId and targetMailboxId are required');
      await client.moveEmail(emailId, targetMailboxId);
      return { content: [{ type: 'text', text: 'Email moved successfully' }] };
    }
  • JMAP client method that implements the email move operation. Fetches the email's current mailboxIds, builds a JMAP patch (removes from all current mailboxes, adds to target), and sends an Email/set request.
    async moveEmail(emailId: string, targetMailboxId: string): Promise<void> {
      const session = await this.getSession();
    
      // Fetch current mailboxIds to build a proper JMAP patch
      const getRequest: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/get', {
            accountId: session.accountId,
            ids: [emailId],
            properties: ['mailboxIds']
          }, 'getEmail']
        ]
      };
      const getResponse = await this.makeRequest(getRequest);
      const email = this.getListResult(getResponse, 0)[0];
    
      // Build patch: remove from all current mailboxes, add to target
      const patch: Record<string, boolean | null> = {};
      if (email?.mailboxIds) {
        for (const mbId of Object.keys(email.mailboxIds)) {
          patch[`mailboxIds/${mbId}`] = null;
        }
      }
      patch[`mailboxIds/${targetMailboxId}`] = true;
    
      const request: JmapRequest = {
        using: ['urn:ietf:params:jmap:core', 'urn:ietf:params:jmap:mail'],
        methodCalls: [
          ['Email/set', {
            accountId: session.accountId,
            update: {
              [emailId]: patch
            }
          }, 'moveEmail']
        ]
      };
    
      const response = await this.makeRequest(request);
      const result = this.getMethodResult(response, 0);
    
      if (result.notUpdated && result.notUpdated[emailId]) {
        throw new Error('Failed to move email.');
      }
    }
  • Tool definition/schema for 'move_email' including description and input schema with required emailId and targetMailboxId parameters.
    writeTool(
      'move_email',
      'Move Email',
      description(
        'Move one email to a different Fastmail mailbox.',
        'Use when the user wants a specific message filed into another mailbox.',
        'Do not use to add extra labels while keeping the current mailbox membership; use add_labels.',
      ),
      {
        type: 'object',
        properties: {
          emailId: {
            type: 'string',
            description: 'ID of the email to move',
          },
          targetMailboxId: {
            type: 'string',
            description: 'ID of the target mailbox',
          },
        },
        required: ['emailId', 'targetMailboxId'],
      },
      { idempotentHint: true },
    ),
  • Tool registration via ListToolsRequestSchema handler that returns TOOL_DEFINITIONS, which includes the move_email definition.
    server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOL_DEFINITIONS }));
Behavior3/5

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

Annotations already indicate mutation (readOnlyHint=false) and idempotency (idempotentHint=true). Description adds no further behavioral details beyond the obvious move action.

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, purpose first, followed by usage note. No wasted words.

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

Completeness4/5

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

For a simple move operation with two required params, the description sufficiently covers purpose and usage. No output schema, but that's expected. Could mention it only moves one email to distinguish from bulk_move, but it's implied by 'one email'.

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 covers both parameters with full descriptions. Description adds no additional meaning beyond what the schema provides.

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?

Description clearly states 'Move one email to a different Fastmail mailbox' with specific verb and resource, and distinguishes from add_labels by excluding label-only moves.

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?

Explicitly states when to use ('user wants a specific message filed into another mailbox') and when not to use ('not to add labels'), with alternative tool name provided.

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/as-j/fastmail-mcp'

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