@floriscornel/teams-mcp 0.7.0 → 0.8.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.
- package/README.md +91 -24
- package/dist/index.js +77 -32
- package/dist/index.js.map +1 -1
- package/dist/services/graph.d.ts +10 -0
- package/dist/services/graph.d.ts.map +1 -1
- package/dist/services/graph.js +24 -5
- package/dist/services/graph.js.map +1 -1
- package/dist/tools/auth.d.ts +1 -1
- package/dist/tools/auth.d.ts.map +1 -1
- package/dist/tools/auth.js +1 -1
- package/dist/tools/auth.js.map +1 -1
- package/dist/tools/chats.d.ts +2 -1
- package/dist/tools/chats.d.ts.map +1 -1
- package/dist/tools/chats.js +197 -2
- package/dist/tools/chats.js.map +1 -1
- package/dist/tools/search.d.ts +1 -1
- package/dist/tools/search.d.ts.map +1 -1
- package/dist/tools/search.js +1 -1
- package/dist/tools/search.js.map +1 -1
- package/dist/tools/teams.d.ts +1 -1
- package/dist/tools/teams.d.ts.map +1 -1
- package/dist/tools/teams.js +557 -460
- package/dist/tools/teams.js.map +1 -1
- package/dist/tools/users.d.ts +1 -1
- package/dist/tools/users.d.ts.map +1 -1
- package/dist/tools/users.js +1 -1
- package/dist/tools/users.js.map +1 -1
- package/dist/types/graph.d.ts +10 -2
- package/dist/types/graph.d.ts.map +1 -1
- package/dist/utils/attachments.d.ts +7 -0
- package/dist/utils/attachments.d.ts.map +1 -1
- package/dist/utils/attachments.js +22 -0
- package/dist/utils/attachments.js.map +1 -1
- package/dist/utils/content-type.d.ts +6 -0
- package/dist/utils/content-type.d.ts.map +1 -0
- package/dist/utils/content-type.js +43 -0
- package/dist/utils/content-type.js.map +1 -0
- package/dist/utils/file-upload.d.ts +51 -0
- package/dist/utils/file-upload.d.ts.map +1 -0
- package/dist/utils/file-upload.js +227 -0
- package/dist/utils/file-upload.js.map +1 -0
- package/dist/utils/html-to-markdown.d.ts +5 -2
- package/dist/utils/html-to-markdown.d.ts.map +1 -1
- package/dist/utils/html-to-markdown.js +92 -7
- package/dist/utils/html-to-markdown.js.map +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -75,6 +75,10 @@ To use this MCP server in Cursor/Claude/VS Code, add the following configuration
|
|
|
75
75
|
- **Hosted Content**
|
|
76
76
|
- Download hosted content (images, files) from chat and channel messages
|
|
77
77
|
- Access inline images and attachments shared in conversations
|
|
78
|
+
- **File Upload**
|
|
79
|
+
- Upload and send any file type (PDF, DOCX, XLSX, ZIP, images, etc.) to channels and chats
|
|
80
|
+
- Large file support (>4 MB) via resumable upload sessions
|
|
81
|
+
- Optional message text, custom filename, formatting, and importance levels
|
|
78
82
|
|
|
79
83
|
### 🔍 Advanced Search & Discovery
|
|
80
84
|
- **Message Search**
|
|
@@ -158,19 +162,23 @@ Use the `contentFormat` parameter to control how message content is returned:
|
|
|
158
162
|
|
|
159
163
|
### What Gets Converted
|
|
160
164
|
|
|
161
|
-
| HTML Element
|
|
162
|
-
|
|
163
|
-
| `<at id="0">Name</at>` (Teams mention) | `@Name` |
|
|
164
|
-
| `<strong>text</strong>`
|
|
165
|
-
| `<em>text</em>`
|
|
166
|
-
| `<code>text</code>`
|
|
167
|
-
| `<a href="url">text</a>`
|
|
168
|
-
| `<ul><li>item</li></ul>`
|
|
169
|
-
| `<table>...</table>`
|
|
170
|
-
| `<attachment id="...">`
|
|
171
|
-
| `<systemEventMessage/>`
|
|
172
|
-
| `<hr>`
|
|
173
|
-
| ` `, `&`, etc.
|
|
165
|
+
| HTML Element | Markdown Output |
|
|
166
|
+
| -------------------------------------- | -------------------------------------------------------- |
|
|
167
|
+
| `<at id="0">Name</at>` (Teams mention) | `@Name` (multi-word names merged using mentions metadata) |
|
|
168
|
+
| `<strong>text</strong>` | `**text**` |
|
|
169
|
+
| `<em>text</em>` | `*text*` |
|
|
170
|
+
| `<code>text</code>` | `` `text` `` |
|
|
171
|
+
| `<a href="url">text</a>` | `[text](url)` |
|
|
172
|
+
| `<ul><li>item</li></ul>` | `- item` |
|
|
173
|
+
| `<table>...</table>` | GFM Markdown table |
|
|
174
|
+
| `<attachment id="...">` | `{attachment:id}` |
|
|
175
|
+
| `<systemEventMessage/>` | *(removed)* |
|
|
176
|
+
| `<hr>` | `---` |
|
|
177
|
+
| ` `, `&`, etc. | Decoded to plain characters |
|
|
178
|
+
|
|
179
|
+
### Attachment Metadata
|
|
180
|
+
|
|
181
|
+
Messages that contain file attachments or inline images include an `attachments` array in the response with metadata for each attachment (id, name, contentType, contentUrl, thumbnailUrl). The inline `{attachment:id}` markers in the markdown content correlate with entries in this array, allowing consumers to identify and download attachments via `download_message_hosted_content` or `download_chat_hosted_content`.
|
|
174
182
|
|
|
175
183
|
### Example Usage
|
|
176
184
|
|
|
@@ -213,19 +221,28 @@ npm run auth
|
|
|
213
221
|
- Azure App Registration with Microsoft Graph permissions
|
|
214
222
|
|
|
215
223
|
### Required Microsoft Graph Permissions
|
|
224
|
+
|
|
225
|
+
**Full mode (default):**
|
|
216
226
|
- `User.Read` - Read user profile
|
|
217
227
|
- `User.ReadBasic.All` - Read basic user info
|
|
218
228
|
- `Team.ReadBasic.All` - Read team information
|
|
219
229
|
- `Channel.ReadBasic.All` - Read channel information
|
|
220
230
|
- `ChannelMessage.Read.All` - Read channel messages
|
|
221
|
-
- `ChannelMessage.Send` - Send channel messages
|
|
231
|
+
- `ChannelMessage.Send` - Send channel messages and replies
|
|
222
232
|
- `ChannelMessage.ReadWrite` - Edit and delete channel messages
|
|
223
|
-
- `Chat.Read` - Read chat messages
|
|
224
|
-
- `Chat.ReadWrite` - Create and manage chats
|
|
225
|
-
- `
|
|
226
|
-
- `
|
|
227
|
-
|
|
228
|
-
- `
|
|
233
|
+
- `Chat.Read` - Read chat messages (included via read-only scopes)
|
|
234
|
+
- `Chat.ReadWrite` - Create and manage chats, send/edit/delete chat messages (supersedes `Chat.Read`)
|
|
235
|
+
- `TeamMember.Read.All` - Read team members
|
|
236
|
+
- `Files.ReadWrite.All` - Required for file uploads to channels and chats
|
|
237
|
+
|
|
238
|
+
**Read-only mode** (`TEAMS_MCP_READ_ONLY=true`) — only these scopes are requested:
|
|
239
|
+
- `User.Read`
|
|
240
|
+
- `User.ReadBasic.All`
|
|
241
|
+
- `Team.ReadBasic.All`
|
|
242
|
+
- `Channel.ReadBasic.All`
|
|
243
|
+
- `ChannelMessage.Read.All`
|
|
244
|
+
- `TeamMember.Read.All`
|
|
245
|
+
- `Chat.Read`
|
|
229
246
|
|
|
230
247
|
## 🛠️ Usage
|
|
231
248
|
|
|
@@ -236,13 +253,54 @@ npm run dev
|
|
|
236
253
|
|
|
237
254
|
# Production mode
|
|
238
255
|
npm run build && node dist/index.js
|
|
256
|
+
|
|
257
|
+
# Start in read-only mode (disables all write tools)
|
|
258
|
+
TEAMS_MCP_READ_ONLY=true node dist/index.js
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Read-Only Mode
|
|
262
|
+
|
|
263
|
+
The server supports a read-only mode that disables all write operations (sending messages, creating chats, uploading files, editing/deleting messages) and requests only read-permission scopes from Microsoft Graph.
|
|
264
|
+
|
|
265
|
+
**Enable read-only mode** using either:
|
|
266
|
+
- Environment variable: `TEAMS_MCP_READ_ONLY=true`
|
|
267
|
+
- CLI flag: `--read-only`
|
|
268
|
+
|
|
269
|
+
**Authenticate with reduced scopes:**
|
|
270
|
+
```bash
|
|
271
|
+
npx @floriscornel/teams-mcp@latest authenticate --read-only
|
|
239
272
|
```
|
|
240
273
|
|
|
274
|
+
**MCP server configuration (read-only):**
|
|
275
|
+
```json
|
|
276
|
+
{
|
|
277
|
+
"mcpServers": {
|
|
278
|
+
"teams-mcp": {
|
|
279
|
+
"command": "npx",
|
|
280
|
+
"args": ["-y", "@floriscornel/teams-mcp@latest"],
|
|
281
|
+
"env": {
|
|
282
|
+
"TEAMS_MCP_READ_ONLY": "true"
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
**Switching modes:** When switching from read-only to full mode, the server detects the scope mismatch and warns you to re-authenticate:
|
|
290
|
+
```bash
|
|
291
|
+
npx @floriscornel/teams-mcp@latest authenticate
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Read-only tools (15):**
|
|
295
|
+
`auth_status`, `get_current_user`, `search_users`, `get_user`, `list_teams`, `list_channels`, `get_channel_messages`, `get_channel_message_replies`, `list_team_members`, `search_users_for_mentions`, `download_message_hosted_content`, `list_chats`, `get_chat_messages`, `search_messages`, `get_my_mentions`
|
|
296
|
+
|
|
297
|
+
**Write tools disabled in read-only mode (10):**
|
|
298
|
+
`send_channel_message`, `reply_to_channel_message`, `update_channel_message`, `delete_channel_message`, `send_file_to_channel`, `send_chat_message`, `create_chat`, `update_chat_message`, `delete_chat_message`, `send_file_to_chat`
|
|
299
|
+
|
|
241
300
|
### Available MCP Tools
|
|
242
301
|
|
|
243
302
|
#### Authentication
|
|
244
|
-
- `
|
|
245
|
-
- `logout` - Clear authentication tokens
|
|
303
|
+
- `auth_status` - Check current authentication status
|
|
246
304
|
- `get_current_user` - Get authenticated user information
|
|
247
305
|
|
|
248
306
|
#### User Operations
|
|
@@ -253,10 +311,14 @@ npm run build && node dist/index.js
|
|
|
253
311
|
- `list_teams` - List user's joined teams
|
|
254
312
|
- `list_channels` - List channels in a specific team
|
|
255
313
|
- `get_channel_messages` - Retrieve messages from a team channel with pagination and filtering
|
|
314
|
+
- `get_channel_message_replies` - Get replies to a specific channel message
|
|
256
315
|
- `send_channel_message` - Send a message to a team channel
|
|
316
|
+
- `reply_to_channel_message` - Reply to an existing channel message
|
|
257
317
|
- `update_channel_message` - Edit a previously sent channel message
|
|
258
318
|
- `delete_channel_message` - Soft delete a channel message (supports replies)
|
|
259
319
|
- `list_team_members` - List members of a specific team
|
|
320
|
+
- `search_users_for_mentions` - Search for team members to @mention in messages
|
|
321
|
+
- `send_file_to_channel` - Upload a local file and send it as a message to a channel
|
|
260
322
|
|
|
261
323
|
#### Chat Operations
|
|
262
324
|
- `list_chats` - List user's chats (1:1 and group)
|
|
@@ -265,13 +327,14 @@ npm run build && node dist/index.js
|
|
|
265
327
|
- `create_chat` - Create a new 1:1 or group chat
|
|
266
328
|
- `update_chat_message` - Edit a previously sent chat message
|
|
267
329
|
- `delete_chat_message` - Soft delete a chat message
|
|
330
|
+
- `send_file_to_chat` - Upload a local file and send it as a message to a chat
|
|
268
331
|
|
|
269
332
|
#### Media Operations
|
|
270
|
-
- `download_message_hosted_content` - Download hosted content (images, files) from messages
|
|
333
|
+
- `download_message_hosted_content` - Download hosted content (images, files) from channel messages
|
|
334
|
+
- `download_chat_hosted_content` - Download hosted content (images, files) from chat messages
|
|
271
335
|
|
|
272
336
|
#### Search Operations
|
|
273
337
|
- `search_messages` - Search across all Teams messages using KQL syntax
|
|
274
|
-
- `get_recent_messages` - Get recent messages with advanced filtering options
|
|
275
338
|
- `get_my_mentions` - Find messages mentioning the current user
|
|
276
339
|
|
|
277
340
|
## 📋 Examples
|
|
@@ -281,7 +344,11 @@ npm run build && node dist/index.js
|
|
|
281
344
|
First, authenticate with Microsoft Graph:
|
|
282
345
|
|
|
283
346
|
```bash
|
|
347
|
+
# Full access (default)
|
|
284
348
|
npx @floriscornel/teams-mcp@latest authenticate
|
|
349
|
+
|
|
350
|
+
# Read-only (reduced permission scopes)
|
|
351
|
+
npx @floriscornel/teams-mcp@latest authenticate --read-only
|
|
285
352
|
```
|
|
286
353
|
|
|
287
354
|
Check your authentication status:
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { PublicClientApplication, } from "@azure/msal-node";
|
|
|
6
6
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
7
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
8
8
|
import { cachePlugin } from "./msal-cache.js";
|
|
9
|
-
import { GraphService } from "./services/graph.js";
|
|
9
|
+
import { FULL_SCOPES, GraphService, READ_ONLY_SCOPES } from "./services/graph.js";
|
|
10
10
|
import { registerAuthTools } from "./tools/auth.js";
|
|
11
11
|
import { registerChatTools } from "./tools/chats.js";
|
|
12
12
|
import { registerSearchTools } from "./tools/search.js";
|
|
@@ -16,23 +16,27 @@ import { registerUsersTools } from "./tools/users.js";
|
|
|
16
16
|
const CLIENT_ID = "14d82eec-204b-4c2f-b7e8-296a70dab67e";
|
|
17
17
|
const AUTHORITY = "https://login.microsoftonline.com/common";
|
|
18
18
|
const AUTH_INFO_PATH = join(homedir(), ".msgraph-mcp-auth.json");
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
19
|
+
/** Check whether CLI args contain --read-only. */
|
|
20
|
+
function hasReadOnlyFlag(args) {
|
|
21
|
+
return args.includes("--read-only");
|
|
22
|
+
}
|
|
23
|
+
/** Read the persisted auth info file (best-effort). */
|
|
24
|
+
async function readAuthInfo() {
|
|
25
|
+
try {
|
|
26
|
+
const data = await fs.readFile(AUTH_INFO_PATH, "utf8");
|
|
27
|
+
return JSON.parse(data);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return undefined;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
31
33
|
// Authentication functions
|
|
32
|
-
async function authenticate() {
|
|
34
|
+
async function authenticate(readOnly) {
|
|
35
|
+
const scopes = readOnly ? READ_ONLY_SCOPES : FULL_SCOPES;
|
|
36
|
+
const modeLabel = readOnly ? "read-only" : "full access";
|
|
33
37
|
console.log("🔐 Microsoft Graph Authentication for MCP Server");
|
|
34
38
|
console.log("=".repeat(50));
|
|
35
|
-
console.log(
|
|
39
|
+
console.log(`Using Microsoft Graph CLI app (${modeLabel})`);
|
|
36
40
|
try {
|
|
37
41
|
console.log("\n📱 Using device code flow...");
|
|
38
42
|
const msalConfig = {
|
|
@@ -46,7 +50,7 @@ async function authenticate() {
|
|
|
46
50
|
};
|
|
47
51
|
const client = new PublicClientApplication(msalConfig);
|
|
48
52
|
const result = await client.acquireTokenByDeviceCode({
|
|
49
|
-
scopes
|
|
53
|
+
scopes,
|
|
50
54
|
deviceCodeCallback: (response) => {
|
|
51
55
|
console.log("\n📱 Please complete authentication:");
|
|
52
56
|
console.log(`🌐 Visit: ${response.verificationUri}`);
|
|
@@ -62,10 +66,12 @@ async function authenticate() {
|
|
|
62
66
|
timestamp: new Date().toISOString(),
|
|
63
67
|
expiresAt: result.expiresOn?.toISOString(),
|
|
64
68
|
account: result.account?.username,
|
|
69
|
+
grantedScopes: result.scopes,
|
|
65
70
|
};
|
|
66
71
|
await fs.writeFile(AUTH_INFO_PATH, JSON.stringify(authInfo, null, 2));
|
|
67
72
|
console.log("\n✅ Authentication successful!");
|
|
68
73
|
console.log(`👤 Signed in as: ${result.account?.username || "Unknown"}`);
|
|
74
|
+
console.log(`🔒 Mode: ${modeLabel}`);
|
|
69
75
|
console.log(`💾 Credentials saved to: ${AUTH_INFO_PATH}`);
|
|
70
76
|
console.log("🔄 Refresh token cached for automatic renewal");
|
|
71
77
|
console.log("\n🚀 You can now use the MCP server in Cursor!");
|
|
@@ -96,6 +102,18 @@ async function checkAuth() {
|
|
|
96
102
|
console.log("✅ Authentication found");
|
|
97
103
|
console.log(`👤 Account: ${authInfo.account || "Unknown"}`);
|
|
98
104
|
console.log(`📅 Authenticated on: ${authInfo.timestamp}`);
|
|
105
|
+
// Show granted scope mode
|
|
106
|
+
const grantedScopes = authInfo.grantedScopes;
|
|
107
|
+
if (grantedScopes) {
|
|
108
|
+
const hasWriteScopes = grantedScopes.some((s) => s === "ChannelMessage.Send" ||
|
|
109
|
+
s === "ChannelMessage.ReadWrite" ||
|
|
110
|
+
s === "Chat.ReadWrite" ||
|
|
111
|
+
s === "Files.ReadWrite.All");
|
|
112
|
+
console.log(`🔒 Scope mode: ${hasWriteScopes ? "full access" : "read-only"}`);
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
console.log("⚠️ Scope mode: unknown (authenticated before read-only support)");
|
|
116
|
+
}
|
|
99
117
|
// Check if we have expiration info
|
|
100
118
|
if (authInfo.expiresAt) {
|
|
101
119
|
const expiresAt = new Date(authInfo.expiresAt);
|
|
@@ -140,34 +158,56 @@ async function logout() {
|
|
|
140
158
|
console.log("🔄 Run 'npx @floriscornel/teams-mcp@latest authenticate' to re-authenticate");
|
|
141
159
|
}
|
|
142
160
|
// MCP Server setup
|
|
143
|
-
async function startMcpServer() {
|
|
161
|
+
async function startMcpServer(readOnly) {
|
|
144
162
|
// Create MCP server
|
|
145
163
|
const server = new McpServer({
|
|
146
164
|
name: "teams-mcp",
|
|
147
|
-
version: "0.
|
|
165
|
+
version: "0.8.0",
|
|
148
166
|
});
|
|
149
167
|
// Initialize Graph service (singleton)
|
|
150
168
|
const graphService = GraphService.getInstance();
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
169
|
+
graphService.readOnlyMode = readOnly;
|
|
170
|
+
// Detect scope mismatch: warn when switching from read-only → full mode
|
|
171
|
+
if (!readOnly && !process.env.AUTH_TOKEN) {
|
|
172
|
+
const authInfo = await readAuthInfo();
|
|
173
|
+
if (authInfo) {
|
|
174
|
+
const grantedScopes = authInfo.grantedScopes;
|
|
175
|
+
const hasWriteScopes = grantedScopes?.some((s) => s === "ChannelMessage.Send" ||
|
|
176
|
+
s === "ChannelMessage.ReadWrite" ||
|
|
177
|
+
s === "Chat.ReadWrite" ||
|
|
178
|
+
s === "Files.ReadWrite.All");
|
|
179
|
+
if (grantedScopes && !hasWriteScopes) {
|
|
180
|
+
console.error("⚠️ Warning: You authenticated with read-only scopes but the server is running in full mode.");
|
|
181
|
+
console.error(" Write operations may fail. Re-authenticate without --read-only:");
|
|
182
|
+
console.error(" npx @floriscornel/teams-mcp@latest authenticate");
|
|
183
|
+
}
|
|
184
|
+
else if (!grantedScopes) {
|
|
185
|
+
console.error("⚠️ Warning: Could not determine granted scopes. If you experience permission errors,");
|
|
186
|
+
console.error(" re-authenticate: npx @floriscornel/teams-mcp@latest authenticate");
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
// Register all tools (write tools are skipped when readOnly is true)
|
|
191
|
+
registerAuthTools(server, graphService, readOnly);
|
|
192
|
+
registerUsersTools(server, graphService, readOnly);
|
|
193
|
+
registerTeamsTools(server, graphService, readOnly);
|
|
194
|
+
registerChatTools(server, graphService, readOnly);
|
|
195
|
+
registerSearchTools(server, graphService, readOnly);
|
|
157
196
|
// Start server
|
|
158
197
|
const transport = new StdioServerTransport();
|
|
159
198
|
await server.connect(transport);
|
|
160
|
-
console.error(
|
|
199
|
+
console.error(`Microsoft Graph MCP Server started${readOnly ? " (read-only mode)" : ""}`);
|
|
161
200
|
}
|
|
162
201
|
// Main function to handle both CLI and MCP server modes
|
|
163
202
|
async function main() {
|
|
164
203
|
const args = process.argv.slice(2);
|
|
165
|
-
const command = args
|
|
204
|
+
const command = args.find((arg) => arg !== "--read-only");
|
|
205
|
+
const readOnly = hasReadOnlyFlag(args) || process.env.TEAMS_MCP_READ_ONLY === "true";
|
|
166
206
|
// CLI commands
|
|
167
207
|
switch (command) {
|
|
168
208
|
case "authenticate":
|
|
169
209
|
case "auth":
|
|
170
|
-
await authenticate();
|
|
210
|
+
await authenticate(readOnly);
|
|
171
211
|
return;
|
|
172
212
|
case "check":
|
|
173
213
|
await checkAuth();
|
|
@@ -181,14 +221,19 @@ async function main() {
|
|
|
181
221
|
console.log("Microsoft Graph MCP Server");
|
|
182
222
|
console.log("");
|
|
183
223
|
console.log("Usage:");
|
|
184
|
-
console.log(" npx @floriscornel/teams-mcp@latest authenticate
|
|
185
|
-
console.log(" npx @floriscornel/teams-mcp@latest
|
|
186
|
-
console.log(" npx @floriscornel/teams-mcp@latest
|
|
187
|
-
console.log(" npx @floriscornel/teams-mcp@latest
|
|
224
|
+
console.log(" npx @floriscornel/teams-mcp@latest authenticate # Authenticate with full scopes");
|
|
225
|
+
console.log(" npx @floriscornel/teams-mcp@latest authenticate --read-only # Authenticate with read-only scopes");
|
|
226
|
+
console.log(" npx @floriscornel/teams-mcp@latest check # Check authentication status");
|
|
227
|
+
console.log(" npx @floriscornel/teams-mcp@latest logout # Clear authentication");
|
|
228
|
+
console.log(" npx @floriscornel/teams-mcp@latest # Start MCP server (default)");
|
|
229
|
+
console.log("");
|
|
230
|
+
console.log("Environment variables:");
|
|
231
|
+
console.log(" TEAMS_MCP_READ_ONLY=true # Start MCP server in read-only mode");
|
|
232
|
+
console.log(" AUTH_TOKEN=<jwt> # Use a pre-existing access token");
|
|
188
233
|
return;
|
|
189
234
|
case undefined:
|
|
190
235
|
// No command = start MCP server
|
|
191
|
-
await startMcpServer();
|
|
236
|
+
await startMcpServer(readOnly);
|
|
192
237
|
return;
|
|
193
238
|
default:
|
|
194
239
|
console.error(`Unknown command: ${command}`);
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAGL,uBAAuB,GACxB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,QAAQ,IAAI,EAAE,EAAE,MAAM,SAAS,C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AAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,kBAAkB,EAAE,KAAK,CAAC,CAAC;IACzC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/services/graph.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { Client } from "@microsoft/microsoft-graph-client";
|
|
2
|
+
/** Scopes sufficient for read-only operations (no message sending, no file uploads). */
|
|
3
|
+
export declare const READ_ONLY_SCOPES: string[];
|
|
4
|
+
/** Full scopes including write operations. */
|
|
5
|
+
export declare const FULL_SCOPES: string[];
|
|
2
6
|
export interface AuthStatus {
|
|
3
7
|
isAuthenticated: boolean;
|
|
4
8
|
userPrincipalName?: string | undefined;
|
|
@@ -12,7 +16,13 @@ export declare class GraphService {
|
|
|
12
16
|
private tokenExpiresAt;
|
|
13
17
|
private msalApp;
|
|
14
18
|
private msalAccount;
|
|
19
|
+
private _readOnlyMode;
|
|
15
20
|
static getInstance(): GraphService;
|
|
21
|
+
/** Whether the service operates in read-only mode (reduced permission scopes). */
|
|
22
|
+
get readOnlyMode(): boolean;
|
|
23
|
+
set readOnlyMode(value: boolean);
|
|
24
|
+
/** Returns the scopes to request based on the current mode. */
|
|
25
|
+
get scopes(): string[];
|
|
16
26
|
private initializeClient;
|
|
17
27
|
private acquireToken;
|
|
18
28
|
getAuthStatus(): Promise<AuthStatus>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/services/graph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"graph.d.ts","sourceRoot":"","sources":["../../src/services/graph.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAM3D,wFAAwF;AACxF,eAAO,MAAM,gBAAgB,UAQ5B,CAAC;AAEF,8CAA8C;AAC9C,eAAO,MAAM,WAAW,UAMvB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,eAAe,EAAE,OAAO,CAAC;IACzB,iBAAiB,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CAChC;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAe;IACtC,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,cAAc,CAAmB;IACzC,OAAO,CAAC,OAAO,CAAsC;IACrD,OAAO,CAAC,WAAW,CAA0B;IAC7C,OAAO,CAAC,aAAa,CAAS;IAE9B,MAAM,CAAC,WAAW,IAAI,YAAY;IAOlC,kFAAkF;IAClF,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,IAAI,YAAY,CAAC,KAAK,EAAE,OAAO,EAE9B;IAED,+DAA+D;IAC/D,IAAI,MAAM,IAAI,MAAM,EAAE,CAErB;YAEa,gBAAgB;YA8DhB,YAAY;IAoBpB,aAAa,IAAI,OAAO,CAAC,UAAU,CAAC;IAqBpC,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAWlC,eAAe,IAAI,OAAO;IAI1B,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;CAqBjD"}
|
package/dist/services/graph.js
CHANGED
|
@@ -3,16 +3,23 @@ import { Client } from "@microsoft/microsoft-graph-client";
|
|
|
3
3
|
import { cachePlugin } from "../msal-cache.js";
|
|
4
4
|
const CLIENT_ID = "14d82eec-204b-4c2f-b7e8-296a70dab67e";
|
|
5
5
|
const AUTHORITY = "https://login.microsoftonline.com/common";
|
|
6
|
-
|
|
6
|
+
/** Scopes sufficient for read-only operations (no message sending, no file uploads). */
|
|
7
|
+
export const READ_ONLY_SCOPES = [
|
|
7
8
|
"User.Read",
|
|
8
9
|
"User.ReadBasic.All",
|
|
9
10
|
"Team.ReadBasic.All",
|
|
10
11
|
"Channel.ReadBasic.All",
|
|
11
12
|
"ChannelMessage.Read.All",
|
|
12
|
-
"ChannelMessage.Send",
|
|
13
13
|
"TeamMember.Read.All",
|
|
14
|
-
"Chat.
|
|
14
|
+
"Chat.Read",
|
|
15
|
+
];
|
|
16
|
+
/** Full scopes including write operations. */
|
|
17
|
+
export const FULL_SCOPES = [
|
|
18
|
+
...READ_ONLY_SCOPES,
|
|
19
|
+
"ChannelMessage.Send",
|
|
20
|
+
"ChannelMessage.ReadWrite",
|
|
15
21
|
"Chat.ReadWrite",
|
|
22
|
+
"Files.ReadWrite.All",
|
|
16
23
|
];
|
|
17
24
|
export class GraphService {
|
|
18
25
|
static instance;
|
|
@@ -21,12 +28,24 @@ export class GraphService {
|
|
|
21
28
|
tokenExpiresAt;
|
|
22
29
|
msalApp;
|
|
23
30
|
msalAccount;
|
|
31
|
+
_readOnlyMode = false;
|
|
24
32
|
static getInstance() {
|
|
25
33
|
if (!GraphService.instance) {
|
|
26
34
|
GraphService.instance = new GraphService();
|
|
27
35
|
}
|
|
28
36
|
return GraphService.instance;
|
|
29
37
|
}
|
|
38
|
+
/** Whether the service operates in read-only mode (reduced permission scopes). */
|
|
39
|
+
get readOnlyMode() {
|
|
40
|
+
return this._readOnlyMode;
|
|
41
|
+
}
|
|
42
|
+
set readOnlyMode(value) {
|
|
43
|
+
this._readOnlyMode = value;
|
|
44
|
+
}
|
|
45
|
+
/** Returns the scopes to request based on the current mode. */
|
|
46
|
+
get scopes() {
|
|
47
|
+
return this._readOnlyMode ? READ_ONLY_SCOPES : FULL_SCOPES;
|
|
48
|
+
}
|
|
30
49
|
async initializeClient() {
|
|
31
50
|
if (this.isInitialized)
|
|
32
51
|
return;
|
|
@@ -62,7 +81,7 @@ export class GraphService {
|
|
|
62
81
|
this.msalAccount = accounts[0];
|
|
63
82
|
// Verify we can acquire a token
|
|
64
83
|
const result = await this.msalApp.acquireTokenSilent({
|
|
65
|
-
scopes:
|
|
84
|
+
scopes: this.scopes,
|
|
66
85
|
account: this.msalAccount,
|
|
67
86
|
});
|
|
68
87
|
if (!result) {
|
|
@@ -86,7 +105,7 @@ export class GraphService {
|
|
|
86
105
|
throw new Error("MSAL not initialized");
|
|
87
106
|
}
|
|
88
107
|
const result = await this.msalApp.acquireTokenSilent({
|
|
89
|
-
scopes:
|
|
108
|
+
scopes: this.scopes,
|
|
90
109
|
account: this.msalAccount,
|
|
91
110
|
});
|
|
92
111
|
if (!result) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/services/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,SAAS,GAAG,sCAAsC,CAAC;AACzD,MAAM,SAAS,GAAG,0CAA0C,CAAC;AAE7D,MAAM,gBAAgB,GAAG;
|
|
1
|
+
{"version":3,"file":"graph.js","sourceRoot":"","sources":["../../src/services/graph.ts"],"names":[],"mappings":"AAAA,OAAO,EAAoB,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,MAAM,SAAS,GAAG,sCAAsC,CAAC;AACzD,MAAM,SAAS,GAAG,0CAA0C,CAAC;AAE7D,wFAAwF;AACxF,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,WAAW;IACX,oBAAoB;IACpB,oBAAoB;IACpB,uBAAuB;IACvB,yBAAyB;IACzB,qBAAqB;IACrB,WAAW;CACZ,CAAC;AAEF,8CAA8C;AAC9C,MAAM,CAAC,MAAM,WAAW,GAA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,MAAM,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CACb,kHAAkH,CACnH,CAAC;QACJ,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED,eAAe;QACb,OAAO,CAAC,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,aAAa,CAAC;IAC7C,CAAC;IAED,aAAa,CAAC,KAAa;QACzB,MAAM,WAAW,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC7B,OAAO,CAAC,KAAK,CAAC,mCAAmC,CAAC,CAAC;YACnD,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,IAAI,CAAC;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACjD,MAAM,SAAS,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YAC3E,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,6BAA6B,CAAC,EAAE,CAAC;gBACvD,OAAO,CAAC,KAAK,CAAC,sDAAsD,CAAC,CAAC;gBACtE,OAAO,SAAS,CAAC;YACnB,CAAC;QACH,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,4CAA4C,EAAE,KAAK,CAAC,CAAC;YACnE,OAAO,SAAS,CAAC;QACnB,CAAC;QAED,OAAO,KAAK,CAAC;IACf,CAAC;CACF"}
|
package/dist/tools/auth.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
2
|
import type { GraphService } from "../services/graph.js";
|
|
3
|
-
export declare function registerAuthTools(server: McpServer, graphService: GraphService): void;
|
|
3
|
+
export declare function registerAuthTools(server: McpServer, graphService: GraphService, _readOnly: boolean): void;
|
|
4
4
|
//# sourceMappingURL=auth.d.ts.map
|
package/dist/tools/auth.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,wBAAgB,iBAAiB,
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAEzD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,YAAY,EAC1B,SAAS,EAAE,OAAO,QAqBnB"}
|
package/dist/tools/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export function registerAuthTools(server, graphService) {
|
|
1
|
+
export function registerAuthTools(server, graphService, _readOnly) {
|
|
2
2
|
// Authentication status tool
|
|
3
3
|
server.tool("auth_status", "Check the authentication status of the Microsoft Graph connection. Returns whether the user is authenticated and shows their basic profile information.", {}, async () => {
|
|
4
4
|
const status = await graphService.getAuthStatus();
|
package/dist/tools/auth.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,iBAAiB,
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/tools/auth.ts"],"names":[],"mappings":"AAGA,MAAM,UAAU,iBAAiB,CAC/B,MAAiB,EACjB,YAA0B,EAC1B,SAAkB;IAElB,6BAA6B;IAC7B,MAAM,CAAC,IAAI,CACT,aAAa,EACb,yJAAyJ,EACzJ,EAAE,EACF,KAAK,IAAI,EAAE;QACT,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,aAAa,EAAE,CAAC;QAClD,OAAO;YACL,OAAO,EAAE;gBACP;oBACE,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,MAAM,CAAC,eAAe;wBAC1B,CAAC,CAAC,sBAAsB,MAAM,CAAC,WAAW,IAAI,cAAc,KAAK,MAAM,CAAC,iBAAiB,IAAI,oBAAoB,GAAG;wBACpH,CAAC,CAAC,kFAAkF;iBACvF;aACF;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC"}
|
package/dist/tools/chats.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { GraphService } from "../services/graph.js";
|
|
|
7
7
|
*
|
|
8
8
|
* @param server - The MCP server instance to register tools on.
|
|
9
9
|
* @param graphService - The Microsoft Graph service used for API calls.
|
|
10
|
+
* @param readOnly - When true, skips registration of write tools (send, create, update, delete, file upload).
|
|
10
11
|
*/
|
|
11
|
-
export declare function registerChatTools(server: McpServer, graphService: GraphService): void;
|
|
12
|
+
export declare function registerChatTools(server: McpServer, graphService: GraphService, readOnly: boolean): void;
|
|
12
13
|
//# sourceMappingURL=chats.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chats.d.ts","sourceRoot":"","sources":["../../src/tools/chats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"chats.d.ts","sourceRoot":"","sources":["../../src/tools/chats.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAEzE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAuBzD;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,SAAS,EACjB,YAAY,EAAE,YAAY,EAC1B,QAAQ,EAAE,OAAO,QA83BlB"}
|