ms365-mcp-server 1.0.5 → 1.1.0

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.
Files changed (4) hide show
  1. package/README.md +214 -116
  2. package/bin/cli.js +2 -2
  3. package/dist/index.js +320 -645
  4. package/package.json +2 -3
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, or delete 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
58
47
 
48
+ # Start the server
49
+ npx ms365-mcp-server
50
+ ```
51
+
52
+ ### 2. SIYA Desktop Integration
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,166 @@ 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
+ }
137
202
  }
138
203
  ```
139
204
 
140
- ### 🔍 Email Search Options
205
+ ### Contact & Authentication
206
+ ```javascript
207
+ // List all contacts
208
+ {
209
+ "tool": "manage_contacts",
210
+ "arguments": {
211
+ "action": "list",
212
+ "maxResults": 100
213
+ }
214
+ }
215
+
216
+ // Search contacts by name
217
+ {
218
+ "tool": "manage_contacts",
219
+ "arguments": {
220
+ "action": "search",
221
+ "query": "John"
222
+ }
223
+ }
141
224
 
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"}`
225
+ // Get attachment from email
226
+ {
227
+ "tool": "get_attachment",
228
+ "arguments": {
229
+ "messageId": "email_id",
230
+ "attachmentId": "attachment_id"
231
+ }
232
+ }
148
233
 
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}`
234
+ // List mailbox folders
235
+ {
236
+ "tool": "list_folders",
237
+ "arguments": {}
238
+ }
239
+ ```
154
240
 
155
241
  ## 🎯 Command Line Options
156
242
 
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
243
+ ```bash
244
+ # Authentication
245
+ ms365-mcp-server --login # Authenticate using device code
246
+ ms365-mcp-server --logout # Clear stored tokens
247
+ ms365-mcp-server --verify-login # Check authentication status
248
+
249
+ # Management
250
+ ms365-mcp-server --setup-auth # Interactive credential setup
251
+ ms365-mcp-server --reset-auth # Clear all authentication data
252
+ ms365-mcp-server --debug # Enable detailed logging
253
+ ```
163
254
 
164
- ## 🛡️ Security Features
255
+ ## 🛡️ Security & Reliability
165
256
 
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
257
+ - **🔄 Proactive Token Refresh** - Prevents authentication interruptions during long conversations
258
+ - **🔐 Secure Storage** - OS keychain integration with encrypted fallback
259
+ - **🛡️ OAuth2 Compliance** - Microsoft MSAL library with enterprise-grade security
260
+ - **🏠 Privacy First** - All processing happens locally, no data sent to third parties
261
+ - **🔒 Single-User Model** - Simplified security without account enumeration risks
172
262
 
173
263
  ## 🚨 Troubleshooting
174
264
 
175
- ### Common Issues
176
-
177
- **"MS365 credentials not configured"**
265
+ ### Authentication Issues
178
266
  ```bash
267
+ # Check current status
268
+ ms365-mcp-server --verify-login
269
+
270
+ # Reset and re-authenticate
271
+ ms365-mcp-server --logout
179
272
  ms365-mcp-server --login
180
273
  ```
181
274
 
182
- **Device code authentication issues**
275
+ ### Debug Mode
183
276
  ```bash
184
- ms365-mcp-server --verify-login # Check status
185
- ms365-mcp-server --logout # Reset if needed
186
- ms365-mcp-server --login # Re-authenticate
277
+ # Enable detailed logging
278
+ ms365-mcp-server --debug
279
+
280
+ # Logs location: /tmp/ms365-mcp-server.log
187
281
  ```
188
282
 
189
- **Authentication timeout**
190
- - Device codes expire in 15 minutes
191
- - Use `--reset-auth` to clear old tokens
283
+ ### Common Solutions
284
+ - **"Credentials not configured"** Run `--login`
285
+ - **"Token expired"** → Authentication auto-refreshes, or run `--login`
286
+ - **Device code timeout** → Codes expire in 15 minutes, try `--login` again
192
287
 
193
- ### Debug Logs
194
- ```bash
195
- ms365-mcp-server --debug
196
- # Logs written to: /tmp/ms365-mcp-server.log
197
- ```
288
+ ## 🧠 Perfect for AI Assistants
289
+
290
+ - **📞 Natural Language Interface** - Ask SIYA to "check my emails from John today"
291
+ - **🤖 Smart Email Processing** - Let AI help organize, respond, and analyze emails
292
+ - **⚡ Optimized for LLMs** - Unified tools reduce context switching and improve performance
293
+ - **🔄 Reliable Sessions** - Proactive authentication prevents chat interruptions
294
+ - **📊 Email Analytics** - Extract insights and patterns from your email data
198
295
 
199
296
  ## 🔧 Development
200
297
 
@@ -202,20 +299,21 @@ ms365-mcp-server --debug
202
299
  # Local development
203
300
  npm run dev
204
301
 
205
- # Build project
302
+ # Build and test
206
303
  npm run build
304
+ npm test
207
305
 
208
- # Version management
306
+ # Version management
209
307
  npm run version-bump [patch|minor|major]
210
308
  ```
211
309
 
212
- ## 🧠 Perfect for AI Assistants
310
+ ## 📈 What's New in v1.1.0
213
311
 
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
312
+ - **🎯 67% Fewer Tools** - Consolidated 18 tools into 6 unified tools
313
+ - **🔄 Bulletproof Auth** - Proactive token refresh prevents interruptions
314
+ - **⚡ Better Performance** - Optimized tool architecture for faster responses
315
+ - **🧠 AI-Optimized** - Action-based design perfect for LLM interactions
316
+ - **🛡️ Enhanced Security** - Improved error handling and retry logic
219
317
 
220
318
  ## 📝 License
221
319
 
@@ -223,10 +321,10 @@ MIT License - see LICENSE file for details.
223
321
 
224
322
  ## 🤝 Contributing
225
323
 
226
- Contributions welcome! Please feel free to submit a Pull Request.
324
+ Contributions welcome! Please submit issues and pull requests.
227
325
 
228
326
  ---
229
327
 
230
- **Built with 🔒 Security and ❤️ for the AI community**
328
+ **Built with 🔒 Security and ❤️ for the AI community**
231
329
 
232
- *Production-ready Microsoft 365 integration for Claude Desktop and MCP applications*
330
+ *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