@softeria/ms-365-mcp-server 0.131.2 → 0.131.3

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.
@@ -1100,14 +1100,16 @@
1100
1100
  "method": "post",
1101
1101
  "toolName": "create-todo-task",
1102
1102
  "presets": ["personal", "tasks"],
1103
- "scopes": ["Tasks.ReadWrite"]
1103
+ "scopes": ["Tasks.ReadWrite"],
1104
+ "llmTip": "Creates a new task in a Microsoft To Do list. Body: { title: \"...\" }; optional dueDateTime, reminderDateTime, importance, body (notes), recurrence, categories. Requires todoTaskListId from list-todo-task-lists."
1104
1105
  },
1105
1106
  {
1106
1107
  "pathPattern": "/me/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}",
1107
1108
  "method": "patch",
1108
1109
  "toolName": "update-todo-task",
1109
1110
  "presets": ["personal", "tasks"],
1110
- "scopes": ["Tasks.ReadWrite"]
1111
+ "scopes": ["Tasks.ReadWrite"],
1112
+ "llmTip": "Updates a Microsoft To Do task. Use this to mark a to-do item complete or done (body: { status: \"completed\" }), reopen it (status: \"notStarted\"), rename it (title), or change its due date (dueDateTime), reminder (reminderDateTime), importance, or notes (body). Requires todoTaskListId from list-todo-task-lists and todoTaskId from list-todo-tasks."
1111
1113
  },
1112
1114
  {
1113
1115
  "pathPattern": "/me/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}",
@@ -0,0 +1,112 @@
1
+ import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
2
+ import logger from "./logger.js";
3
+ function unescapePointer(token) {
4
+ return token.replace(/~1/g, "/").replace(/~0/g, "~");
5
+ }
6
+ function isBadRef(value) {
7
+ return typeof value === "string" && value.startsWith("#/") && !value.startsWith("#/$defs/");
8
+ }
9
+ function collectBadRefTargets(node, targets) {
10
+ if (!node || typeof node !== "object") return;
11
+ if (Array.isArray(node)) {
12
+ for (const item of node) collectBadRefTargets(item, targets);
13
+ return;
14
+ }
15
+ for (const [key, value] of Object.entries(node)) {
16
+ if (key === "$ref" && isBadRef(value)) {
17
+ targets.add(value.slice(1));
18
+ } else {
19
+ collectBadRefTargets(value, targets);
20
+ }
21
+ }
22
+ }
23
+ function resolvePointer(root, pointer) {
24
+ const tokens = pointer.split("/").slice(1).map(unescapePointer);
25
+ if (tokens.length === 0) return null;
26
+ let parent = null;
27
+ let key = "";
28
+ let cur = root;
29
+ for (const token of tokens) {
30
+ if (!cur || typeof cur !== "object") return null;
31
+ parent = cur;
32
+ key = Array.isArray(cur) ? Number(token) : token;
33
+ cur = cur[key];
34
+ if (cur === void 0) return null;
35
+ }
36
+ return parent === null ? null : { parent, key, obj: cur };
37
+ }
38
+ function repointRefs(node, nameFor) {
39
+ if (!node || typeof node !== "object") return;
40
+ if (Array.isArray(node)) {
41
+ for (const item of node) repointRefs(item, nameFor);
42
+ return;
43
+ }
44
+ const record = node;
45
+ for (const [key, value] of Object.entries(record)) {
46
+ if (key === "$ref" && isBadRef(value)) {
47
+ const name = nameFor.get(value.slice(1));
48
+ if (name) record.$ref = `#/$defs/${name}`;
49
+ } else {
50
+ repointRefs(value, nameFor);
51
+ }
52
+ }
53
+ }
54
+ function normalizeToolSchemaRefs(schema) {
55
+ const targets = /* @__PURE__ */ new Set();
56
+ collectBadRefTargets(schema, targets);
57
+ if (targets.size === 0) return schema;
58
+ const clone = structuredClone(schema);
59
+ const slots = /* @__PURE__ */ new Map();
60
+ for (const pointer of [...targets].sort()) {
61
+ const slot = resolvePointer(clone, pointer);
62
+ if (slot) slots.set(pointer, slot);
63
+ }
64
+ if (slots.size === 0) return schema;
65
+ const takenNames = new Set(
66
+ clone.$defs && typeof clone.$defs === "object" ? Object.keys(clone.$defs) : []
67
+ );
68
+ const nameFor = /* @__PURE__ */ new Map();
69
+ let index = 0;
70
+ for (const pointer of slots.keys()) {
71
+ let name = `def${index++}`;
72
+ while (takenNames.has(name)) name = `def${index++}`;
73
+ takenNames.add(name);
74
+ nameFor.set(pointer, name);
75
+ }
76
+ const defs = {};
77
+ for (const [pointer, slot] of slots) {
78
+ defs[nameFor.get(pointer)] = slot.obj;
79
+ }
80
+ for (const [pointer, slot] of slots) {
81
+ slot.parent[slot.key] = {
82
+ $ref: `#/$defs/${nameFor.get(pointer)}`
83
+ };
84
+ }
85
+ repointRefs(clone, nameFor);
86
+ for (const name of Object.keys(defs)) repointRefs(defs[name], nameFor);
87
+ const existingDefs = clone.$defs ?? {};
88
+ clone.$defs = { ...existingDefs, ...defs };
89
+ return clone;
90
+ }
91
+ function installToolSchemaRefNormalization(server) {
92
+ const lowLevel = server.server;
93
+ const handlers = lowLevel._requestHandlers;
94
+ const original = handlers?.get("tools/list");
95
+ if (!original) {
96
+ logger.warn("Skipping tool-schema $ref normalization: tools/list handler not found");
97
+ return;
98
+ }
99
+ lowLevel.setRequestHandler(ListToolsRequestSchema, async (request, extra) => {
100
+ const result = await original(request, extra);
101
+ for (const tool of result.tools ?? []) {
102
+ if (tool.inputSchema && typeof tool.inputSchema === "object") {
103
+ tool.inputSchema = normalizeToolSchemaRefs(tool.inputSchema);
104
+ }
105
+ }
106
+ return result;
107
+ });
108
+ }
109
+ export {
110
+ installToolSchemaRefNormalization,
111
+ normalizeToolSchemaRefs
112
+ };
package/dist/server.js CHANGED
@@ -9,6 +9,7 @@ import logger, { enableConsoleLogging } from "./logger.js";
9
9
  import { registerAuthTools } from "./auth-tools.js";
10
10
  import { registerGraphTools, registerDiscoveryTools } from "./graph-tools.js";
11
11
  import { buildMcpServerInstructions } from "./mcp-instructions.js";
12
+ import { installToolSchemaRefNormalization } from "./normalize-tool-schema.js";
12
13
  import GraphClient from "./graph-client.js";
13
14
  import {
14
15
  buildScopesFromEndpoints,
@@ -102,6 +103,7 @@ class MicrosoftGraphServer {
102
103
  this.options.allowedScopes
103
104
  );
104
105
  }
106
+ installToolSchemaRefNormalization(server);
105
107
  return server;
106
108
  }
107
109
  async initialize(version) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@softeria/ms-365-mcp-server",
3
- "version": "0.131.2",
3
+ "version": "0.131.3",
4
4
  "description": " A Model Context Protocol (MCP) server for interacting with Microsoft 365 and Office services through the Graph API",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1100,14 +1100,16 @@
1100
1100
  "method": "post",
1101
1101
  "toolName": "create-todo-task",
1102
1102
  "presets": ["personal", "tasks"],
1103
- "scopes": ["Tasks.ReadWrite"]
1103
+ "scopes": ["Tasks.ReadWrite"],
1104
+ "llmTip": "Creates a new task in a Microsoft To Do list. Body: { title: \"...\" }; optional dueDateTime, reminderDateTime, importance, body (notes), recurrence, categories. Requires todoTaskListId from list-todo-task-lists."
1104
1105
  },
1105
1106
  {
1106
1107
  "pathPattern": "/me/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}",
1107
1108
  "method": "patch",
1108
1109
  "toolName": "update-todo-task",
1109
1110
  "presets": ["personal", "tasks"],
1110
- "scopes": ["Tasks.ReadWrite"]
1111
+ "scopes": ["Tasks.ReadWrite"],
1112
+ "llmTip": "Updates a Microsoft To Do task. Use this to mark a to-do item complete or done (body: { status: \"completed\" }), reopen it (status: \"notStarted\"), rename it (title), or change its due date (dueDateTime), reminder (reminderDateTime), importance, or notes (body). Requires todoTaskListId from list-todo-task-lists and todoTaskId from list-todo-tasks."
1111
1113
  },
1112
1114
  {
1113
1115
  "pathPattern": "/me/todo/lists/{todoTaskList-id}/tasks/{todoTask-id}",