@softeria/ms-365-mcp-server 0.180.7 → 0.181.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/PRESETS.md CHANGED
@@ -10,14 +10,14 @@ Every preset also includes the account tools (`login`, `logout`, `verify-login`,
10
10
 
11
11
  | Preset | Mode | Tools | Scopes | Org mode | Description |
12
12
  | ------------- | ---------------------------------------------------------------- | ---------: | -------: | -------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
13
- | `all` | [full](#all-full)<br>[read only](#all-read-only) | 370<br>180 | 63<br>37 | -<br>- | All available tools |
13
+ | `all` | [full](#all-full)<br>[read only](#all-read-only) | 370<br>180 | 65<br>38 | -<br>- | All available tools |
14
14
  | `calendar` | [full](#calendar-full)<br>[read only](#calendar-read-only) | 47<br>22 | 7<br>5 | -<br>- | Calendar and event management |
15
15
  | `contacts` | [full](#contacts-full)<br>[read only](#contacts-read-only) | 15<br>7 | 1<br>1 | -<br>- | Outlook contacts management |
16
16
  | `excel` | [full](#excel-full)<br>[read only](#excel-read-only) | 25<br>9 | 1<br>1 | -<br>- | Excel spreadsheet operations |
17
17
  | `files` | [full](#files-full)<br>[read only](#files-read-only) | 25<br>14 | 3<br>2 | -<br>- | OneDrive file and folder operations |
18
18
  | `mail` | [full](#mail-full)<br>[read only](#mail-read-only) | 50<br>19 | 5<br>3 | -<br>- | Email operations (read, send, manage folders, attachments) |
19
19
  | `onedrive` | [full](#onedrive-full)<br>[read only](#onedrive-read-only) | 23<br>12 | 2<br>1 | -<br>- | OneDrive app only: drive and file operations, excluding Excel |
20
- | `onenote` | [full](#onenote-full)<br>[read only](#onenote-read-only) | 29<br>17 | 3<br>1 | -<br>- | OneNote notebook operations |
20
+ | `onenote` | [full](#onenote-full)<br>[read only](#onenote-read-only) | 29<br>17 | 5<br>2 | -<br>- | OneNote notebook operations |
21
21
  | `outlook` | [full](#outlook-full)<br>[read only](#outlook-read-only) | 97<br>37 | 8<br>6 | -<br>- | Outlook app only: mail, calendar and contacts |
22
22
  | `personal` | [full](#personal-full)<br>[read only](#personal-read-only) | 178<br>74 | 20<br>15 | -<br>- | Personal productivity tools (mail, calendar, files, contacts, tasks, notes, search) |
23
23
  | `search` | [full](#search-full)<br>[read only](#search-read-only) | 7<br>7 | 8<br>8 | -<br>- | Microsoft Search capabilities |
@@ -25,7 +25,7 @@ Every preset also includes the account tools (`login`, `logout`, `verify-login`,
25
25
  | `teams` | [full](#teams-full)<br>[read only](#teams-read-only) | 73<br>43 | 31<br>18 | required<br>required | Teams app only: chats, channels, meetings and presence |
26
26
  | `teams-write` | [full](#teams-write-full)<br>[read only](#teams-write-read-only) | 11<br>7 | 6<br>3 | required<br>required | Teams send-only: send/reply in chats and channels, list chats/teams/channels by name, activity notifications - no message reading |
27
27
  | `users` | [full](#users-full)<br>[read only](#users-read-only) | 11<br>11 | 4<br>4 | required<br>required | User directory access |
28
- | `work` | [full](#work-full)<br>[read only](#work-read-only) | 190<br>110 | 56<br>33 | required<br>required | Organization/work tools (Teams, SharePoint, shared mailboxes, search) |
28
+ | `work` | [full](#work-full)<br>[read only](#work-read-only) | 190<br>110 | 55<br>33 | required<br>required | Organization/work tools (Teams, SharePoint, shared mailboxes, search) |
29
29
 
30
30
  ## `all` full
31
31
 
@@ -404,7 +404,7 @@ Tools (370):
404
404
  - `upload-file-content`
405
405
  - `upload-my-profile-photo`
406
406
 
407
- Scopes (63):
407
+ Scopes (65):
408
408
 
409
409
  - `Calendars.Read.Shared`
410
410
  - `Calendars.ReadWrite`
@@ -439,7 +439,9 @@ Scopes (63):
439
439
  - `MailboxSettings.ReadWrite`
440
440
  - `Notes.Create`
441
441
  - `Notes.Read`
442
+ - `Notes.Read.All`
442
443
  - `Notes.ReadWrite`
444
+ - `Notes.ReadWrite.All`
443
445
  - `OnlineMeetingArtifact.Read.All`
444
446
  - `OnlineMeetingRecording.Read.All`
445
447
  - `OnlineMeetings.Read`
@@ -657,7 +659,7 @@ Tools (180):
657
659
  - `search-query`
658
660
  - `search-sharepoint-sites`
659
661
 
660
- Scopes (37):
662
+ Scopes (38):
661
663
 
662
664
  - `Calendars.Read`
663
665
  - `Calendars.Read.Shared`
@@ -677,6 +679,7 @@ Scopes (37):
677
679
  - `Mail.Read.Shared`
678
680
  - `MailboxSettings.Read`
679
681
  - `Notes.Read`
682
+ - `Notes.Read.All`
680
683
  - `OnlineMeetingArtifact.Read.All`
681
684
  - `OnlineMeetingRecording.Read.All`
682
685
  - `OnlineMeetings.Read`
@@ -1153,11 +1156,13 @@ Tools (29):
1153
1156
  - `update-onenote-page-content`
1154
1157
  - `update-sharepoint-site-onenote-page-content`
1155
1158
 
1156
- Scopes (3):
1159
+ Scopes (5):
1157
1160
 
1158
1161
  - `Notes.Create`
1159
1162
  - `Notes.Read`
1163
+ - `Notes.Read.All`
1160
1164
  - `Notes.ReadWrite`
1165
+ - `Notes.ReadWrite.All`
1161
1166
 
1162
1167
  ## `onenote` read only
1163
1168
 
@@ -1183,9 +1188,10 @@ Tools (17):
1183
1188
  - `list-sharepoint-site-onenote-section-group-sections`
1184
1189
  - `list-sharepoint-site-onenote-section-pages`
1185
1190
 
1186
- Scopes (1):
1191
+ Scopes (2):
1187
1192
 
1188
1193
  - `Notes.Read`
1194
+ - `Notes.Read.All`
1189
1195
 
1190
1196
  ## `outlook` full
1191
1197
 
@@ -2278,7 +2284,7 @@ Tools (190):
2278
2284
  - `update-team-channel`
2279
2285
  - `upload-attachment-from-file`
2280
2286
 
2281
- Scopes (56):
2287
+ Scopes (55):
2282
2288
 
2283
2289
  - `Calendars.Read`
2284
2290
  - `Calendars.Read.Shared`
@@ -2306,9 +2312,8 @@ Scopes (56):
2306
2312
  - `Mail.Read.Shared`
2307
2313
  - `Mail.ReadWrite.Shared`
2308
2314
  - `Mail.Send.Shared`
2309
- - `Notes.Create`
2310
- - `Notes.Read`
2311
- - `Notes.ReadWrite`
2315
+ - `Notes.Read.All`
2316
+ - `Notes.ReadWrite.All`
2312
2317
  - `OnlineMeetingArtifact.Read.All`
2313
2318
  - `OnlineMeetingRecording.Read.All`
2314
2319
  - `OnlineMeetings.Read`
@@ -2472,7 +2477,7 @@ Scopes (33):
2472
2477
  - `GroupMember.Read.All`
2473
2478
  - `Mail.Read`
2474
2479
  - `Mail.Read.Shared`
2475
- - `Notes.Read`
2480
+ - `Notes.Read.All`
2476
2481
  - `OnlineMeetingArtifact.Read.All`
2477
2482
  - `OnlineMeetingRecording.Read.All`
2478
2483
  - `OnlineMeetings.Read`
@@ -1407,6 +1407,146 @@ describe("graph-tools", () => {
1407
1407
  expect(path).toContain("$top=5");
1408
1408
  expect(path).toContain("$skiptoken=tok");
1409
1409
  });
1410
+ it("points a deltaToken tool at token when skiptoken gets a token= link", async () => {
1411
+ mockEndpoints.push(makeEndpoint({ alias: "drive-delta", path: "/me/drive/delta()" }));
1412
+ mockEndpointsJson = [
1413
+ makeConfig({ toolName: "drive-delta", pathPattern: "/me/drive/delta()", deltaToken: true })
1414
+ ];
1415
+ const graphClient = createMockGraphClient();
1416
+ const server = createMockServer();
1417
+ const { registerGraphTools } = await loadModule();
1418
+ registerGraphTools(server, graphClient);
1419
+ const result = await server.tools.get("drive-delta").handler({
1420
+ skiptoken: "https://graph.microsoft.com/v1.0/me/drive/delta?token=abc"
1421
+ });
1422
+ const payload = JSON.parse(result.content[0].text);
1423
+ expect(payload.error).toBe("invalid_skiptoken");
1424
+ expect(payload.message).toContain("pass that link as token");
1425
+ expect(graphClient.graphRequest).not.toHaveBeenCalled();
1426
+ });
1427
+ });
1428
+ describe("delta token", () => {
1429
+ const deltaEndpoint = () => makeEndpoint({
1430
+ alias: "items-delta",
1431
+ path: "/sites/:siteId/lists/:listId/items/delta()",
1432
+ parameters: [
1433
+ { name: "select", type: "Query", schema: z.string().optional() },
1434
+ { name: "expand", type: "Query", schema: z.string().optional() },
1435
+ { name: "top", type: "Query", schema: z.number().optional() }
1436
+ ]
1437
+ });
1438
+ const register = async (deltaToken) => {
1439
+ mockEndpoints.push(deltaEndpoint());
1440
+ mockEndpointsJson = [
1441
+ makeConfig({
1442
+ toolName: "items-delta",
1443
+ pathPattern: "/sites/{site-id}/lists/{list-id}/items/delta()",
1444
+ queryParams: ["select", "expand", "top"],
1445
+ ...deltaToken === void 0 ? {} : { deltaToken }
1446
+ })
1447
+ ];
1448
+ const graphClient = createMockGraphClient();
1449
+ const server = createMockServer();
1450
+ const { registerGraphTools } = await loadModule();
1451
+ registerGraphTools(server, graphClient);
1452
+ return { server, graphClient };
1453
+ };
1454
+ const callForResult = async (args) => {
1455
+ const { server, graphClient } = await register(true);
1456
+ const result = await server.tools.get("items-delta").handler({
1457
+ siteId: "s1",
1458
+ listId: "l1",
1459
+ ...args
1460
+ });
1461
+ return { result, graphClient };
1462
+ };
1463
+ const callWith = async (args) => {
1464
+ const { result, graphClient } = await callForResult(args);
1465
+ expect(result.isError).not.toBe(true);
1466
+ return graphClient.graphRequest.mock.calls[0][0];
1467
+ };
1468
+ it("advertises token on a deltaToken tool", async () => {
1469
+ const { server } = await register(true);
1470
+ expect(server.tools.get("items-delta").schema.token).toBeDefined();
1471
+ });
1472
+ it.each([void 0, false])("omits token when deltaToken is %s", async (flag) => {
1473
+ const { server } = await register(flag);
1474
+ expect(server.tools.get("items-delta").schema.token).toBeUndefined();
1475
+ });
1476
+ it("shows token in discovery mode only on a deltaToken tool", async () => {
1477
+ const { describeToolSchema } = await import("../lib/tool-schema.js");
1478
+ const names = (deltaToken) => describeToolSchema(deltaEndpoint(), {
1479
+ queryParams: ["select", "expand", "top"],
1480
+ deltaToken
1481
+ }).parameters.map((p) => p.name);
1482
+ expect(names(true)).toContain("token");
1483
+ expect(names()).not.toContain("token");
1484
+ });
1485
+ it("sends a bare token as token=", async () => {
1486
+ const path = await callWith({ token: "abc123" });
1487
+ expect(path).toBe("/sites/s1/lists/l1/items/delta()?token=abc123");
1488
+ });
1489
+ it("sends latest as token=latest", async () => {
1490
+ const path = await callWith({ token: "latest" });
1491
+ expect(path).toContain("?token=latest");
1492
+ });
1493
+ it("reads the token out of a whole @odata.deltaLink", async () => {
1494
+ const path = await callWith({
1495
+ token: "https://graph.microsoft.com/v1.0/sites/s1/lists/l1/items/delta?token=MzslMjM0OyUyMzE7Mw"
1496
+ });
1497
+ expect(path).toBe("/sites/s1/lists/l1/items/delta()?token=MzslMjM0OyUyMzE7Mw");
1498
+ });
1499
+ it("reads the token out of a @odata.nextLink with params after it", async () => {
1500
+ const path = await callWith({
1501
+ token: "https://graph.microsoft.com/v1.0/sites/s1/lists/l1/items/delta?token=tok1&$top=5",
1502
+ top: 5
1503
+ });
1504
+ expect(path).toContain("token=tok1");
1505
+ expect(path).not.toContain("tok1%26");
1506
+ expect(path).not.toContain("graph.microsoft.com");
1507
+ });
1508
+ it.each([
1509
+ ["token=tok1", "tok1"],
1510
+ ["https://graph.microsoft.com/v1.0/me/drive/root/delta(token='tok1')", "tok1"],
1511
+ ["https://graph.microsoft.com/v1.0/me/drive/root/delta?(token='tok1')", "tok1"],
1512
+ ["https://graph.microsoft.com/v1.0/me/drive/delta(token=tok1)", "tok1"]
1513
+ ])("reads the token out of %s", async (value, expected) => {
1514
+ const path = await callWith({ token: value });
1515
+ expect(path).toContain(`?token=${expected}`);
1516
+ expect(path).not.toContain("'");
1517
+ });
1518
+ it("percent-decodes a token copied out of a link once, so it is not encoded twice", async () => {
1519
+ const path = await callWith({
1520
+ token: "https://graph.microsoft.com/v1.0/sites/delta?token=a%2Bb%3D%3D"
1521
+ });
1522
+ expect(path).toContain("token=a%2Bb%3D%3D");
1523
+ expect(path).not.toContain("%25");
1524
+ });
1525
+ it("does not read a $deltatoken or $skiptoken as token=", async () => {
1526
+ const path = await callWith({
1527
+ token: "https://graph.microsoft.com/v1.0/sites/delta?$deltatoken=dt1"
1528
+ });
1529
+ expect(path).toContain("$deltatoken=dt1");
1530
+ expect(path).not.toContain("?token=");
1531
+ });
1532
+ it.each(["", " "])("sends no token when blank (%j)", async (blank) => {
1533
+ const path = await callWith({ token: blank });
1534
+ expect(path).not.toContain("token");
1535
+ });
1536
+ it.each([
1537
+ "https://graph.microsoft.com/v1.0/sites/s1/lists/l1/items/delta?$top=5",
1538
+ "https://graph.microsoft.com/v1.0/sites/s1/lists/l1/items/delta?token=&$top=5"
1539
+ ])("refuses a link with no token to resume from: %s", async (link) => {
1540
+ const { result, graphClient } = await callForResult({ token: link });
1541
+ expect(result.isError).toBe(true);
1542
+ expect(JSON.parse(result.content[0].text).error).toBe("invalid_delta_token");
1543
+ expect(graphClient.graphRequest).not.toHaveBeenCalled();
1544
+ });
1545
+ it("drops token on a tool without deltaToken", async () => {
1546
+ const { server, graphClient } = await register(void 0);
1547
+ await server.tools.get("items-delta").handler({ siteId: "s1", listId: "l1", token: "x" });
1548
+ expect(graphClient.graphRequest.mock.calls[0][0]).not.toContain("token");
1549
+ });
1410
1550
  });
1411
1551
  describe("fetchAllPages pagination", () => {
1412
1552
  it("should follow @odata.nextLink and combine results", async () => {
@@ -739,7 +739,8 @@
739
739
  "presets": ["files", "onedrive", "personal"],
740
740
  "scopes": ["Files.Read"],
741
741
  "appScopes": [["Files.Read.All"], ["Sites.Read.All"], ["Sites.Selected"]],
742
- "llmTip": "Tracks changes to a driveItem and its children over time. Returns a collection of driveItems that have been created, modified, or deleted. Use get-drive-root-item first to get the root driveItem-id, then pass it here. Supports $select and delta tokens for incremental sync via @odata.deltaLink."
742
+ "deltaToken": true,
743
+ "llmTip": "Tracks changes to a driveItem and its children over time. Returns a collection of driveItems that have been created, modified, or deleted. Use get-drive-root-item first to get the root driveItem-id, then pass it here. Supports $select. For incremental sync, pass the @odata.deltaLink from the last page as token on the next call."
743
744
  },
744
745
  {
745
746
  "pathPattern": "/drives/{drive-id}/root",
@@ -1300,77 +1301,77 @@
1300
1301
  "method": "get",
1301
1302
  "toolName": "list-sharepoint-site-onenote-notebooks",
1302
1303
  "presets": ["onenote", "work"],
1303
- "workScopes": ["Notes.Read"]
1304
+ "workScopes": ["Notes.Read.All"]
1304
1305
  },
1305
1306
  {
1306
1307
  "pathPattern": "/sites/{site-id}/onenote/notebooks/{notebook-id}/sections",
1307
1308
  "method": "get",
1308
1309
  "toolName": "list-sharepoint-site-onenote-notebook-sections",
1309
1310
  "presets": ["onenote", "work"],
1310
- "workScopes": ["Notes.Read"]
1311
+ "workScopes": ["Notes.Read.All"]
1311
1312
  },
1312
1313
  {
1313
1314
  "pathPattern": "/sites/{site-id}/onenote/sections/{onenoteSection-id}/pages",
1314
1315
  "method": "get",
1315
1316
  "toolName": "list-sharepoint-site-onenote-section-pages",
1316
1317
  "presets": ["onenote", "work"],
1317
- "workScopes": ["Notes.Read"]
1318
+ "workScopes": ["Notes.Read.All"]
1318
1319
  },
1319
1320
  {
1320
1321
  "pathPattern": "/sites/{site-id}/onenote/notebooks/{notebook-id}/sectionGroups",
1321
1322
  "method": "get",
1322
1323
  "toolName": "list-sharepoint-site-onenote-notebook-section-groups",
1323
1324
  "presets": ["onenote", "work"],
1324
- "workScopes": ["Notes.Read"]
1325
+ "workScopes": ["Notes.Read.All"]
1325
1326
  },
1326
1327
  {
1327
1328
  "pathPattern": "/sites/{site-id}/onenote/sectionGroups/{sectionGroup-id}/sections",
1328
1329
  "method": "get",
1329
1330
  "toolName": "list-sharepoint-site-onenote-section-group-sections",
1330
1331
  "presets": ["onenote", "work"],
1331
- "workScopes": ["Notes.Read"]
1332
+ "workScopes": ["Notes.Read.All"]
1332
1333
  },
1333
1334
  {
1334
1335
  "pathPattern": "/sites/{site-id}/onenote/sectionGroups/{sectionGroup-id}/sectionGroups",
1335
1336
  "method": "get",
1336
1337
  "toolName": "list-sharepoint-site-onenote-section-group-section-groups",
1337
1338
  "presets": ["onenote", "work"],
1338
- "workScopes": ["Notes.Read"]
1339
+ "workScopes": ["Notes.Read.All"]
1339
1340
  },
1340
1341
  {
1341
1342
  "pathPattern": "/sites/{site-id}/onenote/pages/{onenotePage-id}/content",
1342
1343
  "method": "get",
1343
1344
  "toolName": "get-sharepoint-site-onenote-page-content",
1344
1345
  "presets": ["onenote", "work"],
1345
- "workScopes": ["Notes.Read"]
1346
+ "workScopes": ["Notes.Read.All"]
1346
1347
  },
1347
1348
  {
1348
1349
  "pathPattern": "/sites/{site-id}/onenote/notebooks",
1349
1350
  "method": "post",
1350
1351
  "toolName": "create-sharepoint-site-onenote-notebook",
1351
1352
  "presets": ["onenote", "work"],
1352
- "workScopes": ["Notes.Create"]
1353
+ "workScopes": ["Notes.ReadWrite.All"]
1353
1354
  },
1354
1355
  {
1355
1356
  "pathPattern": "/sites/{site-id}/onenote/notebooks/{notebook-id}/sections",
1356
1357
  "method": "post",
1357
1358
  "toolName": "create-sharepoint-site-onenote-section",
1358
1359
  "presets": ["onenote", "work"],
1359
- "workScopes": ["Notes.Create"]
1360
+ "workScopes": ["Notes.ReadWrite.All"]
1360
1361
  },
1361
1362
  {
1362
1363
  "pathPattern": "/sites/{site-id}/onenote/sectionGroups/{sectionGroup-id}/sections",
1363
1364
  "method": "post",
1364
1365
  "toolName": "create-sharepoint-site-onenote-section-group-section",
1365
1366
  "presets": ["onenote", "work"],
1366
- "workScopes": ["Notes.Create"]
1367
+ "workScopes": ["Notes.ReadWrite.All"]
1367
1368
  },
1368
1369
  {
1369
1370
  "pathPattern": "/sites/{site-id}/onenote/sections/{onenoteSection-id}/pages",
1370
1371
  "method": "post",
1371
1372
  "toolName": "create-sharepoint-site-onenote-section-page",
1372
1373
  "presets": ["onenote", "work"],
1373
- "workScopes": ["Notes.Create"],
1374
+ "workScopes": ["Notes.ReadWrite.All"],
1374
1375
  "contentType": "text/html",
1375
1376
  "llmTip": "Body must be a full HTML document (with <html><head><title>...</title></head><body>...</body></html>). Partial HTML fails silently."
1376
1377
  },
@@ -1379,7 +1380,7 @@
1379
1380
  "method": "patch",
1380
1381
  "toolName": "update-sharepoint-site-onenote-page-content",
1381
1382
  "presets": ["onenote", "work"],
1382
- "workScopes": ["Notes.ReadWrite"],
1383
+ "workScopes": ["Notes.ReadWrite.All"],
1383
1384
  "requestBodySchema": {
1384
1385
  "type": "array",
1385
1386
  "description": "Array of patchContentCommand objects applied in order to the page's HTML.",
@@ -1414,7 +1415,7 @@
1414
1415
  "method": "delete",
1415
1416
  "toolName": "delete-sharepoint-site-onenote-page",
1416
1417
  "presets": ["onenote", "work"],
1417
- "workScopes": ["Notes.ReadWrite"]
1418
+ "workScopes": ["Notes.ReadWrite.All"]
1418
1419
  },
1419
1420
  {
1420
1421
  "pathPattern": "/me/onenote/pages",
@@ -2381,7 +2382,8 @@
2381
2382
  "presets": ["work"],
2382
2383
  "workScopes": [["Sites.Read.All"], ["Sites.Selected"]],
2383
2384
  "appScopes": [["Sites.Read.All"], ["Sites.Selected"]],
2384
- "queryParams": ["select", "expand", "top"]
2385
+ "queryParams": ["select", "expand", "top"],
2386
+ "deltaToken": true
2385
2387
  },
2386
2388
  {
2387
2389
  "pathPattern": "/sites/{site-id}/lists/{list-id}/items/{listItem-id}/versions",
@@ -2506,7 +2508,8 @@
2506
2508
  "toolName": "get-sharepoint-sites-delta",
2507
2509
  "presets": ["work"],
2508
2510
  "workScopes": ["Sites.Read.All"],
2509
- "appScopes": [["Sites.Read.All"], ["Sites.FullControl.All"], ["Sites.Manage.All"]]
2511
+ "appScopes": [["Sites.Read.All"], ["Sites.FullControl.All"], ["Sites.Manage.All"]],
2512
+ "deltaToken": true
2510
2513
  },
2511
2514
  {
2512
2515
  "pathPattern": "/search/query",
@@ -165,11 +165,12 @@ function toBlobResponse(data, blob) {
165
165
  };
166
166
  }
167
167
  class GraphClient {
168
- constructor(authManager, secrets, outputFormat = "json") {
168
+ constructor(authManager, secrets, outputFormat = "json", options = {}) {
169
169
  this.outputFormat = "json";
170
170
  this.authManager = authManager;
171
171
  this.secrets = secrets;
172
172
  this.outputFormat = outputFormat;
173
+ this.orgMode = Boolean(options.orgMode);
173
174
  }
174
175
  async makeRequest(endpoint, options = {}) {
175
176
  return (await this.makeRequestWithMetadata(endpoint, options)).data;
@@ -352,6 +353,9 @@ class GraphClient {
352
353
  if (this.authManager.isAppMode?.()) {
353
354
  return "Grant one of these as an application permission to your app registration (with admin consent), or for mail and calendars through Exchange RBAC for Applications.";
354
355
  }
356
+ if (this.orgMode) {
357
+ return "The access token does not carry a scope this request needs. Make sure the app registration has the permission and sign in again to consent to it.";
358
+ }
355
359
  return "This tool requires organization mode. Please restart with --org-mode flag.";
356
360
  }
357
361
  async createGraphApiError(response) {
@@ -48,6 +48,7 @@ import {
48
48
  getMaxPages,
49
49
  isFetchAllPagesApplicable,
50
50
  isSkiptokenApplicable,
51
+ DELTA_TOKEN_PARAM_DESCRIPTION,
51
52
  MEMBER_NAME_PARAM_DESCRIPTION,
52
53
  paginationAllowed,
53
54
  positiveIntFromEnv,
@@ -312,7 +313,7 @@ function normalizeSearchQueryParam(queryParams, path2, toolAlias) {
312
313
  queryParams["$search"] = normalized;
313
314
  }
314
315
  }
315
- function normalizeSkiptokenQueryParam(queryParams, toolAlias) {
316
+ function normalizeSkiptokenQueryParam(queryParams, toolAlias, deltaToken = false) {
316
317
  const raw = queryParams["$skiptoken"];
317
318
  if (raw === void 0) return;
318
319
  delete queryParams["$skiptoken"];
@@ -327,7 +328,7 @@ function normalizeSkiptokenQueryParam(queryParams, toolAlias) {
327
328
  text: JSON.stringify({
328
329
  error: "invalid_skiptoken",
329
330
  tool: toolAlias,
330
- message: "The value passed as skiptoken has no $skiptoken or $skip to page with. The drive and sites delta tools page with a token= link, which skiptoken cannot resend." + (paginationAllowed() ? " Remove skiptoken and retry with fetchAllPages set to true to follow the link, or remove it for the first page." : " Remove skiptoken and retry for the first page.")
331
+ message: "The value passed as skiptoken has no $skiptoken or $skip to page with." + (deltaToken ? " This tool pages and resumes with a token= link: pass that link as token instead of skiptoken." : " Delta tools that page with a token= link take it in their token parameter, where they have one.") + (paginationAllowed() ? " Remove skiptoken and retry with fetchAllPages set to true to follow the link, or remove it for the first page." : " Remove skiptoken and retry for the first page.")
331
332
  })
332
333
  }
333
334
  ],
@@ -356,6 +357,47 @@ function normalizeSkiptokenQueryParam(queryParams, toolAlias) {
356
357
  }
357
358
  queryParams["$skiptoken"] = token;
358
359
  }
360
+ function normalizeDeltaTokenParam(raw, queryParams, toolAlias) {
361
+ if (raw === void 0 || raw === null) return;
362
+ let token = `${raw}`.trim();
363
+ if (token === "") return;
364
+ const invalidToken = () => {
365
+ logger.warn(`Refusing ${toolAlias}: 'token' has no token value to resume from`);
366
+ return {
367
+ content: [
368
+ {
369
+ type: "text",
370
+ text: JSON.stringify({
371
+ error: "invalid_delta_token",
372
+ tool: toolAlias,
373
+ message: "The value passed as token has no token= value. Pass the @odata.nextLink or @odata.deltaLink this tool returned, the bare token from it, or latest. Remove token to enumerate from the start."
374
+ })
375
+ }
376
+ ],
377
+ isError: true
378
+ };
379
+ };
380
+ const marker = token.match(/(?:^|[?&(,])token=(?:'([^']*)'|([^&)#']*))/i);
381
+ if (marker) {
382
+ token = marker[1] ?? marker[2];
383
+ } else if (/:\/\/|[?(]/.test(token)) {
384
+ const deltatoken = token.match(/(?:^|[?&])(?:\$|%24)deltatoken=([^&#]*)/i)?.[1];
385
+ if (!deltatoken) return invalidToken();
386
+ queryParams["$deltatoken"] = decodeOnce(deltatoken);
387
+ return;
388
+ }
389
+ if (token === "") return invalidToken();
390
+ queryParams["token"] = decodeOnce(token);
391
+ }
392
+ function decodeOnce(value) {
393
+ if (!value.includes("%")) return value;
394
+ try {
395
+ return decodeURIComponent(value);
396
+ } catch {
397
+ logger.warn("Delta token looks percent-encoded but could not be decoded; sending as-is");
398
+ return value;
399
+ }
400
+ }
359
401
  const DEFAULT_MAX_ITEMS = 1e4;
360
402
  function isConfirmGateEnabled() {
361
403
  return process.env.MS365_MCP_REQUIRE_CONFIRM === "true";
@@ -1888,6 +1930,7 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
1888
1930
  for (const [paramName, paramValue] of Object.entries(params)) {
1889
1931
  if (paramName === "fileName" && config?.blobOutput) continue;
1890
1932
  if (paramName === "name" && config?.nameFilter) continue;
1933
+ if (paramName === "token" && config?.deltaToken) continue;
1891
1934
  if ([
1892
1935
  "account",
1893
1936
  "confirm",
@@ -2082,8 +2125,16 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
2082
2125
  }
2083
2126
  body = rewritten.body;
2084
2127
  }
2085
- const skiptokenError = normalizeSkiptokenQueryParam(queryParams, tool.alias);
2128
+ const skiptokenError = normalizeSkiptokenQueryParam(
2129
+ queryParams,
2130
+ tool.alias,
2131
+ config?.deltaToken
2132
+ );
2086
2133
  if (skiptokenError) return skiptokenError;
2134
+ if (config?.deltaToken) {
2135
+ const deltaTokenError = normalizeDeltaTokenParam(params.token, queryParams, tool.alias);
2136
+ if (deltaTokenError) return deltaTokenError;
2137
+ }
2087
2138
  clampTopQueryParam(queryParams);
2088
2139
  const searchError = normalizeSearchQueryParam(queryParams, tool.path, tool.alias);
2089
2140
  if (searchError) return searchError;
@@ -2469,6 +2520,9 @@ function registerGraphToolWithMcp(server, tool, endpointConfig, graphClient, opt
2469
2520
  if (isSkiptokenApplicable(tool, Object.keys(paramSchema), endpointConfig)) {
2470
2521
  paramSchema["skiptoken"] = z.string().optional().describe(SKIPTOKEN_PARAM_DESCRIPTION);
2471
2522
  }
2523
+ if (endpointConfig?.deltaToken) {
2524
+ paramSchema["token"] = z.string().optional().describe(DELTA_TOKEN_PARAM_DESCRIPTION);
2525
+ }
2472
2526
  if (multiAccount) {
2473
2527
  paramSchema["account"] = z.string().optional().describe(getAccountParamDescription(accountNames));
2474
2528
  }
@@ -65,6 +65,7 @@ function isSkiptokenApplicable(tool, paramNames, config) {
65
65
  }
66
66
  return false;
67
67
  }
68
+ const DELTA_TOKEN_PARAM_DESCRIPTION = "Delta state to resume from: the @odata.deltaLink from the last sync to get only the changes since then, the @odata.nextLink for the next page, or latest to skip existing items and get a deltaLink for changes from now. Omit to enumerate everything.";
68
69
  const COUNT_PARAM_DESCRIPTION = "Set true to enable advanced query mode (ConsistencyLevel: eventual). Required for complex $filter on flag/flagStatus or contains(). The response then includes @odata.count, the total for the filtered collection, which can exceed the items returned when fetchAllPages hits its page/item cap.";
69
70
  const MEMBER_NAME_PARAM_DESCRIPTION = "Case-insensitive text to match against each member's displayName and email. Applied after $select projection, so only fields you can see are matched. Without fetchAllPages only the fetched page is filtered, and @odata.count still reports the unfiltered total.";
70
71
  const CONFIRM_PARAM_DESCRIPTION = 'For destructive operations when the confirm gate is enabled (MS365_MCP_REQUIRE_CONFIRM=true; off by default). Set to true only after the user has explicitly approved this action. When the gate is on, calls without confirm: true return { error: "confirmation_required" } without touching user data.';
@@ -112,6 +113,7 @@ export {
112
113
  CONFIRM_PARAM_DESCRIPTION,
113
114
  COUNT_PARAM_DESCRIPTION,
114
115
  DEFAULT_MAX_PAGES,
116
+ DELTA_TOKEN_PARAM_DESCRIPTION,
115
117
  EXPAND_EXTENDED_PROPERTIES_PARAM_DESCRIPTION,
116
118
  MEMBER_NAME_PARAM_DESCRIPTION,
117
119
  ORDERBY_PARAM_DESCRIPTION,
@@ -14,7 +14,8 @@ import {
14
14
  TIMEZONE_PARAM_DESCRIPTION,
15
15
  EXPAND_EXTENDED_PROPERTIES_PARAM_DESCRIPTION,
16
16
  getAcceptParamDescription,
17
- MEMBER_NAME_PARAM_DESCRIPTION
17
+ MEMBER_NAME_PARAM_DESCRIPTION,
18
+ DELTA_TOKEN_PARAM_DESCRIPTION
18
19
  } from "./param-descriptions.js";
19
20
  function unwrapOptional(schema) {
20
21
  if (schema instanceof z.ZodOptional || schema instanceof z.ZodDefault || schema instanceof z.ZodNullable) {
@@ -108,6 +109,18 @@ function describeToolSchema(tool, config, ctx = {}) {
108
109
  schema: { type: "string" }
109
110
  });
110
111
  }
112
+ if (config?.deltaToken) {
113
+ const synthetic = {
114
+ name: "token",
115
+ in: "Query",
116
+ required: false,
117
+ description: DELTA_TOKEN_PARAM_DESCRIPTION,
118
+ schema: { type: "string" }
119
+ };
120
+ const existing = params.findIndex((p) => p.name === "token");
121
+ if (existing >= 0) params[existing] = synthetic;
122
+ else params.push(synthetic);
123
+ }
111
124
  if (ctx.multiAccount) {
112
125
  params.push({
113
126
  name: "account",
package/dist/server.js CHANGED
@@ -318,7 +318,9 @@ class MicrosoftGraphServer {
318
318
  logger.info("On-Behalf-Of (OBO) flow enabled");
319
319
  }
320
320
  const outputFormat = this.options.toon ? "toon" : "json";
321
- this.graphClient = new GraphClient(this.authManager, this.secrets, outputFormat);
321
+ this.graphClient = new GraphClient(this.authManager, this.secrets, outputFormat, {
322
+ orgMode: Boolean(this.options.orgMode)
323
+ });
322
324
  if (!this.options.http) {
323
325
  this.server = this.createMcpServer();
324
326
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@softeria/ms-365-mcp-server",
3
3
  "mcpName": "io.github.Softeria/ms-365-mcp-server",
4
- "version": "0.180.7",
4
+ "version": "0.181.1",
5
5
  "description": " A Model Context Protocol (MCP) server for interacting with Microsoft 365 and Office services through the Graph API",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",
@@ -739,7 +739,8 @@
739
739
  "presets": ["files", "onedrive", "personal"],
740
740
  "scopes": ["Files.Read"],
741
741
  "appScopes": [["Files.Read.All"], ["Sites.Read.All"], ["Sites.Selected"]],
742
- "llmTip": "Tracks changes to a driveItem and its children over time. Returns a collection of driveItems that have been created, modified, or deleted. Use get-drive-root-item first to get the root driveItem-id, then pass it here. Supports $select and delta tokens for incremental sync via @odata.deltaLink."
742
+ "deltaToken": true,
743
+ "llmTip": "Tracks changes to a driveItem and its children over time. Returns a collection of driveItems that have been created, modified, or deleted. Use get-drive-root-item first to get the root driveItem-id, then pass it here. Supports $select. For incremental sync, pass the @odata.deltaLink from the last page as token on the next call."
743
744
  },
744
745
  {
745
746
  "pathPattern": "/drives/{drive-id}/root",
@@ -1300,77 +1301,77 @@
1300
1301
  "method": "get",
1301
1302
  "toolName": "list-sharepoint-site-onenote-notebooks",
1302
1303
  "presets": ["onenote", "work"],
1303
- "workScopes": ["Notes.Read"]
1304
+ "workScopes": ["Notes.Read.All"]
1304
1305
  },
1305
1306
  {
1306
1307
  "pathPattern": "/sites/{site-id}/onenote/notebooks/{notebook-id}/sections",
1307
1308
  "method": "get",
1308
1309
  "toolName": "list-sharepoint-site-onenote-notebook-sections",
1309
1310
  "presets": ["onenote", "work"],
1310
- "workScopes": ["Notes.Read"]
1311
+ "workScopes": ["Notes.Read.All"]
1311
1312
  },
1312
1313
  {
1313
1314
  "pathPattern": "/sites/{site-id}/onenote/sections/{onenoteSection-id}/pages",
1314
1315
  "method": "get",
1315
1316
  "toolName": "list-sharepoint-site-onenote-section-pages",
1316
1317
  "presets": ["onenote", "work"],
1317
- "workScopes": ["Notes.Read"]
1318
+ "workScopes": ["Notes.Read.All"]
1318
1319
  },
1319
1320
  {
1320
1321
  "pathPattern": "/sites/{site-id}/onenote/notebooks/{notebook-id}/sectionGroups",
1321
1322
  "method": "get",
1322
1323
  "toolName": "list-sharepoint-site-onenote-notebook-section-groups",
1323
1324
  "presets": ["onenote", "work"],
1324
- "workScopes": ["Notes.Read"]
1325
+ "workScopes": ["Notes.Read.All"]
1325
1326
  },
1326
1327
  {
1327
1328
  "pathPattern": "/sites/{site-id}/onenote/sectionGroups/{sectionGroup-id}/sections",
1328
1329
  "method": "get",
1329
1330
  "toolName": "list-sharepoint-site-onenote-section-group-sections",
1330
1331
  "presets": ["onenote", "work"],
1331
- "workScopes": ["Notes.Read"]
1332
+ "workScopes": ["Notes.Read.All"]
1332
1333
  },
1333
1334
  {
1334
1335
  "pathPattern": "/sites/{site-id}/onenote/sectionGroups/{sectionGroup-id}/sectionGroups",
1335
1336
  "method": "get",
1336
1337
  "toolName": "list-sharepoint-site-onenote-section-group-section-groups",
1337
1338
  "presets": ["onenote", "work"],
1338
- "workScopes": ["Notes.Read"]
1339
+ "workScopes": ["Notes.Read.All"]
1339
1340
  },
1340
1341
  {
1341
1342
  "pathPattern": "/sites/{site-id}/onenote/pages/{onenotePage-id}/content",
1342
1343
  "method": "get",
1343
1344
  "toolName": "get-sharepoint-site-onenote-page-content",
1344
1345
  "presets": ["onenote", "work"],
1345
- "workScopes": ["Notes.Read"]
1346
+ "workScopes": ["Notes.Read.All"]
1346
1347
  },
1347
1348
  {
1348
1349
  "pathPattern": "/sites/{site-id}/onenote/notebooks",
1349
1350
  "method": "post",
1350
1351
  "toolName": "create-sharepoint-site-onenote-notebook",
1351
1352
  "presets": ["onenote", "work"],
1352
- "workScopes": ["Notes.Create"]
1353
+ "workScopes": ["Notes.ReadWrite.All"]
1353
1354
  },
1354
1355
  {
1355
1356
  "pathPattern": "/sites/{site-id}/onenote/notebooks/{notebook-id}/sections",
1356
1357
  "method": "post",
1357
1358
  "toolName": "create-sharepoint-site-onenote-section",
1358
1359
  "presets": ["onenote", "work"],
1359
- "workScopes": ["Notes.Create"]
1360
+ "workScopes": ["Notes.ReadWrite.All"]
1360
1361
  },
1361
1362
  {
1362
1363
  "pathPattern": "/sites/{site-id}/onenote/sectionGroups/{sectionGroup-id}/sections",
1363
1364
  "method": "post",
1364
1365
  "toolName": "create-sharepoint-site-onenote-section-group-section",
1365
1366
  "presets": ["onenote", "work"],
1366
- "workScopes": ["Notes.Create"]
1367
+ "workScopes": ["Notes.ReadWrite.All"]
1367
1368
  },
1368
1369
  {
1369
1370
  "pathPattern": "/sites/{site-id}/onenote/sections/{onenoteSection-id}/pages",
1370
1371
  "method": "post",
1371
1372
  "toolName": "create-sharepoint-site-onenote-section-page",
1372
1373
  "presets": ["onenote", "work"],
1373
- "workScopes": ["Notes.Create"],
1374
+ "workScopes": ["Notes.ReadWrite.All"],
1374
1375
  "contentType": "text/html",
1375
1376
  "llmTip": "Body must be a full HTML document (with <html><head><title>...</title></head><body>...</body></html>). Partial HTML fails silently."
1376
1377
  },
@@ -1379,7 +1380,7 @@
1379
1380
  "method": "patch",
1380
1381
  "toolName": "update-sharepoint-site-onenote-page-content",
1381
1382
  "presets": ["onenote", "work"],
1382
- "workScopes": ["Notes.ReadWrite"],
1383
+ "workScopes": ["Notes.ReadWrite.All"],
1383
1384
  "requestBodySchema": {
1384
1385
  "type": "array",
1385
1386
  "description": "Array of patchContentCommand objects applied in order to the page's HTML.",
@@ -1414,7 +1415,7 @@
1414
1415
  "method": "delete",
1415
1416
  "toolName": "delete-sharepoint-site-onenote-page",
1416
1417
  "presets": ["onenote", "work"],
1417
- "workScopes": ["Notes.ReadWrite"]
1418
+ "workScopes": ["Notes.ReadWrite.All"]
1418
1419
  },
1419
1420
  {
1420
1421
  "pathPattern": "/me/onenote/pages",
@@ -2381,7 +2382,8 @@
2381
2382
  "presets": ["work"],
2382
2383
  "workScopes": [["Sites.Read.All"], ["Sites.Selected"]],
2383
2384
  "appScopes": [["Sites.Read.All"], ["Sites.Selected"]],
2384
- "queryParams": ["select", "expand", "top"]
2385
+ "queryParams": ["select", "expand", "top"],
2386
+ "deltaToken": true
2385
2387
  },
2386
2388
  {
2387
2389
  "pathPattern": "/sites/{site-id}/lists/{list-id}/items/{listItem-id}/versions",
@@ -2506,7 +2508,8 @@
2506
2508
  "toolName": "get-sharepoint-sites-delta",
2507
2509
  "presets": ["work"],
2508
2510
  "workScopes": ["Sites.Read.All"],
2509
- "appScopes": [["Sites.Read.All"], ["Sites.FullControl.All"], ["Sites.Manage.All"]]
2511
+ "appScopes": [["Sites.Read.All"], ["Sites.FullControl.All"], ["Sites.Manage.All"]],
2512
+ "deltaToken": true
2510
2513
  },
2511
2514
  {
2512
2515
  "pathPattern": "/search/query",
@@ -44,13 +44,13 @@ improvements should now be much easier to implement and maintain.
44
44
  To regenerate the client code (e.g., after API changes or to update the supported endpoints):
45
45
 
46
46
  ```
47
- npm run bin/generate-graph-client.mjs
47
+ node bin/generate-graph-client.mjs
48
48
  ```
49
49
 
50
50
  This command does the following:
51
51
 
52
52
  1. Fetches/processes the OpenAPI spec
53
53
  2. Generates the TypeScript client with Zod validation
54
- 3. Outputs the result to `client.ts` in this directory
54
+ 3. Writes the v1.0 and beta clients to `client.ts` and `client-beta.ts`.
55
55
 
56
56
  No complex build scripts needed - the generation is handled by openapi-zod-client.