Skip to main content
Glama
ggiraudon

Email MCP Server

by ggiraudon

moveMessage

Move email messages between folders by specifying source folder, destination folder, and message ID for organized email management.

Instructions

Moves a message by ID from one folder to another.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
sourceFolderYes
destinationFolderYes
idYes

Implementation Reference

  • The handler function for the 'moveMessage' tool. It validates arguments, gets the IMAP controller instance, connects if needed, moves the message, and returns success.
    export const MoveMessageTool: Tool<any, typeof MoveMessageInput> = {
      name: "moveMessage",
      description: "Moves a message by ID from one folder to another.",
      parameters: MoveMessageInput,
      async execute(args, context) {
        if (!args || typeof args !== 'object'|| !('sourceFolder' in args) || !('destinationFolder' in args) || !('id' in args)) {
          throw new Error("Missing required arguments");
        }
        const controller = ImapControllerFactory.getInstance();
        await controller.connect();
        await controller.moveMessage(args.sourceFolder, args.destinationFolder, args.id);
        return JSON.stringify({ success: true });
      }
    };
  • Zod input schema defining parameters for the moveMessage tool: sourceFolder, destinationFolder, and id.
    export const MoveMessageInput = z.object({
      sourceFolder: z.string().min(2).max(100),
      destinationFolder: z.string().min(2).max(100),
      id: z.number()
    });
  • src/index.ts:53-53 (registration)
    Registration of the MoveMessageTool with the FastMCP server.
    server.addTool(MoveMessageTool);
  • ImapController method implementing the actual message move using node-imap, with fallback to copy-delete if move is not supported.
    moveMessage(sourceFolder: string, destinationFolder: string, uid: number): Promise<void> {
        return new Promise((resolve, reject) => {
            this.imap.openBox(sourceFolder, false, (err: Error | null, box: Imap.Box | null) => {
                if (err) return reject(err);
                // Try to use move if supported, otherwise fallback to copy+delete
                if (typeof this.imap.move === 'function') {
                    (this.imap as any).move(uid, destinationFolder, (err: any) => {
                        if (err) return reject(err);
                        resolve();
                    });
                } else {
                    this.imap.copy(uid, destinationFolder, (err: Error | null) => {
                        if (err) return reject(err);
                        this.imap.addFlags(uid, '\Deleted', (err: Error | null) => {
                            if (err) return reject(err);
                            this.imap.expunge(uid, (err: Error | null) => {
                                if (err) return reject(err);
                                resolve();
                            });
                        });
                    });
                }
            });
        });
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the action ('Moves') but lacks details on permissions required, whether the move is reversible, error handling for invalid inputs, or side effects like updating folder counts. This is a significant gap 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.

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's function without unnecessary words. It is front-loaded and wastes no space, making it easy to parse quickly.

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?

Given the tool's complexity as a mutation operation with 3 required parameters, no annotations, and no output schema, the description is inadequate. It fails to address critical aspects like behavioral traits, error scenarios, or return values, leaving significant gaps for an AI agent to use it correctly.

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 0%, so the schema provides no parameter details. The description implies the parameters ('sourceFolder', 'destinationFolder', 'id') through context but doesn't explain their formats, constraints, or examples. It adds minimal value beyond what the parameter names suggest, meeting the baseline for low coverage.

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 action ('Moves') and the resource ('a message by ID from one folder to another'), making the purpose immediately understandable. It doesn't explicitly differentiate from sibling tools like 'deleteMessage' or 'setFlags', but the verb 'Moves' is specific enough to imply a distinct operation.

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?

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites, such as needing valid folder names or message IDs, nor does it contrast with related tools like 'deleteMessage' for removal or 'setFlags' for modifying message properties without moving.

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/ggiraudon/emailMCPServer'

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