ms365-mcp-server 1.1.5 → 1.1.6
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 +1 -1
- package/dist/utils/ms365-operations.js +35 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { logger } from './api.js';
|
|
2
|
+
import mimeTypes from 'mime-types';
|
|
2
3
|
/**
|
|
3
4
|
* Microsoft 365 operations manager class
|
|
4
5
|
*/
|
|
@@ -686,19 +687,48 @@ export class MS365Operations {
|
|
|
686
687
|
async getAttachment(messageId, attachmentId) {
|
|
687
688
|
try {
|
|
688
689
|
const graphClient = await this.getGraphClient();
|
|
690
|
+
logger.log(`Fetching attachment ${attachmentId} from message ${messageId}...`);
|
|
691
|
+
// First get attachment metadata
|
|
689
692
|
const attachment = await graphClient
|
|
690
693
|
.api(`/me/messages/${messageId}/attachments/${attachmentId}`)
|
|
691
694
|
.get();
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
695
|
+
logger.log(`Retrieved attachment metadata: ${attachment.name} (${attachment.contentType}, ${attachment.size} bytes)`);
|
|
696
|
+
// Determine content type if not provided
|
|
697
|
+
let contentType = attachment.contentType;
|
|
698
|
+
if (!contentType && attachment.name) {
|
|
699
|
+
contentType = mimeTypes.lookup(attachment.name) || 'application/octet-stream';
|
|
700
|
+
logger.log(`Inferred content type for ${attachment.name}: ${contentType}`);
|
|
701
|
+
}
|
|
702
|
+
// Validate content bytes
|
|
703
|
+
if (!attachment.contentBytes) {
|
|
704
|
+
logger.error('No content bytes found in attachment');
|
|
705
|
+
throw new Error('Attachment content is empty');
|
|
706
|
+
}
|
|
707
|
+
// Return the attachment data
|
|
708
|
+
const result = {
|
|
709
|
+
name: attachment.name || 'unnamed_attachment',
|
|
710
|
+
contentType: contentType || 'application/octet-stream',
|
|
711
|
+
contentBytes: attachment.contentBytes,
|
|
696
712
|
size: attachment.size || 0
|
|
697
713
|
};
|
|
714
|
+
logger.log(`Successfully processed attachment: ${result.name} (${result.contentType}, ${result.size} bytes)`);
|
|
715
|
+
return result;
|
|
698
716
|
}
|
|
699
717
|
catch (error) {
|
|
700
718
|
logger.error('Error getting attachment:', error);
|
|
701
|
-
|
|
719
|
+
// Provide more specific error messages
|
|
720
|
+
if (error.status === 404) {
|
|
721
|
+
throw new Error(`Attachment not found: ${error.message}`);
|
|
722
|
+
}
|
|
723
|
+
else if (error.status === 401) {
|
|
724
|
+
throw new Error('Authentication failed. Please re-authenticate.');
|
|
725
|
+
}
|
|
726
|
+
else if (error.status === 403) {
|
|
727
|
+
throw new Error('Permission denied to access this attachment.');
|
|
728
|
+
}
|
|
729
|
+
else {
|
|
730
|
+
throw new Error(`Failed to get attachment: ${error.message}`);
|
|
731
|
+
}
|
|
702
732
|
}
|
|
703
733
|
}
|
|
704
734
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ms365-mcp-server",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.6",
|
|
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",
|