w
This commit is contained in:
+23
-9
@@ -1,7 +1,7 @@
|
||||
import { type McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
||||
import { z } from "zod/v4";
|
||||
import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { z } from "zod/v4";
|
||||
import { EwsClient, loadConfig } from "../ews_client.ts";
|
||||
|
||||
export function registerCalendarTools(server: McpServer): void {
|
||||
@@ -34,10 +34,13 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
start: item.Start ?? "",
|
||||
end: item.End ?? "",
|
||||
location: item.Location ?? item.EnhancedLocation?.DisplayName ?? "",
|
||||
isAllDay: item.IsAllDayEvent === "true" || item.IsAllDayEvent === true,
|
||||
isCancelled: item.IsCancelled === "true" || item.IsCancelled === true,
|
||||
isAllDay: item.IsAllDayEvent === "true"
|
||||
|| item.IsAllDayEvent === true,
|
||||
isCancelled: item.IsCancelled === "true"
|
||||
|| item.IsCancelled === true,
|
||||
isMeeting: true,
|
||||
isRecurring: item.IsRecurring === "true" || item.IsRecurring === true,
|
||||
isRecurring: item.IsRecurring === "true"
|
||||
|| item.IsRecurring === true,
|
||||
organizer: "",
|
||||
organizerEmail: "",
|
||||
myResponse: item.MyResponseType ?? "",
|
||||
@@ -61,7 +64,10 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
}
|
||||
|
||||
return {
|
||||
content: [{ type: "text" as const, text: JSON.stringify({ events, count: events.length }) }],
|
||||
content: [{
|
||||
type: "text" as const,
|
||||
text: JSON.stringify({ events, count: events.length }),
|
||||
}],
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
@@ -77,9 +83,12 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
server.registerTool(
|
||||
"download_event_attachments",
|
||||
{
|
||||
description: "Download all file attachments from a calendar event to disk",
|
||||
description:
|
||||
"Download all file attachments from a calendar event to disk",
|
||||
inputSchema: z.object({
|
||||
itemId: z.string().describe("The Exchange ItemId of the calendar event"),
|
||||
itemId: z.string().describe(
|
||||
"The Exchange ItemId of the calendar event",
|
||||
),
|
||||
targetFolder: z.string().default("/tmp/attachments").describe(
|
||||
"Local directory to save files (default /tmp/attachments)",
|
||||
),
|
||||
@@ -130,7 +139,9 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
let counter = 1;
|
||||
let finalName = filename;
|
||||
while (usedNames.has(finalName.toLowerCase())) {
|
||||
finalName = extPart ? `${namePart}_${counter}${extPart}` : `${namePart}_${counter}`;
|
||||
finalName = extPart
|
||||
? `${namePart}_${counter}${extPart}`
|
||||
: `${namePart}_${counter}`;
|
||||
counter++;
|
||||
}
|
||||
usedNames.add(finalName.toLowerCase());
|
||||
@@ -145,7 +156,10 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
contentType: result.contentType,
|
||||
});
|
||||
} catch (e: any) {
|
||||
errors.push({ name: att.name || "unknown", error: e.message ?? String(e) });
|
||||
errors.push({
|
||||
name: att.name || "unknown",
|
||||
error: e.message ?? String(e),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user