UNPKG

msexchange-mcp

Version:

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

53 lines 1.98 kB
import { z } from 'zod'; import accountsConfig from '../config/accountsLoader.js'; import { getGraphClient } from '../graph/graphClient.js'; export const listAttachmentsTool = { name: 'list_attachments', description: 'List all attachments for an email', parameters: z.object({ user_id: z.string().describe('The user ID or email address'), message_id: z.string().describe('The email message 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 client = await getGraphClient(account.email); const response = await client .api(`/users/${account.email}/messages/${params.message_id}/attachments`) .get(); const attachments = response.value.map((att) => ({ id: att.id, name: att.name, contentType: att.contentType, size: att.size, isInline: att.isInline, lastModifiedDateTime: att.lastModifiedDateTime, })); return { content: [ { type: 'text', text: JSON.stringify({ attachments, count: attachments.length, }, null, 2), }, ], }; } catch (error) { return { content: [ { type: 'text', text: `Error listing attachments: ${error instanceof Error ? error.message : 'Unknown error'}`, }, ], }; } }, }; //# sourceMappingURL=listAttachments.js.map