@softeria/ms-365-mcp-server 0.187.0 → 0.187.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/dist/normalize-tool-schema.js +38 -26
- package/package.json +1 -1
|
@@ -243,21 +243,26 @@ function findCyclicDefs(defs) {
|
|
|
243
243
|
}
|
|
244
244
|
return cyclic;
|
|
245
245
|
}
|
|
246
|
-
function
|
|
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,
|
|
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) && !
|
|
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,
|
|
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,
|
|
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
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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
|
-
|
|
339
|
-
|
|
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.
|
|
4
|
+
"version": "0.187.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",
|