refactor: drop skill file, rework client #3
+1
-11
@@ -377,7 +377,7 @@ ${restriction}
|
|||||||
return folders;
|
return folders;
|
||||||
}
|
}
|
||||||
|
|
||||||
extractEmailSummary(item: any): Email {
|
extractEmail(item: any): Email {
|
||||||
const itemType = item["@_xsi_type"] ?? item.__type ?? "";
|
const itemType = item["@_xsi_type"] ?? item.__type ?? "";
|
||||||
const isMeeting =
|
const isMeeting =
|
||||||
/MeetingRequest|MeetingResponse|MeetingCancellation|CalendarItem/i.test(
|
/MeetingRequest|MeetingResponse|MeetingCancellation|CalendarItem/i.test(
|
||||||
@@ -429,12 +429,6 @@ ${restriction}
|
|||||||
email.end = item.End ?? item.EndWallClock ?? "";
|
email.end = item.End ?? item.EndWallClock ?? "";
|
||||||
}
|
}
|
||||||
|
|
||||||
return email;
|
|
||||||
}
|
|
||||||
|
|
||||||
extractEmailDetails(item: any): Email {
|
|
||||||
const email = this.extractEmailSummary(item);
|
|
||||||
|
|
||||||
const bodyVal = item.Body?.Value ?? item.Body?.["#text"] ?? "";
|
const bodyVal = item.Body?.Value ?? item.Body?.["#text"] ?? "";
|
||||||
const bodyType = item.Body?.["@_BodyType"] ?? item.Body?.BodyType ?? "Text";
|
const bodyType = item.Body?.["@_BodyType"] ?? item.Body?.BodyType ?? "Text";
|
||||||
|
|
||||||
@@ -476,10 +470,6 @@ ${restriction}
|
|||||||
isInline: a.IsInline === "true" || a.IsInline === true,
|
isInline: a.IsInline === "true" || a.IsInline === true,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
const isMeeting =
|
|
||||||
/MeetingRequest|MeetingResponse|MeetingCancellation|CalendarItem/i.test(
|
|
||||||
item["@_xsi_type"] ?? "",
|
|
||||||
);
|
|
||||||
if (isMeeting) {
|
if (isMeeting) {
|
||||||
email.location = item.Location ?? item.EnhancedLocation?.DisplayName
|
email.location = item.Location ?? item.EnhancedLocation?.DisplayName
|
||||||
?? "";
|
?? "";
|
||||||
|
|||||||
+2
-2
@@ -73,7 +73,7 @@ export function registerCalendarTools(server: McpServer): void {
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (includeBody && event.itemId) {
|
if (includeBody && event.itemId) {
|
||||||
const details = client.extractEmailDetails(item);
|
const details = client.extractEmail(item);
|
||||||
event.body = details.body;
|
event.body = details.body;
|
||||||
event.requiredAttendees = details.requiredAttendees ?? [];
|
event.requiredAttendees = details.requiredAttendees ?? [];
|
||||||
event.optionalAttendees = details.optionalAttendees ?? [];
|
event.optionalAttendees = details.optionalAttendees ?? [];
|
||||||
@@ -138,7 +138,7 @@ export function registerCalendarTools(server: McpServer): void {
|
|||||||
try {
|
try {
|
||||||
const client = new EwsClient(loadConfig());
|
const client = new EwsClient(loadConfig());
|
||||||
const item = await client.getItem(itemId);
|
const item = await client.getItem(itemId);
|
||||||
const email = client.extractEmailDetails(item);
|
const email = client.extractEmail(item);
|
||||||
const attachments = email.attachments ?? [];
|
const attachments = email.attachments ?? [];
|
||||||
|
|
||||||
const fileAttachments = attachments.filter(
|
const fileAttachments = attachments.filter(
|
||||||
|
|||||||
+3
-13
@@ -139,17 +139,7 @@ export function registerEmailTools(server: McpServer): void {
|
|||||||
|
|
||||||
const emails = [];
|
const emails = [];
|
||||||
for (const item of items) {
|
for (const item of items) {
|
||||||
const email = client.extractEmailSummary(item);
|
emails.push(client.extractEmail(item));
|
||||||
|
|
||||||
if (includeBody && email.itemId) {
|
|
||||||
const details = client.extractEmailDetails(item);
|
|
||||||
email.to = details.to;
|
|
||||||
email.cc = details.cc;
|
|
||||||
email.body = details.body;
|
|
||||||
email.hasLinks = details.hasLinks;
|
|
||||||
}
|
|
||||||
|
|
||||||
emails.push(email);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -205,7 +195,7 @@ export function registerEmailTools(server: McpServer): void {
|
|||||||
try {
|
try {
|
||||||
const client = getClient();
|
const client = getClient();
|
||||||
const item = await client.getItem(itemId);
|
const item = await client.getItem(itemId);
|
||||||
const email = client.extractEmailDetails(item);
|
const email = client.extractEmail(item);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
content: [{ type: "text" as const, text: JSON.stringify(email) }],
|
content: [{ type: "text" as const, text: JSON.stringify(email) }],
|
||||||
@@ -326,7 +316,7 @@ export function registerEmailTools(server: McpServer): void {
|
|||||||
try {
|
try {
|
||||||
const client = new EwsClient(loadConfig());
|
const client = new EwsClient(loadConfig());
|
||||||
const item = await client.getItem(itemId);
|
const item = await client.getItem(itemId);
|
||||||
const email = client.extractEmailDetails(item);
|
const email = client.extractEmail(item);
|
||||||
const attachments = email.attachments ?? [];
|
const attachments = email.attachments ?? [];
|
||||||
|
|
||||||
const fileAttachments = attachments.filter(
|
const fileAttachments = attachments.filter(
|
||||||
|
|||||||
Reference in New Issue
Block a user