@softeria/ms-365-mcp-server 0.188.1 → 0.190.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/PRESETS.md CHANGED
@@ -10,7 +10,7 @@ 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) | 371<br>181 | 65<br>38 | -<br>- | All available tools |
13
+ | `all` | [full](#all-full)<br>[read only](#all-read-only) | 372<br>182 | 65<br>38 | -<br>- | All available tools |
14
14
  | `calendar` | [full](#calendar-full)<br>[read only](#calendar-read-only) | 48<br>23 | 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 |
@@ -20,18 +20,18 @@ Every preset also includes the account tools (`login`, `logout`, `verify-login`,
20
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
- | `search` | [full](#search-full)<br>[read only](#search-read-only) | 7<br>7 | 8<br>8 | -<br>- | Microsoft Search capabilities |
23
+ | `search` | [full](#search-full)<br>[read only](#search-read-only) | 8<br>8 | 8<br>8 | -<br>- | Microsoft Search capabilities |
24
24
  | `tasks` | [full](#tasks-full)<br>[read only](#tasks-read-only) | 35<br>16 | 1<br>1 | -<br>- | Task and planning tools (To Do, Planner) |
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) | 191<br>111 | 55<br>33 | required<br>required | Organization/work tools (Teams, SharePoint, shared mailboxes, search) |
28
+ | `work` | [full](#work-full)<br>[read only](#work-read-only) | 192<br>112 | 55<br>33 | required<br>required | Organization/work tools (Teams, SharePoint, shared mailboxes, search) |
29
29
 
30
30
  ## `all` full
31
31
 
32
32
  All available tools
33
33
 
34
- Tools (371):
34
+ Tools (372):
35
35
 
36
36
  - `accept-calendar-event`
37
37
  - `add-calendar-event-attachment`
@@ -344,6 +344,7 @@ Tools (371):
344
344
  - `reply-to-channel-message`
345
345
  - `reply-to-chat-message`
346
346
  - `reply-to-group-thread`
347
+ - `search-files`
347
348
  - `search-onedrive-files`
348
349
  - `search-query`
349
350
  - `search-sharepoint-sites`
@@ -477,7 +478,7 @@ Scopes (65):
477
478
 
478
479
  All available tools
479
480
 
480
- Tools (181):
481
+ Tools (182):
481
482
 
482
483
  - `copilot-retrieve`
483
484
  - `download-bytes`
@@ -657,6 +658,7 @@ Tools (181):
657
658
  - `list-webinar-sessions`
658
659
  - `parse-teams-url`
659
660
  - `read-mail-text`
661
+ - `search-files`
660
662
  - `search-onedrive-files`
661
663
  - `search-query`
662
664
  - `search-sharepoint-sites`
@@ -1678,12 +1680,13 @@ Scopes (15):
1678
1680
 
1679
1681
  Microsoft Search capabilities
1680
1682
 
1681
- Tools (7):
1683
+ Tools (8):
1682
1684
 
1683
1685
  - `copilot-retrieve`
1684
1686
  - `download-bytes`
1685
1687
  - `download-bytes-to-file`
1686
1688
  - `get-download-url`
1689
+ - `search-files`
1687
1690
  - `search-onedrive-files`
1688
1691
  - `search-query`
1689
1692
  - `search-sharepoint-sites`
@@ -1703,12 +1706,13 @@ Scopes (8):
1703
1706
 
1704
1707
  Microsoft Search capabilities
1705
1708
 
1706
- Tools (7):
1709
+ Tools (8):
1707
1710
 
1708
1711
  - `copilot-retrieve`
1709
1712
  - `download-bytes`
1710
1713
  - `download-bytes-to-file`
1711
1714
  - `get-download-url`
1715
+ - `search-files`
1712
1716
  - `search-onedrive-files`
1713
1717
  - `search-query`
1714
1718
  - `search-sharepoint-sites`
@@ -2097,7 +2101,7 @@ Organization/work tools (Teams, SharePoint, shared mailboxes, search)
2097
2101
 
2098
2102
  Requires `--org-mode`.
2099
2103
 
2100
- Tools (191):
2104
+ Tools (192):
2101
2105
 
2102
2106
  - `add-group-member`
2103
2107
  - `add-group-owner`
@@ -2258,6 +2262,7 @@ Tools (191):
2258
2262
  - `reply-to-channel-message`
2259
2263
  - `reply-to-chat-message`
2260
2264
  - `reply-to-group-thread`
2265
+ - `search-files`
2261
2266
  - `search-query`
2262
2267
  - `search-sharepoint-sites`
2263
2268
  - `send-channel-message`
@@ -2355,7 +2360,7 @@ Organization/work tools (Teams, SharePoint, shared mailboxes, search)
2355
2360
 
2356
2361
  Requires `--org-mode`.
2357
2362
 
2358
- Tools (111):
2363
+ Tools (112):
2359
2364
 
2360
2365
  - `copilot-retrieve`
2361
2366
  - `download-bytes`
@@ -2466,6 +2471,7 @@ Tools (111):
2466
2471
  - `list-webinar-sessions`
2467
2472
  - `parse-teams-url`
2468
2473
  - `read-mail-text`
2474
+ - `search-files`
2469
2475
  - `search-query`
2470
2476
  - `search-sharepoint-sites`
2471
2477
 
package/README.md CHANGED
@@ -1086,6 +1086,20 @@ whatever the outcome, and the upload is attached as the identity that minted it,
1086
1086
  downloads are fetched. An upload ticket presented to `GET` (or a download ticket to `PUT`)
1087
1087
  is refused with the same 404 as any other bad ticket.
1088
1088
 
1089
+ ### Several files in one call
1090
+
1091
+ An agent that moves many files would otherwise spend one tool call per file. Both tools
1092
+ take a list instead of a single entry: `get-download-url` takes `targets`, up to 20 paths of
1093
+ the form `target` takes, and `get-upload-url` takes `files`, up to 20 entries with the
1094
+ fields of a single upload (`target`, `name`, and the optional `contentType`, `contentId`
1095
+ and `conflictBehavior`). Each entry is checked and minted exactly as a single call would be.
1096
+ The result is `{ "results": [...] }`, one item per entry in the order given, naming its
1097
+ `target` (and `name`) next to its URL or its `error`; the call is an error only when every
1098
+ entry failed. Every URL this server mints keeps its own single use and TTL (two minutes by
1099
+ default), and a transfer has to start before its URL expires, so mint a list right before
1100
+ the transfers and start them all at once, in parallel or in one command, rather than one
1101
+ after another.
1102
+
1089
1103
  ### Attaching a local file in stdio mode
1090
1104
 
1091
1105
  In stdio mode the server and the files are on the same machine, so no URL is needed.
@@ -2574,6 +2574,41 @@
2574
2574
  "ChannelMessage.Read.All"
2575
2575
  ]
2576
2576
  },
2577
+ {
2578
+ "pathPattern": "/search/query",
2579
+ "method": "post",
2580
+ "toolName": "search-files",
2581
+ "descriptionOverride": "Find files by keyword across the OneDrive and SharePoint files the signed-in user can read, without knowing the site or drive. The search is KQL keyword matching, not semantic: give a few keywords, not a sentence. A hit's resource.parentReference.driveId and resource.id go to get-drive-item.",
2582
+ "presets": ["search", "work"],
2583
+ "readOnly": true,
2584
+ "workScopes": [["Sites.Read.All"], ["Files.Read.All"]],
2585
+ "queryParams": [],
2586
+ "fixedBody": {
2587
+ "requests": [
2588
+ { "entityTypes": ["driveItem"], "query": { "queryString": "" }, "from": 0, "size": 10 }
2589
+ ]
2590
+ },
2591
+ "bodyParams": {
2592
+ "queryString": {
2593
+ "target": ["requests", 0, "query", "queryString"],
2594
+ "type": "string",
2595
+ "required": true,
2596
+ "description": "Keywords to look for in file names, metadata and content, in KQL."
2597
+ },
2598
+ "size": {
2599
+ "target": ["requests", 0, "size"],
2600
+ "type": "integer",
2601
+ "minimum": 1,
2602
+ "description": "How many hits to return. Defaults to 10."
2603
+ },
2604
+ "from": {
2605
+ "target": ["requests", 0, "from"],
2606
+ "type": "integer",
2607
+ "minimum": 0,
2608
+ "description": "Offset of the first hit, 0 by default. While moreResultsAvailable is true, the next page starts at the previous from plus the previous size."
2609
+ }
2610
+ }
2611
+ },
2577
2612
  {
2578
2613
  "pathPattern": "/copilot/retrieval",
2579
2614
  "method": "post",
@@ -93,6 +93,7 @@ import {
93
93
  targetsUserProfile,
94
94
  userFieldEnforcement
95
95
  } from "./lib/user-field-policy.js";
96
+ import { bodyParamSchemas, buildFixedBody } from "./lib/body-params.js";
96
97
  import logger from "./logger.js";
97
98
  import {
98
99
  mcpAppResultWithoutBody,
@@ -841,6 +842,7 @@ async function mintUploadUrl(target, name, contentType, accountParam, authManage
841
842
  expiresAt: new Date(ticket.expiresAtMs).toISOString(),
842
843
  singleUse: true,
843
844
  maxBytes: MAX_UPLOAD_BYTES,
845
+ name: cleanName,
844
846
  ...drive && { conflictBehavior: drive.conflictBehavior },
845
847
  note: 'PUT the raw file bytes with a Content-Length (e.g. curl -T <file> "<uploadUrl>"). Served by this server; valid for one upload until it expires.'
846
848
  })
@@ -999,17 +1001,86 @@ function invalidAcceptResult(accept) {
999
1001
  isError: true
1000
1002
  };
1001
1003
  }
1004
+ const MAX_TRANSFER_ENTRIES = 20;
1005
+ function withTransferList(listKey, entryParams, single) {
1006
+ const listError = (message) => ({
1007
+ content: [{ type: "text", text: JSON.stringify({ error: message }) }],
1008
+ isError: true
1009
+ });
1010
+ return async (params, ctx) => {
1011
+ const list = params[listKey];
1012
+ if (list == null) return single(params, ctx);
1013
+ if (!Array.isArray(list) || list.length === 0 || list.length > MAX_TRANSFER_ENTRIES) {
1014
+ return listError(`${listKey} must be a list of 1 to ${MAX_TRANSFER_ENTRIES} entries.`);
1015
+ }
1016
+ const mixed = Object.keys(params).filter(
1017
+ (key) => key !== listKey && key !== "account" && params[key] != null && params[key] !== ""
1018
+ );
1019
+ if (mixed.length > 0) {
1020
+ return listError(
1021
+ `With ${listKey}, give every other field inside its entries, not next to it (got ${mixed.join(", ")}).`
1022
+ );
1023
+ }
1024
+ const results = [];
1025
+ let failed = 0;
1026
+ for (const entry of list) {
1027
+ const entryInput = entryParams(entry);
1028
+ let result;
1029
+ try {
1030
+ result = await single({ ...entryInput, account: params.account }, ctx);
1031
+ } catch (error) {
1032
+ const message = error instanceof Error ? error.message : String(error);
1033
+ result = {
1034
+ content: [{ type: "text", text: JSON.stringify({ error: message || "Failed." }) }],
1035
+ isError: true
1036
+ };
1037
+ }
1038
+ const text = result.content?.[0]?.type === "text" ? result.content[0].text : "";
1039
+ let body;
1040
+ try {
1041
+ body = JSON.parse(text);
1042
+ } catch {
1043
+ body = void 0;
1044
+ }
1045
+ let entryFailed = result.isError === true;
1046
+ if (typeof body !== "object" || body === null || Array.isArray(body)) {
1047
+ body = { error: text || "No result." };
1048
+ entryFailed = true;
1049
+ }
1050
+ if (entryFailed) failed++;
1051
+ results.push({
1052
+ target: entryInput.target,
1053
+ ...entryInput.name !== void 0 && { name: entryInput.name },
1054
+ ...body
1055
+ });
1056
+ }
1057
+ return {
1058
+ content: [{ type: "text", text: JSON.stringify({ results }) }],
1059
+ // For the audit log: how many links this call handed out
1060
+ _meta: { result_count: list.length - failed },
1061
+ ...failed === list.length && { isError: true }
1062
+ };
1063
+ };
1064
+ }
1065
+ function uploadEntryParams(entry) {
1066
+ if (typeof entry !== "object" || entry === null) return {};
1067
+ const { target, name, contentType, contentId, conflictBehavior } = entry;
1068
+ return { target, name, contentType, contentId, conflictBehavior };
1069
+ }
1070
+ function downloadEntryParams(entry) {
1071
+ return { target: entry };
1072
+ }
1002
1073
  const UTILITY_TOOLS = [
1003
1074
  {
1004
1075
  name: "get-upload-url",
1005
1076
  method: "PUT",
1006
1077
  path: "tool:get-upload-url",
1007
1078
  searchKeywords: "upload attachment attach file draft email attach file event large attachment send file out-of-band upload url upload onedrive file upload sharepoint file",
1008
- description: 'Mint a short-lived, single-use URL that this server serves for uploading a file as an attachment to a draft message or an event, or as a file in a OneDrive/SharePoint folder, so the bytes go straight from the caller to Microsoft Graph instead of passing as base64 through the agent context. target is the attachments collection of the item: /me/messages/{message-id}/attachments (a draft; create it first) or /me/events/{event-id}/attachments; or a drive folder: /me/drive/root, /me/drive/items/{folder-id}, /drives/{drive-id}/items/{folder-id}, /sites/{site-id}/drive/items/{folder-id}. PUT the raw file bytes to the returned uploadUrl with a Content-Length (e.g. curl -T file "<uploadUrl>"); the response confirms the upload. Up to 150 MB. Pass contentId to attach inline, e.g. a signature picture the HTML body shows with <img src="cid:<contentId>">. For a drive folder, conflictBehavior says what happens when the name is taken (default fail; contentId does not apply). Requires --enable-attachment-urls. Returns { uploadUrl, method, expiresAt, singleUse, maxBytes, conflictBehavior? }.',
1079
+ description: 'Mint a short-lived, single-use URL that this server serves for uploading a file as an attachment to a draft message or an event, or as a file in a OneDrive/SharePoint folder, so the bytes go straight from the caller to Microsoft Graph instead of passing as base64 through the agent context. target is the attachments collection of the item: /me/messages/{message-id}/attachments (a draft; create it first) or /me/events/{event-id}/attachments; or a drive folder: /me/drive/root, /me/drive/items/{folder-id}, /drives/{drive-id}/items/{folder-id}, /sites/{site-id}/drive/items/{folder-id}. PUT the raw file bytes to the returned uploadUrl with a Content-Length (e.g. curl -T file "<uploadUrl>"); the response confirms the upload. Up to 150 MB. Pass contentId to attach inline, e.g. a signature picture the HTML body shows with <img src="cid:<contentId>">. For a drive folder, conflictBehavior says what happens when the name is taken (default fail; contentId does not apply). Requires --enable-attachment-urls. Returns { uploadUrl, method, expiresAt, singleUse, maxBytes, name, conflictBehavior? }. For several files, pass files (up to 20 entries of target, name and the optional fields) instead: one call returns { results: [...] }, one item per entry with its uploadUrl or its error. The links expire minutes after minting, so start every upload right away, in parallel or in one command.',
1009
1080
  readOnlyHint: false,
1010
1081
  openWorldHint: true,
1011
1082
  buildSchema: (ctx) => {
1012
- const schema = {
1083
+ const entry = {
1013
1084
  target: z.string().describe(
1014
1085
  "Attachments collection of a draft message or an event, e.g. /me/messages/{message-id}/attachments, /me/events/{event-id}/attachments, or /users/{user-id}/messages/{message-id}/attachments for another mailbox. Or a OneDrive/SharePoint folder: /me/drive/root, /me/drive/items/{folder-id}, /drives/{drive-id}/items/{folder-id}, /sites/{site-id}/drive/items/{folder-id}."
1015
1086
  ),
@@ -1024,6 +1095,15 @@ const UTILITY_TOOLS = [
1024
1095
  "Drive folder targets only: what happens when the folder already has a file with this name. fail (default), replace, or rename."
1025
1096
  )
1026
1097
  };
1098
+ const schema = {
1099
+ ...entry,
1100
+ // Optional so that files can stand in for them; execute still requires one form.
1101
+ target: entry.target.optional(),
1102
+ name: entry.name.optional(),
1103
+ files: z.array(z.object(entry)).min(1).max(MAX_TRANSFER_ENTRIES).optional().describe(
1104
+ `Several files at once, instead of target and name: up to ${MAX_TRANSFER_ENTRIES} entries, each with the fields of a single upload.`
1105
+ )
1106
+ };
1027
1107
  if (ctx.multiAccount) {
1028
1108
  schema["account"] = z.string().optional().describe(
1029
1109
  "Account to use when multiple Microsoft accounts are configured. Required when multiple accounts exist (see list-accounts)."
@@ -1031,7 +1111,7 @@ const UTILITY_TOOLS = [
1031
1111
  }
1032
1112
  return schema;
1033
1113
  },
1034
- execute: async (params, { authManager }) => {
1114
+ execute: withTransferList("files", uploadEntryParams, async (params, { authManager }) => {
1035
1115
  const target = params.target;
1036
1116
  const name = params.name;
1037
1117
  if (typeof target !== "string" || target.length === 0) {
@@ -1050,7 +1130,7 @@ const UTILITY_TOOLS = [
1050
1130
  optionalContentId(params.contentId),
1051
1131
  params.conflictBehavior === "" ? void 0 : params.conflictBehavior
1052
1132
  );
1053
- }
1133
+ })
1054
1134
  },
1055
1135
  {
1056
1136
  name: "upload-attachment-from-file",
@@ -1582,13 +1662,17 @@ const UTILITY_TOOLS = [
1582
1662
  method: "GET",
1583
1663
  path: "tool:get-download-url",
1584
1664
  searchKeywords: "download file download drive file download onedrive file sharepoint file download large drive file large sharepoint file large file out-of-band download pre-authenticated url",
1585
- description: "Resolve a short-lived, pre-authenticated download URL for Microsoft Graph binary content that exposes one (drive/SharePoint file content). The returned URL streams the bytes with NO Authorization header, so the client can fetch it straight to disk (e.g. curl) without round-tripping base64 through the agent context. Prefer this over download-bytes for any file above a few KB or any bulk download. Returns { downloadUrl, name?, size?, contentType? }. Mail file attachments (/messages/{id}/attachments/{id}/$value), meeting recordings and other $value byte endpoints have no pre-authenticated URL from Graph itself, but call this tool for them anyway: a server running with --enable-attachment-urls mints its own single-use URL for them, and one without it answers with the reason and points at download-bytes. With --enable-attachment-urls, drive files get a short single-use URL from this server as well, instead of the long one from Graph.",
1665
+ description: "Resolve a short-lived, pre-authenticated download URL for Microsoft Graph binary content that exposes one (drive/SharePoint file content). The returned URL streams the bytes with NO Authorization header, so the client can fetch it straight to disk (e.g. curl) without round-tripping base64 through the agent context. Prefer this over download-bytes for any file above a few KB or any bulk download. Returns { downloadUrl, name?, size?, contentType? }. Mail file attachments (/messages/{id}/attachments/{id}/$value), meeting recordings and other $value byte endpoints have no pre-authenticated URL from Graph itself, but call this tool for them anyway: a server running with --enable-attachment-urls mints its own single-use URL for them, and one without it answers with the reason and points at download-bytes. With --enable-attachment-urls, drive files get a short single-use URL from this server as well, instead of the long one from Graph. For several files, pass targets (up to 20) instead of target: one call returns { results: [...] }, one item per target with its downloadUrl or its error. Server-minted links expire minutes after minting, so start every download right away, in parallel or in one command.",
1586
1666
  readOnlyHint: true,
1587
1667
  openWorldHint: true,
1588
1668
  buildSchema: (ctx) => {
1589
1669
  const schema = {
1590
- target: z.string().describe(
1670
+ // Optional so that targets can stand in for it; execute still requires one form.
1671
+ target: z.string().optional().describe(
1591
1672
  'Relative Microsoft Graph path starting with "/". Either a driveItem content path or the item path itself, e.g. /drives/{drive-id}/items/{driveItem-id}/content, /me/drive/items/{driveItem-id}/content, or /sites/{site-id}/drive/items/{driveItem-id}. A trailing /content is optional and is stripped automatically for drive items. Mail attachment $value paths and meeting recordings are accepted on a server running with --enable-attachment-urls.'
1673
+ ),
1674
+ targets: z.array(z.string()).min(1).max(MAX_TRANSFER_ENTRIES).optional().describe(
1675
+ `Several files at once, instead of target: up to ${MAX_TRANSFER_ENTRIES} paths, each of the form target takes.`
1592
1676
  )
1593
1677
  };
1594
1678
  if (ctx.multiAccount) {
@@ -1598,7 +1682,8 @@ const UTILITY_TOOLS = [
1598
1682
  }
1599
1683
  return schema;
1600
1684
  },
1601
- execute: async (params, { graphClient, authManager, userFields }) => {
1685
+ execute: withTransferList("targets", downloadEntryParams, async (params, context) => {
1686
+ const { graphClient, authManager, userFields } = context;
1602
1687
  const target = params.target;
1603
1688
  const accountParam = params.account;
1604
1689
  if (typeof target !== "string" || target.length === 0) {
@@ -1839,7 +1924,7 @@ const UTILITY_TOOLS = [
1839
1924
  ...Object.keys(metadata).length > 0 ? { _meta: metadata } : {}
1840
1925
  };
1841
1926
  }
1842
- }
1927
+ })
1843
1928
  }
1844
1929
  ];
1845
1930
  function registerUtilityToolWithMcp(server, utility, ctx) {
@@ -2068,6 +2153,9 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
2068
2153
  if (paramName === "fileName" && config?.blobOutput) continue;
2069
2154
  if (paramName === "name" && config?.nameFilter) continue;
2070
2155
  if (paramName === "token" && config?.deltaToken) continue;
2156
+ if (config?.bodyParams && Object.prototype.hasOwnProperty.call(config.bodyParams, paramName)) {
2157
+ continue;
2158
+ }
2071
2159
  if ([
2072
2160
  "account",
2073
2161
  "confirm",
@@ -2346,7 +2434,14 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
2346
2434
  ...acceptFallback ? { acceptFallback } : {}
2347
2435
  };
2348
2436
  if (config?.fixedBody) {
2349
- body = { ...config.fixedBody };
2437
+ const built = buildFixedBody(config.fixedBody, config.bodyParams ?? {}, params);
2438
+ if ("error" in built) {
2439
+ return {
2440
+ content: [{ type: "text", text: JSON.stringify({ error: built.error }) }],
2441
+ isError: true
2442
+ };
2443
+ }
2444
+ body = built.body;
2350
2445
  }
2351
2446
  if (config?.blobOutput && isBlobOutputEnabled()) {
2352
2447
  options.forceBinary = true;
@@ -2639,6 +2734,9 @@ function registerGraphToolWithMcp(server, tool, endpointConfig, graphClient, opt
2639
2734
  }
2640
2735
  }
2641
2736
  }
2737
+ if (endpointConfig?.bodyParams) {
2738
+ Object.assign(paramSchema, bodyParamSchemas(endpointConfig.bodyParams));
2739
+ }
2642
2740
  const pathParamMatches = tool.path.matchAll(/:([a-zA-Z]+)/g);
2643
2741
  for (const match of pathParamMatches) {
2644
2742
  const pathParamName = match[1];
@@ -0,0 +1,39 @@
1
+ import { z } from "zod";
2
+ function bodyParamSchema(config) {
3
+ let schema;
4
+ if (config.type === "integer") {
5
+ const whole = z.number().int().min(config.minimum ?? Number.MIN_SAFE_INTEGER);
6
+ schema = z.union([whole, z.string().regex(/^\d+$/).transform(Number).pipe(whole)]);
7
+ } else {
8
+ schema = z.string();
9
+ if (config.required) schema = schema.min(1);
10
+ }
11
+ schema = schema.describe(config.description);
12
+ return config.required ? schema : schema.optional();
13
+ }
14
+ function bodyParamSchemas(bodyParams) {
15
+ return Object.fromEntries(
16
+ Object.entries(bodyParams).map(([name, config]) => [name, bodyParamSchema(config)])
17
+ );
18
+ }
19
+ function buildFixedBody(fixedBody, bodyParams, params) {
20
+ const body = structuredClone(fixedBody);
21
+ const schemas = bodyParamSchemas(bodyParams);
22
+ for (const [name, config] of Object.entries(bodyParams)) {
23
+ const parsed = schemas[name].safeParse(params[name]);
24
+ if (!parsed.success) {
25
+ return { error: `Invalid ${name}: ${parsed.error.issues.map((i) => i.message).join("; ")}` };
26
+ }
27
+ if (parsed.data === void 0) continue;
28
+ let node = body;
29
+ for (const step of config.target.slice(0, -1)) {
30
+ node = node[step];
31
+ }
32
+ node[config.target[config.target.length - 1]] = parsed.data;
33
+ }
34
+ return { body };
35
+ }
36
+ export {
37
+ bodyParamSchemas,
38
+ buildFixedBody
39
+ };
@@ -2,6 +2,7 @@ import { z } from "zod";
2
2
  import { queryParameterSchema } from "./query-parameter-schema.js";
3
3
  import { tidyToolJsonSchema, zodToToolJsonSchema } from "../normalize-tool-schema.js";
4
4
  import { isDestructiveOperation } from "./destructive-ops.js";
5
+ import { bodyParamSchemas } from "./body-params.js";
5
6
  import { ACCEPT_VALUE_JSON_SCHEMA } from "./media-type.js";
6
7
  import {
7
8
  isFetchAllPagesApplicable,
@@ -70,6 +71,18 @@ function describeToolSchema(tool, config, ctx = {}) {
70
71
  }
71
72
  ];
72
73
  });
74
+ if (config?.bodyParams) {
75
+ for (const [name, schema] of Object.entries(bodyParamSchemas(config.bodyParams))) {
76
+ const { inner, optional } = unwrapOptional(schema);
77
+ params.push({
78
+ name,
79
+ in: "Query",
80
+ required: !optional,
81
+ description: schema.description ?? inner.description,
82
+ schema: toParamJsonSchema(inner)
83
+ });
84
+ }
85
+ }
73
86
  if (isDestructiveOperation(tool.method, config)) {
74
87
  params.push({
75
88
  name: "confirm",
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.188.1",
4
+ "version": "0.190.0",
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",
@@ -2574,6 +2574,41 @@
2574
2574
  "ChannelMessage.Read.All"
2575
2575
  ]
2576
2576
  },
2577
+ {
2578
+ "pathPattern": "/search/query",
2579
+ "method": "post",
2580
+ "toolName": "search-files",
2581
+ "descriptionOverride": "Find files by keyword across the OneDrive and SharePoint files the signed-in user can read, without knowing the site or drive. The search is KQL keyword matching, not semantic: give a few keywords, not a sentence. A hit's resource.parentReference.driveId and resource.id go to get-drive-item.",
2582
+ "presets": ["search", "work"],
2583
+ "readOnly": true,
2584
+ "workScopes": [["Sites.Read.All"], ["Files.Read.All"]],
2585
+ "queryParams": [],
2586
+ "fixedBody": {
2587
+ "requests": [
2588
+ { "entityTypes": ["driveItem"], "query": { "queryString": "" }, "from": 0, "size": 10 }
2589
+ ]
2590
+ },
2591
+ "bodyParams": {
2592
+ "queryString": {
2593
+ "target": ["requests", 0, "query", "queryString"],
2594
+ "type": "string",
2595
+ "required": true,
2596
+ "description": "Keywords to look for in file names, metadata and content, in KQL."
2597
+ },
2598
+ "size": {
2599
+ "target": ["requests", 0, "size"],
2600
+ "type": "integer",
2601
+ "minimum": 1,
2602
+ "description": "How many hits to return. Defaults to 10."
2603
+ },
2604
+ "from": {
2605
+ "target": ["requests", 0, "from"],
2606
+ "type": "integer",
2607
+ "minimum": 0,
2608
+ "description": "Offset of the first hit, 0 by default. While moreResultsAvailable is true, the next page starts at the previous from plus the previous size."
2609
+ }
2610
+ }
2611
+ },
2577
2612
  {
2578
2613
  "pathPattern": "/copilot/retrieval",
2579
2614
  "method": "post",