w
This commit is contained in:
+51
-5
@@ -8,15 +8,35 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
server.registerTool(
|
||||
"get_calendar_events",
|
||||
{
|
||||
description:
|
||||
"Get calendar events within a date range. Set includeBody=true to fetch organizer, attendees, and body via GetItem. Returns {events, count}.",
|
||||
description: "Get calendar events within a date range."
|
||||
+ " Set includeBody=true to fetch organizer, attendees, and body via GetItem.",
|
||||
inputSchema: z.object({
|
||||
startDate: z.string().describe("Start date in YYYY-MM-DD format"),
|
||||
endDate: z.string().describe("End date in YYYY-MM-DD format"),
|
||||
includeBody: z.boolean().default(false).describe(
|
||||
"If true, fetch full event details (organizer, attendees, body) via GetItem. Default: false",
|
||||
"If true, fetch full event details (organizer, attendees, body) via GetItem",
|
||||
),
|
||||
}),
|
||||
outputSchema: z.object({
|
||||
events: z.array(z.object({
|
||||
subject: z.string(),
|
||||
start: z.string(),
|
||||
end: z.string(),
|
||||
location: z.string(),
|
||||
isAllDay: z.boolean(),
|
||||
isCancelled: z.boolean(),
|
||||
isMeeting: z.boolean(),
|
||||
isRecurring: z.boolean(),
|
||||
organizer: z.string(),
|
||||
organizerEmail: z.string(),
|
||||
myResponse: z.string(),
|
||||
itemId: z.string(),
|
||||
body: z.string(),
|
||||
requiredAttendees: z.array(z.string()),
|
||||
optionalAttendees: z.array(z.string()),
|
||||
})),
|
||||
count: z.number(),
|
||||
}),
|
||||
},
|
||||
async ({ startDate, endDate, includeBody }) => {
|
||||
try {
|
||||
@@ -69,6 +89,7 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
type: "text" as const,
|
||||
text: JSON.stringify({ events, count: events.length }),
|
||||
}],
|
||||
structuredContent: { events, count: events.length },
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
@@ -85,15 +106,31 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
"download_event_attachments",
|
||||
{
|
||||
description:
|
||||
"Download all file attachments from a calendar event to disk. Inline (embedded) attachments are skipped — only standalone file attachments are downloaded. Returns {success, downloaded, count} or {success, downloaded, count, errors}.",
|
||||
"Download all file attachments from a calendar event to disk."
|
||||
+ " Inline (embedded) attachments are skipped — only standalone file attachments are downloaded.",
|
||||
inputSchema: z.object({
|
||||
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",
|
||||
"Local directory to save files",
|
||||
),
|
||||
}),
|
||||
outputSchema: z.object({
|
||||
success: z.boolean(),
|
||||
downloaded: z.array(z.object({
|
||||
name: z.string(),
|
||||
path: z.string(),
|
||||
size: z.number(),
|
||||
contentType: z.string(),
|
||||
})),
|
||||
count: z.number(),
|
||||
errors: z.array(z.object({
|
||||
name: z.string(),
|
||||
error: z.string(),
|
||||
})).optional(),
|
||||
message: z.string().optional(),
|
||||
}),
|
||||
},
|
||||
async ({ itemId, targetFolder }) => {
|
||||
try {
|
||||
@@ -117,6 +154,12 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
message: "No downloadable file attachments.",
|
||||
}),
|
||||
}],
|
||||
structuredContent: {
|
||||
success: true,
|
||||
downloaded: [],
|
||||
count: 0,
|
||||
message: "No downloadable file attachments.",
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -174,6 +217,9 @@ export function registerCalendarTools(server: McpServer): void {
|
||||
...(errors.length ? { errors } : {}),
|
||||
}),
|
||||
}],
|
||||
structuredContent: errors.length === 0
|
||||
? { success: true, downloaded, count: downloaded.length }
|
||||
: { success: false, downloaded, count: downloaded.length, errors },
|
||||
};
|
||||
} catch (error: any) {
|
||||
return {
|
||||
|
||||
Reference in New Issue
Block a user