@softeria/ms-365-mcp-server 0.187.0 → 0.188.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.
@@ -2462,7 +2462,8 @@
2462
2462
  "presets": ["work"],
2463
2463
  "workScopes": [["Sites.ReadWrite.All"], ["Sites.Selected"]],
2464
2464
  "appScopes": [["Sites.ReadWrite.All"], ["Sites.Selected"]],
2465
- "llmTip": "Updates fields on an existing list item. Body: { fields: { ColumnName: 'new value' } }. Send only the fields you want to change. Use $expand=fields on get-sharepoint-site-list-item to see current values first."
2465
+ "supportsIfMatch": true,
2466
+ "llmTip": "Updates fields on an existing list item. Body: { fields: { ColumnName: 'new value' } }. Send only the fields you want to change. Use $expand=fields on get-sharepoint-site-list-item to see current values first. For optimistic concurrency, pass its ETag as If-Match; enable includeHeaders=true when reading to capture the ETag. A stale ETag returns 412 without applying the update."
2466
2467
  },
2467
2468
  {
2468
2469
  "pathPattern": "/sites/{site-id}/lists/{list-id}/items/{listItem-id}",
@@ -54,7 +54,8 @@ import {
54
54
  paginationAllowed,
55
55
  positiveIntFromEnv,
56
56
  SKIPTOKEN_PARAM_DESCRIPTION,
57
- TIMEZONE_PARAM_DESCRIPTION
57
+ TIMEZONE_PARAM_DESCRIPTION,
58
+ IF_MATCH_PARAM_DESCRIPTION
58
59
  } from "./lib/param-descriptions.js";
59
60
  import { describePathParam } from "./lib/path-params.js";
60
61
  import { queryParameterSchema } from "./lib/query-parameter-schema.js";
@@ -2185,6 +2186,8 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
2185
2186
  }
2186
2187
  headers["Accept"] = paramValue;
2187
2188
  }
2189
+ } else if (paramName.toLowerCase() === "if-match" && config?.supportsIfMatch) {
2190
+ headers["If-Match"] = `${paramValue}`;
2188
2191
  } else if (isOdataParam) {
2189
2192
  queryParams[fixedParamName] = `${paramValue}`;
2190
2193
  logger.info(
@@ -2648,6 +2651,9 @@ function registerGraphToolWithMcp(server, tool, endpointConfig, graphClient, opt
2648
2651
  getAcceptParamDescription(endpointConfig.acceptType)
2649
2652
  );
2650
2653
  }
2654
+ if (endpointConfig?.supportsIfMatch && !Object.keys(paramSchema).some((name) => name.toLowerCase() === "if-match")) {
2655
+ paramSchema["If-Match"] = z.string().optional().describe(IF_MATCH_PARAM_DESCRIPTION);
2656
+ }
2651
2657
  if (endpointConfig?.blobOutput && paramSchema["fileName"] === void 0) {
2652
2658
  paramSchema["fileName"] = z.string().optional().describe(
2653
2659
  "Name of the file, used as the last segment of the returned resource URI when the server runs with blob output. Optional."
@@ -69,6 +69,7 @@ const DELTA_TOKEN_PARAM_DESCRIPTION = "Delta state to resume from: the @odata.de
69
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.";
70
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.";
71
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.';
72
+ const IF_MATCH_PARAM_DESCRIPTION = "Optional ETag for a conditional update. Use the ETag from the list item read (with includeHeaders=true); if it is stale, Graph returns 412 and does not apply the update.";
72
73
  const TIMEZONE_PARAM_DESCRIPTION = 'IANA timezone name (e.g., "America/New_York", "Europe/London", "Asia/Tokyo") for calendar event times. If not specified, times are returned in UTC.';
73
74
  const EXPAND_EXTENDED_PROPERTIES_PARAM_DESCRIPTION = "When true, expands singleValueExtendedProperties on each event. Use this to retrieve custom extended properties (e.g., sync metadata) stored on calendar events.";
74
75
  function getAcceptParamDescription(acceptType) {
@@ -115,6 +116,7 @@ export {
115
116
  DEFAULT_MAX_PAGES,
116
117
  DELTA_TOKEN_PARAM_DESCRIPTION,
117
118
  EXPAND_EXTENDED_PROPERTIES_PARAM_DESCRIPTION,
119
+ IF_MATCH_PARAM_DESCRIPTION,
118
120
  MEMBER_NAME_PARAM_DESCRIPTION,
119
121
  ORDERBY_PARAM_DESCRIPTION,
120
122
  SELECT_PARAM_DESCRIPTION,
@@ -14,6 +14,7 @@ import {
14
14
  TIMEZONE_PARAM_DESCRIPTION,
15
15
  EXPAND_EXTENDED_PROPERTIES_PARAM_DESCRIPTION,
16
16
  getAcceptParamDescription,
17
+ IF_MATCH_PARAM_DESCRIPTION,
17
18
  MEMBER_NAME_PARAM_DESCRIPTION,
18
19
  DELTA_TOKEN_PARAM_DESCRIPTION
19
20
  } from "./param-descriptions.js";
@@ -157,6 +158,15 @@ function describeToolSchema(tool, config, ctx = {}) {
157
158
  schema: { ...ACCEPT_VALUE_JSON_SCHEMA }
158
159
  });
159
160
  }
161
+ if (config?.supportsIfMatch && !params.some((p) => p.name.toLowerCase() === "if-match")) {
162
+ params.push({
163
+ name: "If-Match",
164
+ in: "Header",
165
+ required: false,
166
+ description: IF_MATCH_PARAM_DESCRIPTION,
167
+ schema: { type: "string" }
168
+ });
169
+ }
160
170
  const llmTip = config?.llmTip;
161
171
  return {
162
172
  name: tool.alias,
@@ -243,21 +243,26 @@ function findCyclicDefs(defs) {
243
243
  }
244
244
  return cyclic;
245
245
  }
246
- function inlineDefRefs(node, defs, pinned, expand) {
246
+ function isLeafDef(value) {
247
+ if (!isPlainObject(value)) return false;
248
+ const type = value.type;
249
+ return typeof type === "string" && ["boolean", "integer", "number", "string", "null"].includes(type) || Array.isArray(value.enum) || "const" in value;
250
+ }
251
+ function inlineDefRefs(node, defs, keep, expand) {
247
252
  if (!node || typeof node !== "object") return node;
248
- if (Array.isArray(node)) return node.map((item) => inlineDefRefs(item, defs, pinned, expand));
253
+ if (Array.isArray(node)) return node.map((item) => inlineDefRefs(item, defs, keep, expand));
249
254
  const record = node;
250
255
  const name = defRefName(record.$ref);
251
- if (name !== null && hasDef(defs, name) && !pinned.has(name)) {
256
+ if (name !== null && hasDef(defs, name) && !keep.has(name)) {
252
257
  const siblings = {};
253
258
  for (const [key, value] of Object.entries(record)) {
254
- if (key !== "$ref") siblings[key] = inlineDefRefs(value, defs, pinned, expand);
259
+ if (key !== "$ref") siblings[key] = inlineDefRefs(value, defs, keep, expand);
255
260
  }
256
261
  return { ...structuredClone(expand(name)), ...siblings };
257
262
  }
258
263
  const out = {};
259
264
  for (const [key, value] of Object.entries(record)) {
260
- out[key] = inlineDefRefs(value, defs, pinned, expand);
265
+ out[key] = inlineDefRefs(value, defs, keep, expand);
261
266
  }
262
267
  return out;
263
268
  }
@@ -315,29 +320,36 @@ function normalizeToolSchemaRefs(schema) {
315
320
  for (const name of [...pinned]) {
316
321
  if (!hasDef(defs, name)) pinned.delete(name);
317
322
  }
318
- if (pinned.size > 0) {
319
- clone.$defs = { ...existingDefs, ...defs };
320
- return clone;
321
- }
322
- const memo = /* @__PURE__ */ new Map();
323
- const expand = (name) => {
324
- if (memo.has(name)) return memo.get(name);
325
- const value = inlineDefRefs(defs[name], defs, pinned, expand);
326
- memo.set(name, value);
327
- return value;
328
- };
329
- const inlined = inlineDefRefs(clone, defs, pinned, expand);
330
- if (Object.keys(existingDefs).length > 0) {
331
- inlined.$defs = Object.fromEntries(
332
- Object.entries(existingDefs).map(([name, value]) => [
333
- name,
334
- inlineDefRefs(value, defs, pinned, expand)
335
- ])
323
+ const inlineExcept = (keep) => {
324
+ const memo = /* @__PURE__ */ new Map();
325
+ const expand = (name) => {
326
+ if (memo.has(name)) return memo.get(name);
327
+ const value = inlineDefRefs(defs[name], defs, keep, expand);
328
+ memo.set(name, value);
329
+ return value;
330
+ };
331
+ const inlined2 = inlineDefRefs(clone, defs, keep, expand);
332
+ const keptDefs = Object.fromEntries(
333
+ [
334
+ ...Object.entries(existingDefs),
335
+ ...[...keep].map((name) => [name, defs[name]])
336
+ ].map(([name, value]) => [name, inlineDefRefs(value, defs, keep, expand)])
336
337
  );
338
+ if (Object.keys(keptDefs).length > 0) inlined2.$defs = keptDefs;
339
+ return inlined2;
340
+ };
341
+ const hoisted = { ...clone, $defs: { ...existingDefs, ...defs } };
342
+ const limit = JSON.stringify(hoisted).length * MAX_INLINE_GROWTH;
343
+ if (pinned.size === 0) {
344
+ const full = inlineExcept(pinned);
345
+ if (JSON.stringify(full).length <= limit) return full;
346
+ }
347
+ const leavesOnly = new Set(pinned);
348
+ for (const [name, value] of Object.entries(defs)) {
349
+ if (!isLeafDef(value)) leavesOnly.add(name);
337
350
  }
338
- clone.$defs = { ...existingDefs, ...defs };
339
- const grewTooMuch = JSON.stringify(inlined).length > JSON.stringify(clone).length * MAX_INLINE_GROWTH;
340
- return grewTooMuch ? clone : inlined;
351
+ const inlined = inlineExcept(leavesOnly);
352
+ return JSON.stringify(inlined).length <= limit ? inlined : hoisted;
341
353
  }
342
354
  function installToolSchemaRefNormalization(server) {
343
355
  const lowLevel = server.server;
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.187.0",
4
+ "version": "0.188.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",
@@ -2462,7 +2462,8 @@
2462
2462
  "presets": ["work"],
2463
2463
  "workScopes": [["Sites.ReadWrite.All"], ["Sites.Selected"]],
2464
2464
  "appScopes": [["Sites.ReadWrite.All"], ["Sites.Selected"]],
2465
- "llmTip": "Updates fields on an existing list item. Body: { fields: { ColumnName: 'new value' } }. Send only the fields you want to change. Use $expand=fields on get-sharepoint-site-list-item to see current values first."
2465
+ "supportsIfMatch": true,
2466
+ "llmTip": "Updates fields on an existing list item. Body: { fields: { ColumnName: 'new value' } }. Send only the fields you want to change. Use $expand=fields on get-sharepoint-site-list-item to see current values first. For optimistic concurrency, pass its ETag as If-Match; enable includeHeaders=true when reading to capture the ETag. A stale ETag returns 412 without applying the update."
2466
2467
  },
2467
2468
  {
2468
2469
  "pathPattern": "/sites/{site-id}/lists/{list-id}/items/{listItem-id}",