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 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 **Claude Desktop**, **LLMs**, and any MCP-compatible application with **production-ready security**.
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
- - **Complete Microsoft 365 integration** with OAuth2 security via Azure MSAL
8
- - **Intuitive email management** - send, read, search, and organize emails
9
- - **Smart email search** with advanced filtering and criteria support
10
- - **File attachment support** - send and receive attachments seamlessly
11
- - **Enhanced security** with simplified single-user authentication model
12
- - **Contact management** - retrieve and search your contact directory
13
- - **Secure authentication** with OS keychain storage and automatic refresh
14
- - **Cross-platform compatibility** (macOS, Linux, Windows)
15
-
16
- ## 🛠️ Tools & Capabilities
17
-
18
- ### 📧 Core Email Operations (12 tools)
19
- - **`send_email`** - Send emails with attachments, HTML/text content, CC/BCC
20
- - **`read_email`** - Read full email content including headers and attachments
21
- - **`search_emails`** - Advanced search with intelligent partial name matching
22
- - **`search_emails_to_me`** - Find emails addressed to YOU (both TO and CC fields)
23
- - **`list_emails`** - List emails in inbox, sent, or custom folders
24
- - **`get_attachment`** - Download and retrieve email attachments
25
- - **`mark_email`** - Mark emails as read or unread
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
- # Global installation
33
+ # Install globally
47
34
  npm install -g ms365-mcp-server
48
35
 
49
- # Authenticate (no Azure app registration needed!)
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
- ### Claude Desktop Integration
57
- Add to your `claude_desktop_config.json`:
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 - no Azure registration required!
85
+ # One-command authentication
75
86
  ms365-mcp-server --login
76
87
  ```
77
88
 
78
- ### MCP Authentication Flow
79
- 1. **Call**: `authenticate_with_device_code`
80
- 2. **Get**: Device code and URL in the response
81
- 3. **Visit**: https://microsoft.com/devicelogin
82
- 4. **Enter**: The provided device code
83
- 5. **Call**: `authenticate_with_device_code` again
84
- 6. **Done**: ✅ Authenticated and ready!
89
+ ### MCP Tool Authentication
90
+ ```javascript
91
+ // Check authentication status
92
+ {
93
+ "tool": "authenticate",
94
+ "arguments": {
95
+ "action": "status"
96
+ }
97
+ }
85
98
 
86
- ### Advanced Setup (Custom Azure App)
87
- For advanced users who want custom Azure app configuration:
99
+ // Login with device code
100
+ {
101
+ "tool": "authenticate",
102
+ "arguments": {
103
+ "action": "login"
104
+ }
105
+ }
88
106
 
89
- ```bash
90
- ms365-mcp-server --setup-auth
91
- # Follow prompts for custom client ID/secret
107
+ // Logout
108
+ {
109
+ "tool": "authenticate",
110
+ "arguments": {
111
+ "action": "logout"
112
+ }
113
+ }
92
114
  ```
93
115
 
94
- ## 📖 Usage Examples
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 advanced criteria
135
+ // Search emails with smart name matching
114
136
  {
115
- "tool": "search_emails",
137
+ "tool": "manage_email",
116
138
  "arguments": {
117
- "from": "boss@company.com",
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
- // Find all emails addressed to YOU (both TO and CC)
146
+ // List recent inbox emails
124
147
  {
125
- "tool": "search_emails_to_me",
148
+ "tool": "manage_email",
126
149
  "arguments": {
127
- "from": "important-sender@company.com",
128
- "isUnread": true,
129
- "after": "2024-01-01"
150
+ "action": "list",
151
+ "folderId": "inbox",
152
+ "maxResults": 10
130
153
  }
131
154
  }
132
155
 
133
- // Check authentication
156
+ // Find emails sent to you (TO or CC)
134
157
  {
135
- "tool": "verify_authentication",
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
- ### 🔍 Email Search Options
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
- - **`search_emails`** - Unified search with intelligent capabilities
143
- - **Smart Name Matching**: Automatically detects names vs email addresses
144
- - **Partial Name Support**: Search by "Madan", "Kumar", "M Kumar", etc.
145
- - **Flexible Criteria**: Combine name search with date ranges, subjects, etc.
146
- - **Email Address Matching**: Use exact email addresses when needed
147
- - Example: `{"from": "Madan", "after": "2024-01-01"}` or `{"from": "boss@company.com"}`
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
- - **`search_emails_to_me`** - Automatic search for emails addressed to YOU
150
- - Automatically uses your email address for both TO and CC searches
151
- - Finds ALL emails where you are a recipient (direct or CC'd)
152
- - No need to specify your email address manually
153
- - Example: `{"from": "boss@company.com", "isUnread": true}`
248
+ // List mailbox folders
249
+ {
250
+ "tool": "list_folders",
251
+ "arguments": {}
252
+ }
253
+ ```
154
254
 
155
255
  ## 🎯 Command Line Options
156
256
 
157
- - `--login` - Authenticate using device code flow (recommended)
158
- - `--logout` - Clear stored authentication tokens
159
- - `--verify-login` - Check current authentication status
160
- - `--setup-auth` - Interactive credential setup
161
- - `--reset-auth` - Clear all stored authentication data
162
- - `--debug` - Enable detailed debug logging
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 Features
269
+ ## 🛡️ Security & Reliability
165
270
 
166
- - **Device Code Authentication** - No browser auto-open, manual code entry
167
- - **OS Keychain Integration** - Secure token storage with encrypted fallback
168
- - **Single-User Model** - Simplified security, no account enumeration
169
- - **Privacy Protection** - Users see only their own information
170
- - **OAuth2 Compliance** - Microsoft MSAL library with automatic refresh
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
- ### Common Issues
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
- **Device code authentication issues**
289
+ ### Debug Mode
183
290
  ```bash
184
- ms365-mcp-server --verify-login # Check status
185
- ms365-mcp-server --logout # Reset if needed
186
- ms365-mcp-server --login # Re-authenticate
291
+ # Enable detailed logging
292
+ ms365-mcp-server --debug
293
+
294
+ # Logs location: /tmp/ms365-mcp-server.log
187
295
  ```
188
296
 
189
- **Authentication timeout**
190
- - Device codes expire in 15 minutes
191
- - Use `--reset-auth` to clear old tokens
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
- ### Debug Logs
194
- ```bash
195
- ms365-mcp-server --debug
196
- # Logs written to: /tmp/ms365-mcp-server.log
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 project
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
- ## 🧠 Perfect for AI Assistants
324
+ ## 📈 What's New in v1.1.0
213
325
 
214
- - **Claude Desktop integration** - Add Microsoft 365 to Claude conversations
215
- - **Email automation** - Build smart workflows and email processing
216
- - **Inbox management** - Let AI help organize and respond to emails
217
- - **Email analysis** - Extract insights and patterns from email data
218
- - **Customer support** - Streamline email-based interactions
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 feel free to submit a Pull Request.
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 Claude Desktop and MCP applications*
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