UNPKG

msexchange-mcp

Version:

MCP server for Microsoft Exchange/Outlook email operations via Microsoft Graph API

57 lines (53 loc) 2.05 kB
import { z } from 'zod'; import { MailService } from '../mail/mailService.js'; import accountsConfig from '../config/accountsLoader.js'; export const moveEmailTool = { name: 'move_email', description: `Move an email to a different folder. Common use cases: - Archive processed emails - Organize emails into project folders - Move spam to junk folder - File emails by client or category Steps: 1. Use list_folders to find destination folder ID 2. Use this tool with the email ID and destination folder ID Example workflow: 1. list_folders to see available folders 2. move_email with destination_folder_id from step 1 Note: Moving is permanent - the email is removed from its current folder.`, parameters: z.object({ user_id: z.string().describe('The user ID or email address'), message_id: z.string().describe('The email message ID'), destination_folder_id: z.string().describe('The destination folder ID'), }), execute: async (params) => { try { const account = accountsConfig.accounts.find(acc => acc.id === params.user_id || acc.email === params.user_id); if (!account) { throw new Error(`User not found: ${params.user_id}`); } const mailService = new MailService(account.email); const movedEmail = await mailService.moveEmail(params.message_id, params.destination_folder_id); return { content: [ { type: 'text', text: `Email moved successfully. New location: ${movedEmail.parentFolderId}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error moving email: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }, }; //# sourceMappingURL=moveEmail.js.map