outlook-mcp/folder/index.js
Seton Carmichael e70840552d feat(outlook-mcp): shared mailbox targeting, discovery, and scopes (v1.1.0)
Add optional mailbox (UPN/SMTP) routing on email/folder/thread tools via
users/{upn}/... and X-AnchorMailbox. New list-mailboxes probes primary,
OUTLOOK_SHARED_MAILBOXES seeds, cache, and candidates. Send supports
mailbox-rooted sendMail and onBehalfOf. MSAL requests Mail.*.Shared;
check-auth-status reports token scp gaps. Docs, env example, tests.
2026-08-24 08:41:05 -04:00

86 lines
2.4 KiB
JavaScript

/**
* Folder management module for Outlook MCP server
*/
const { handleListFolders } = require('./list');
const handleCreateFolder = require('./create');
const handleMoveEmails = require('./move');
const mailboxProp = {
type: "string",
description: "Optional shared/delegated mailbox UPN or SMTP. Omit for the signed-in user's primary mailbox."
};
// Folder management tool definitions
const folderTools = [
{
name: "list-folders",
description: "Lists mail folders in your Outlook account (or a shared mailbox when mailbox is set)",
inputSchema: {
type: "object",
properties: {
includeItemCounts: {
anyOf: [{ type: "boolean" }, { type: "string" }],
description: "Include counts of total and unread items"
},
includeChildren: {
anyOf: [{ type: "boolean" }, { type: "string" }],
description: "Include child folders in hierarchy"
},
mailbox: mailboxProp
},
required: []
},
handler: handleListFolders
},
{
name: "create-folder",
description: "Creates a new mail folder. There is no delete-folder tool — avoid test folders on shared mailboxes.",
inputSchema: {
type: "object",
properties: {
name: {
type: "string",
description: "Name of the folder to create"
},
parentFolder: {
type: "string",
description: "Optional parent folder name (default is root)"
},
mailbox: mailboxProp
},
required: ["name"]
},
handler: handleCreateFolder
},
{
name: "move-emails",
description: "Moves emails from one folder to another within the same mailbox",
inputSchema: {
type: "object",
properties: {
emailIds: {
type: "string",
description: "Comma-separated list of email IDs to move"
},
targetFolder: {
type: "string",
description: "Name of the folder to move emails to"
},
sourceFolder: {
type: "string",
description: "Optional name of the source folder (default is inbox)"
},
mailbox: mailboxProp
},
required: ["emailIds", "targetFolder"]
},
handler: handleMoveEmails
}
];
module.exports = {
folderTools,
handleListFolders,
handleCreateFolder,
handleMoveEmails
};