ms365-mcp-server 1.0.5 → 1.1.1
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/README.md +228 -116
- package/bin/cli.js +2 -2
- package/dist/index.js +382 -627
- package/dist/utils/ms365-operations.js +68 -0
- package/package.json +3 -4
package/README.md
CHANGED
|
@@ -1,61 +1,57 @@
|
|
|
1
1
|
# ✉️ Microsoft 365 MCP Server
|
|
2
2
|
|
|
3
|
-
A powerful **Model Context Protocol (MCP) server** that enables seamless Microsoft 365 email integration through natural language interactions. Built for **
|
|
3
|
+
A powerful **Model Context Protocol (MCP) server** that enables seamless Microsoft 365 email integration through natural language interactions. Built for **SIYA Desktop**, **LLMs**, and any MCP-compatible application with **production-ready security**.
|
|
4
4
|
|
|
5
5
|
## ✨ Key Features
|
|
6
6
|
|
|
7
|
-
-
|
|
8
|
-
-
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- **`
|
|
20
|
-
- **`
|
|
21
|
-
- **`
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
- **`
|
|
25
|
-
- **`
|
|
26
|
-
- **`move_email`** - Move emails between folders
|
|
27
|
-
- **`delete_email`** - Permanently delete email messages
|
|
28
|
-
- **`list_folders`** - Browse all mail folders and their statistics
|
|
29
|
-
- **`get_contacts`** - Retrieve contact list from Microsoft 365
|
|
30
|
-
- **`search_contacts`** - Search contacts by name or email address
|
|
31
|
-
|
|
32
|
-
### 🔐 Authentication Tools (6 tools)
|
|
33
|
-
- **`authenticate_with_device_code`** - Complete authentication in MCP (RECOMMENDED)
|
|
34
|
-
- **`device_code_login`** - Start device code authentication flow
|
|
35
|
-
- **`check_pending_auth`** - Check for pending device code authentication
|
|
36
|
-
- **`verify_authentication`** - Check current authentication status
|
|
37
|
-
- **`logout`** - Clear authentication tokens and reset session
|
|
38
|
-
- **`get_device_code`** - Get device code info for manual authentication
|
|
39
|
-
|
|
40
|
-
**Total: 18 tools** (12 email operations + 6 authentication tools)
|
|
7
|
+
- **🎯 Optimized Tool Architecture** - Only 6 unified tools (67% reduction from 18 tools)
|
|
8
|
+
- **📧 Complete Email Management** - Send, read, search, organize, and manage attachments
|
|
9
|
+
- **🔐 Bulletproof Authentication** - Proactive token refresh prevents chat interruptions
|
|
10
|
+
- **🤖 AI-First Design** - Intuitive action-based tools perfect for LLM interactions
|
|
11
|
+
- **🔒 Enterprise Security** - OAuth2 with secure keychain storage and automatic refresh
|
|
12
|
+
- **📁 Smart Contact Management** - Search and retrieve your Microsoft 365 contacts
|
|
13
|
+
- **🌐 Cross-Platform** - Works on macOS, Linux, and Windows
|
|
14
|
+
|
|
15
|
+
## 🛠️ Available Tools (6 Total)
|
|
16
|
+
|
|
17
|
+
### **📧 Email Management**
|
|
18
|
+
- **`send_email`** - Send emails with attachments and rich formatting
|
|
19
|
+
- **`manage_email`** - **UNIFIED**: Read, search, list, mark, move, delete, or draft emails
|
|
20
|
+
- **`get_attachment`** - Download email attachments with metadata
|
|
21
|
+
- **`list_folders`** - Browse mailbox folders with item counts
|
|
22
|
+
|
|
23
|
+
### **👥 Contacts & Authentication**
|
|
24
|
+
- **`manage_contacts`** - **UNIFIED**: List all contacts or search by name/email
|
|
25
|
+
- **`authenticate`** - **UNIFIED**: Complete authentication management (login, status, logout)
|
|
41
26
|
|
|
42
27
|
## 🚀 Quick Start
|
|
43
28
|
|
|
44
|
-
### Installation
|
|
29
|
+
### 1. Installation
|
|
30
|
+
|
|
31
|
+
**Option A: Global Installation**
|
|
45
32
|
```bash
|
|
46
|
-
#
|
|
33
|
+
# Install globally
|
|
47
34
|
npm install -g ms365-mcp-server
|
|
48
35
|
|
|
49
|
-
# Authenticate (no Azure
|
|
36
|
+
# Authenticate (no Azure setup needed!)
|
|
50
37
|
ms365-mcp-server --login
|
|
51
38
|
|
|
52
39
|
# Start the server
|
|
53
40
|
ms365-mcp-server
|
|
54
41
|
```
|
|
55
42
|
|
|
56
|
-
|
|
57
|
-
|
|
43
|
+
**Option B: Run with npx (no installation needed)**
|
|
44
|
+
```bash
|
|
45
|
+
# Authenticate
|
|
46
|
+
npx ms365-mcp-server --login
|
|
47
|
+
|
|
48
|
+
# Start the server
|
|
49
|
+
npx ms365-mcp-server
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 2. SIYA Desktop Integration
|
|
58
53
|
|
|
54
|
+
**For Global Installation:**
|
|
59
55
|
```json
|
|
60
56
|
{
|
|
61
57
|
"mcpServers": {
|
|
@@ -67,31 +63,57 @@ Add to your `claude_desktop_config.json`:
|
|
|
67
63
|
}
|
|
68
64
|
```
|
|
69
65
|
|
|
66
|
+
**For npx Usage:**
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"mcpServers": {
|
|
70
|
+
"ms365": {
|
|
71
|
+
"command": "npx",
|
|
72
|
+
"args": ["ms365-mcp-server"]
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### 3. Start Using
|
|
79
|
+
Chat with SIYA and ask it to help with your emails! The tools are designed for natural language interaction.
|
|
80
|
+
|
|
70
81
|
## 🔐 Authentication
|
|
71
82
|
|
|
72
83
|
### Simple Setup (Recommended)
|
|
73
84
|
```bash
|
|
74
|
-
# One-command authentication
|
|
85
|
+
# One-command authentication
|
|
75
86
|
ms365-mcp-server --login
|
|
76
87
|
```
|
|
77
88
|
|
|
78
|
-
### MCP Authentication
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
89
|
+
### MCP Tool Authentication
|
|
90
|
+
```javascript
|
|
91
|
+
// Check authentication status
|
|
92
|
+
{
|
|
93
|
+
"tool": "authenticate",
|
|
94
|
+
"arguments": {
|
|
95
|
+
"action": "status"
|
|
96
|
+
}
|
|
97
|
+
}
|
|
85
98
|
|
|
86
|
-
|
|
87
|
-
|
|
99
|
+
// Login with device code
|
|
100
|
+
{
|
|
101
|
+
"tool": "authenticate",
|
|
102
|
+
"arguments": {
|
|
103
|
+
"action": "login"
|
|
104
|
+
}
|
|
105
|
+
}
|
|
88
106
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
107
|
+
// Logout
|
|
108
|
+
{
|
|
109
|
+
"tool": "authenticate",
|
|
110
|
+
"arguments": {
|
|
111
|
+
"action": "logout"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
92
114
|
```
|
|
93
115
|
|
|
94
|
-
##
|
|
116
|
+
## 💡 Tool Usage Examples
|
|
95
117
|
|
|
96
118
|
### Email Operations
|
|
97
119
|
```javascript
|
|
@@ -110,91 +132,180 @@ ms365-mcp-server --setup-auth
|
|
|
110
132
|
}
|
|
111
133
|
}
|
|
112
134
|
|
|
113
|
-
// Search emails with
|
|
135
|
+
// Search emails with smart name matching
|
|
114
136
|
{
|
|
115
|
-
"tool": "
|
|
137
|
+
"tool": "manage_email",
|
|
116
138
|
"arguments": {
|
|
117
|
-
"
|
|
139
|
+
"action": "search",
|
|
140
|
+
"from": "John Smith", // Works with names or emails
|
|
118
141
|
"after": "2024-01-01",
|
|
119
142
|
"hasAttachment": true
|
|
120
143
|
}
|
|
121
144
|
}
|
|
122
145
|
|
|
123
|
-
//
|
|
146
|
+
// List recent inbox emails
|
|
124
147
|
{
|
|
125
|
-
"tool": "
|
|
148
|
+
"tool": "manage_email",
|
|
126
149
|
"arguments": {
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
150
|
+
"action": "list",
|
|
151
|
+
"folderId": "inbox",
|
|
152
|
+
"maxResults": 10
|
|
130
153
|
}
|
|
131
154
|
}
|
|
132
155
|
|
|
133
|
-
//
|
|
156
|
+
// Find emails sent to you (TO or CC)
|
|
134
157
|
{
|
|
135
|
-
"tool": "
|
|
136
|
-
"arguments": {
|
|
158
|
+
"tool": "manage_email",
|
|
159
|
+
"arguments": {
|
|
160
|
+
"action": "search_to_me",
|
|
161
|
+
"from": "boss@company.com",
|
|
162
|
+
"isUnread": true
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// Read a specific email
|
|
167
|
+
{
|
|
168
|
+
"tool": "manage_email",
|
|
169
|
+
"arguments": {
|
|
170
|
+
"action": "read",
|
|
171
|
+
"messageId": "email_id_here"
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
// Mark email as read
|
|
176
|
+
{
|
|
177
|
+
"tool": "manage_email",
|
|
178
|
+
"arguments": {
|
|
179
|
+
"action": "mark",
|
|
180
|
+
"messageId": "email_id",
|
|
181
|
+
"isRead": true
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// Move email to folder
|
|
186
|
+
{
|
|
187
|
+
"tool": "manage_email",
|
|
188
|
+
"arguments": {
|
|
189
|
+
"action": "move",
|
|
190
|
+
"messageId": "email_id",
|
|
191
|
+
"destinationFolderId": "archive"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
// Delete email
|
|
196
|
+
{
|
|
197
|
+
"tool": "manage_email",
|
|
198
|
+
"arguments": {
|
|
199
|
+
"action": "delete",
|
|
200
|
+
"messageId": "email_id"
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Create draft email
|
|
205
|
+
{
|
|
206
|
+
"tool": "manage_email",
|
|
207
|
+
"arguments": {
|
|
208
|
+
"action": "draft",
|
|
209
|
+
"draftTo": ["colleague@company.com"],
|
|
210
|
+
"draftSubject": "Draft: Project Update",
|
|
211
|
+
"draftBody": "<h2>Status Report</h2><p>Project is on track!</p>",
|
|
212
|
+
"draftBodyType": "html",
|
|
213
|
+
"draftCc": ["manager@company.com"],
|
|
214
|
+
"draftImportance": "normal"
|
|
215
|
+
}
|
|
137
216
|
}
|
|
138
217
|
```
|
|
139
218
|
|
|
140
|
-
###
|
|
219
|
+
### Contact & Authentication
|
|
220
|
+
```javascript
|
|
221
|
+
// List all contacts
|
|
222
|
+
{
|
|
223
|
+
"tool": "manage_contacts",
|
|
224
|
+
"arguments": {
|
|
225
|
+
"action": "list",
|
|
226
|
+
"maxResults": 100
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Search contacts by name
|
|
231
|
+
{
|
|
232
|
+
"tool": "manage_contacts",
|
|
233
|
+
"arguments": {
|
|
234
|
+
"action": "search",
|
|
235
|
+
"query": "John"
|
|
236
|
+
}
|
|
237
|
+
}
|
|
141
238
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
239
|
+
// Get attachment from email
|
|
240
|
+
{
|
|
241
|
+
"tool": "get_attachment",
|
|
242
|
+
"arguments": {
|
|
243
|
+
"messageId": "email_id",
|
|
244
|
+
"attachmentId": "attachment_id"
|
|
245
|
+
}
|
|
246
|
+
}
|
|
148
247
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
248
|
+
// List mailbox folders
|
|
249
|
+
{
|
|
250
|
+
"tool": "list_folders",
|
|
251
|
+
"arguments": {}
|
|
252
|
+
}
|
|
253
|
+
```
|
|
154
254
|
|
|
155
255
|
## 🎯 Command Line Options
|
|
156
256
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
-
|
|
160
|
-
-
|
|
161
|
-
-
|
|
162
|
-
|
|
257
|
+
```bash
|
|
258
|
+
# Authentication
|
|
259
|
+
ms365-mcp-server --login # Authenticate using device code
|
|
260
|
+
ms365-mcp-server --logout # Clear stored tokens
|
|
261
|
+
ms365-mcp-server --verify-login # Check authentication status
|
|
262
|
+
|
|
263
|
+
# Management
|
|
264
|
+
ms365-mcp-server --setup-auth # Interactive credential setup
|
|
265
|
+
ms365-mcp-server --reset-auth # Clear all authentication data
|
|
266
|
+
ms365-mcp-server --debug # Enable detailed logging
|
|
267
|
+
```
|
|
163
268
|
|
|
164
|
-
## 🛡️ Security
|
|
269
|
+
## 🛡️ Security & Reliability
|
|
165
270
|
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
169
|
-
-
|
|
170
|
-
-
|
|
171
|
-
- **Local Processing** - No data transmitted to third-party servers
|
|
271
|
+
- **🔄 Proactive Token Refresh** - Prevents authentication interruptions during long conversations
|
|
272
|
+
- **🔐 Secure Storage** - OS keychain integration with encrypted fallback
|
|
273
|
+
- **🛡️ OAuth2 Compliance** - Microsoft MSAL library with enterprise-grade security
|
|
274
|
+
- **🏠 Privacy First** - All processing happens locally, no data sent to third parties
|
|
275
|
+
- **🔒 Single-User Model** - Simplified security without account enumeration risks
|
|
172
276
|
|
|
173
277
|
## 🚨 Troubleshooting
|
|
174
278
|
|
|
175
|
-
###
|
|
176
|
-
|
|
177
|
-
**"MS365 credentials not configured"**
|
|
279
|
+
### Authentication Issues
|
|
178
280
|
```bash
|
|
281
|
+
# Check current status
|
|
282
|
+
ms365-mcp-server --verify-login
|
|
283
|
+
|
|
284
|
+
# Reset and re-authenticate
|
|
285
|
+
ms365-mcp-server --logout
|
|
179
286
|
ms365-mcp-server --login
|
|
180
287
|
```
|
|
181
288
|
|
|
182
|
-
|
|
289
|
+
### Debug Mode
|
|
183
290
|
```bash
|
|
184
|
-
|
|
185
|
-
ms365-mcp-server --
|
|
186
|
-
|
|
291
|
+
# Enable detailed logging
|
|
292
|
+
ms365-mcp-server --debug
|
|
293
|
+
|
|
294
|
+
# Logs location: /tmp/ms365-mcp-server.log
|
|
187
295
|
```
|
|
188
296
|
|
|
189
|
-
|
|
190
|
-
-
|
|
191
|
-
-
|
|
297
|
+
### Common Solutions
|
|
298
|
+
- **"Credentials not configured"** → Run `--login`
|
|
299
|
+
- **"Token expired"** → Authentication auto-refreshes, or run `--login`
|
|
300
|
+
- **Device code timeout** → Codes expire in 15 minutes, try `--login` again
|
|
192
301
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
302
|
+
## 🧠 Perfect for AI Assistants
|
|
303
|
+
|
|
304
|
+
- **📞 Natural Language Interface** - Ask SIYA to "check my emails from John today"
|
|
305
|
+
- **🤖 Smart Email Processing** - Let AI help organize, respond, and analyze emails
|
|
306
|
+
- **⚡ Optimized for LLMs** - Unified tools reduce context switching and improve performance
|
|
307
|
+
- **🔄 Reliable Sessions** - Proactive authentication prevents chat interruptions
|
|
308
|
+
- **📊 Email Analytics** - Extract insights and patterns from your email data
|
|
198
309
|
|
|
199
310
|
## 🔧 Development
|
|
200
311
|
|
|
@@ -202,20 +313,21 @@ ms365-mcp-server --debug
|
|
|
202
313
|
# Local development
|
|
203
314
|
npm run dev
|
|
204
315
|
|
|
205
|
-
# Build
|
|
316
|
+
# Build and test
|
|
206
317
|
npm run build
|
|
318
|
+
npm test
|
|
207
319
|
|
|
208
|
-
# Version management
|
|
320
|
+
# Version management
|
|
209
321
|
npm run version-bump [patch|minor|major]
|
|
210
322
|
```
|
|
211
323
|
|
|
212
|
-
##
|
|
324
|
+
## 📈 What's New in v1.1.0
|
|
213
325
|
|
|
214
|
-
-
|
|
215
|
-
-
|
|
216
|
-
-
|
|
217
|
-
-
|
|
218
|
-
-
|
|
326
|
+
- **🎯 67% Fewer Tools** - Consolidated 18 tools into 6 unified tools
|
|
327
|
+
- **🔄 Bulletproof Auth** - Proactive token refresh prevents interruptions
|
|
328
|
+
- **⚡ Better Performance** - Optimized tool architecture for faster responses
|
|
329
|
+
- **🧠 AI-Optimized** - Action-based design perfect for LLM interactions
|
|
330
|
+
- **🛡️ Enhanced Security** - Improved error handling and retry logic
|
|
219
331
|
|
|
220
332
|
## 📝 License
|
|
221
333
|
|
|
@@ -223,10 +335,10 @@ MIT License - see LICENSE file for details.
|
|
|
223
335
|
|
|
224
336
|
## 🤝 Contributing
|
|
225
337
|
|
|
226
|
-
Contributions welcome! Please
|
|
338
|
+
Contributions welcome! Please submit issues and pull requests.
|
|
227
339
|
|
|
228
340
|
---
|
|
229
341
|
|
|
230
|
-
**Built with 🔒 Security and ❤️ for the AI community**
|
|
342
|
+
**Built with 🔒 Security and ❤️ for the AI community**
|
|
231
343
|
|
|
232
|
-
*Production-ready Microsoft 365 integration for
|
|
344
|
+
*Production-ready Microsoft 365 integration for SIYA Desktop and MCP applications*
|
package/bin/cli.js
CHANGED
|
@@ -64,7 +64,7 @@ let login = false;
|
|
|
64
64
|
let logout = false;
|
|
65
65
|
let verifyLogin = false;
|
|
66
66
|
|
|
67
|
-
// Detect if we're running under an MCP context (Claude/ChatGPT/etc.)
|
|
67
|
+
// Detect if we're running under an MCP context (Claude/SIYA/ChatGPT/etc.)
|
|
68
68
|
const isMcpContext =
|
|
69
69
|
!process.stdin.isTTY ||
|
|
70
70
|
process.env.npm_execpath?.includes('npx') ||
|
|
@@ -106,7 +106,7 @@ for (let i = 0; i < args.length; i++) {
|
|
|
106
106
|
writeDebug('Verify login mode enabled');
|
|
107
107
|
} else if (arg === '--help' || arg === '-h') {
|
|
108
108
|
console.log(`
|
|
109
|
-
MS365 MCP Server - Microsoft 365 Integration for Claude Desktop
|
|
109
|
+
MS365 MCP Server - Microsoft 365 Integration for Claude/SIYA Desktop
|
|
110
110
|
|
|
111
111
|
Usage: npx ms365-mcp-server [options]
|
|
112
112
|
|