@softeria/ms-365-mcp-server 0.139.1 → 0.139.2

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.
@@ -535,6 +535,9 @@ function registerUtilityToolWithMcp(server, utility, ctx) {
535
535
  async (params) => utility.execute(params, ctx)
536
536
  );
537
537
  }
538
+ function namesNestedBodyType(value) {
539
+ return typeof value === "string" && value.toLowerCase().endsWith("itembody");
540
+ }
538
541
  function bodySchemaShape(schema) {
539
542
  let current = schema;
540
543
  for (let i = 0; i < 10 && current; i++) {
@@ -722,11 +725,39 @@ async function executeGraphTool(tool, config, graphClient, params, authManager)
722
725
  logger.warn(`Dropping unrecognized parameter '${paramName}' for tool ${tool.alias}`);
723
726
  }
724
727
  }
728
+ if (isPlainObject(body) && bodyShape != null && hasOwn(bodyShape, "body") && !Object.keys(body).some((k) => k.toLowerCase() === "body")) {
729
+ const nestedShape = bodySchemaShape(bodyShape.body);
730
+ if (nestedShape != null) {
731
+ const nestedKeys = new Set(Object.keys(nestedShape).map((k) => k.toLowerCase()));
732
+ const outerKeys = new Set(Object.keys(bodyShape).map((k) => k.toLowerCase()));
733
+ const nested = /* @__PURE__ */ Object.create(null);
734
+ const kept = /* @__PURE__ */ Object.create(null);
735
+ const annotations = /* @__PURE__ */ Object.create(null);
736
+ for (const [key, value] of Object.entries(body)) {
737
+ const lower = key.toLowerCase();
738
+ if (key.startsWith("@")) {
739
+ if (lower === "@odata.type" && namesNestedBodyType(value)) {
740
+ annotations[key] = value;
741
+ } else {
742
+ kept[key] = value;
743
+ }
744
+ } else if (nestedKeys.has(lower) && !outerKeys.has(lower)) {
745
+ nested[key] = value;
746
+ } else {
747
+ kept[key] = value;
748
+ }
749
+ }
750
+ if (Object.keys(nested).length > 0) {
751
+ body = { ...kept, body: { ...nested, ...annotations } };
752
+ logger.info(
753
+ `Moved misplaced fields into nested 'body' for ${tool.alias}: ${Object.keys(nested).join(", ")}`
754
+ );
755
+ }
756
+ }
757
+ }
725
758
  if (Object.keys(strayBodyFields).length > 0) {
726
759
  if (isPlainObject(body)) {
727
- const keys = Object.keys(body);
728
- const bodyIsNestedField = bodyShape != null && hasOwn(bodyShape, "body") && keys.length > 0 && keys.every((k) => !hasOwn(bodyShape, k));
729
- body = bodyIsNestedField ? { ...strayBodyFields, body } : { ...strayBodyFields, ...body };
760
+ body = { ...strayBodyFields, ...body };
730
761
  logger.info(`Merged flattened body fields: ${Object.keys(strayBodyFields).join(", ")}`);
731
762
  } else if (body == null) {
732
763
  body = strayBodyFields;
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.139.1",
4
+ "version": "0.139.2",
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",