w
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import { z } from "zod/v4";
|
||||
import { EwsClient, loadConfig } from "../ews_client.ts";
|
||||
import { type McpServer } from "@modelcontextprotocol/server";
|
||||
|
||||
export function registerFolderTools(server: McpServer): void {
|
||||
server.registerTool(
|
||||
"get_folders",
|
||||
{
|
||||
description: "List mail folders from the Exchange mailbox",
|
||||
inputSchema: z.object({
|
||||
parentFolderId: z.string().default("msgfolderroot").describe("Parent folder to list children of (default: msgfolderroot)"),
|
||||
recursive: z.boolean().default(false).describe("If True, traverse all subfolders recursively"),
|
||||
}),
|
||||
},
|
||||
async ({ parentFolderId, recursive }) => {
|
||||
try {
|
||||
const client = new EwsClient(loadConfig());
|
||||
const folders = await client.findFolders(parentFolderId, recursive);
|
||||
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify(folders) }],
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify({ error: error.message ?? String(error) }) }],
|
||||
};
|
||||
}
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user