msexchange-mcp
Version:
MCP server for Microsoft Exchange/Outlook email operations via Microsoft Graph API
47 lines • 1.87 kB
JavaScript
import { z } from 'zod';
import { getGraphClient } from '../graph/graphClient.js';
import accountsConfig from '../config/accountsLoader.js';
export const replyEmailTool = {
name: 'reply_email',
description: 'Reply to 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 to reply to'),
comment: z.string().describe('Reply message content'),
reply_all: z.boolean().default(false).describe('Reply to all recipients'),
}),
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 endpoint = params.reply_all
? `/users/${account.email}/messages/${params.message_id}/replyAll`
: `/users/${account.email}/messages/${params.message_id}/reply`;
await client.api(endpoint).post({
comment: params.comment,
});
return {
content: [
{
type: 'text',
text: `Reply sent successfully${params.reply_all ? ' to all recipients' : ''}.`,
},
],
};
}
catch (error) {
return {
content: [
{
type: 'text',
text: `Error replying to email: ${error instanceof Error ? error.message : 'Unknown error'}`,
},
],
};
}
},
};
//# sourceMappingURL=replyEmail.js.map