ms365-mcp-server 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +69 -3
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -67,7 +67,7 @@ function parseArgs() {
|
|
|
67
67
|
}
|
|
68
68
|
const server = new Server({
|
|
69
69
|
name: "ms365-mcp-server",
|
|
70
|
-
version: "1.1.
|
|
70
|
+
version: "1.1.9"
|
|
71
71
|
}, {
|
|
72
72
|
capabilities: {
|
|
73
73
|
resources: {
|
|
@@ -687,12 +687,78 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
|
687
687
|
};
|
|
688
688
|
case "search_to_me":
|
|
689
689
|
const searchToMeResults = await ms365Ops.searchEmailsToMe(args);
|
|
690
|
+
// Process attachments for each email
|
|
691
|
+
const processedEmails = await Promise.all(searchToMeResults.messages.map(async (email) => {
|
|
692
|
+
try {
|
|
693
|
+
// Get full email details including body
|
|
694
|
+
const fullEmail = await ms365Ops.getEmail(email.id, email.hasAttachments);
|
|
695
|
+
// Update email with body content
|
|
696
|
+
email.body = fullEmail.body || fullEmail.bodyPreview || '';
|
|
697
|
+
if (email.hasAttachments && fullEmail.attachments) {
|
|
698
|
+
// Process each attachment
|
|
699
|
+
const processedAttachments = await Promise.all(fullEmail.attachments.map(async (attachment) => {
|
|
700
|
+
try {
|
|
701
|
+
// Get the actual attachment content
|
|
702
|
+
const attachmentContent = await ms365Ops.getAttachment(email.id, attachment.id);
|
|
703
|
+
if (attachmentContent && attachmentContent.contentBytes) {
|
|
704
|
+
const savedFilename = await saveBase64ToFile(attachmentContent.contentBytes, attachment.name);
|
|
705
|
+
const fileUrl = `${SERVER_URL}/attachments/${savedFilename}`;
|
|
706
|
+
return {
|
|
707
|
+
...attachment,
|
|
708
|
+
fileUrl: fileUrl
|
|
709
|
+
};
|
|
710
|
+
}
|
|
711
|
+
return attachment;
|
|
712
|
+
}
|
|
713
|
+
catch (error) {
|
|
714
|
+
logger.error(`Error processing attachment ${attachment.id}:`, error);
|
|
715
|
+
return attachment;
|
|
716
|
+
}
|
|
717
|
+
}));
|
|
718
|
+
email.attachments = processedAttachments;
|
|
719
|
+
email.artifacts = getListOfArtifacts("search_to_me", processedAttachments);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
catch (error) {
|
|
723
|
+
logger.error(`Error processing email ${email.id}:`, error);
|
|
724
|
+
}
|
|
725
|
+
return email;
|
|
726
|
+
}));
|
|
690
727
|
return {
|
|
691
728
|
content: [
|
|
692
729
|
{
|
|
693
730
|
type: "text",
|
|
694
|
-
text: `🔍 Emails Addressed to You (TO & CC) - ${
|
|
695
|
-
|
|
731
|
+
text: `🔍 Emails Addressed to You (TO & CC) - ${processedEmails.length} found\n\n${processedEmails.map((email, index) => {
|
|
732
|
+
let emailText = `${index + 1}. 📧 ${email.subject}\n 👤 From: ${email.from.name} <${email.from.address}>\n 📅 ${new Date(email.receivedDateTime).toLocaleDateString()}\n 🆔 ID: ${email.id}\n`;
|
|
733
|
+
if (email.hasAttachments && email.attachments && email.attachments.length > 0) {
|
|
734
|
+
emailText += ` 📎 Attachments (${email.attachments.length}):\n`;
|
|
735
|
+
email.attachments.forEach((attachment, attIndex) => {
|
|
736
|
+
const sizeInMB = (attachment.size / (1024 * 1024)).toFixed(2);
|
|
737
|
+
emailText += ` ${attIndex + 1}. ${attachment.name}\n`;
|
|
738
|
+
emailText += ` 📦 Size: ${sizeInMB} MB\n`;
|
|
739
|
+
emailText += ` 📄 Type: ${attachment.contentType}\n`;
|
|
740
|
+
emailText += ` 🆔 ID: ${attachment.id}\n`;
|
|
741
|
+
if (attachment.fileUrl) {
|
|
742
|
+
emailText += ` 🔗 Download URL: ${attachment.fileUrl}\n`;
|
|
743
|
+
}
|
|
744
|
+
if (attachment.isInline) {
|
|
745
|
+
emailText += ` 📌 Inline: Yes\n`;
|
|
746
|
+
}
|
|
747
|
+
});
|
|
748
|
+
}
|
|
749
|
+
// Add email body with proper formatting
|
|
750
|
+
if (email.body) {
|
|
751
|
+
emailText += `\n 💬 Content:\n${email.body.split('\n').map((line) => ` ${line}`).join('\n')}\n`;
|
|
752
|
+
}
|
|
753
|
+
else {
|
|
754
|
+
emailText += `\n 💬 Content: No content available\n`;
|
|
755
|
+
}
|
|
756
|
+
return emailText;
|
|
757
|
+
}).join('\n')}`
|
|
758
|
+
},
|
|
759
|
+
...processedEmails
|
|
760
|
+
.filter((email) => email.artifacts)
|
|
761
|
+
.flatMap((email) => email.artifacts)
|
|
696
762
|
]
|
|
697
763
|
};
|
|
698
764
|
case "list":
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ms365-mcp-server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "Microsoft 365 MCP Server for managing Microsoft 365 email through natural language interactions with full OAuth2 authentication support",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"type": "module",
|