@softeria/ms-365-mcp-server 0.175.0 → 0.176.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/PRESETS.md +22 -10
- package/bin/modules/generate-mcp-tools.mjs +24 -1
- package/dist/__tests__/graph-tools.test.js +4 -4
- package/dist/endpoints.json +66 -1
- package/dist/generated/client-beta.js +50 -50
- package/dist/generated/client.js +717 -515
- package/dist/graph-tools.js +34 -25
- package/dist/lib/tool-schema.js +39 -12
- package/dist/normalize-tool-schema.js +170 -1
- package/package.json +2 -3
- package/src/endpoints.json +66 -1
package/dist/graph-tools.js
CHANGED
|
@@ -1112,9 +1112,9 @@ const UTILITY_TOOLS = [
|
|
|
1112
1112
|
target: z.string().describe(
|
|
1113
1113
|
'Relative Microsoft Graph path starting with "/". Common paths: /drives/{drive-id}/items/{driveItem-id}/content (drive file content); /me/messages/{message-id}/attachments/{attachment-id}/$value (mail attachment, list-mail-attachments returns the IDs); /me/photo/$value or /users/{user-id}/photo/$value (profile photo); /chats/{chat-id}/messages/{chatMessage-id}/hostedContents/{chatMessageHostedContent-id}/$value (Teams chat hosted content, list-chat-message-hosted-contents returns the IDs); /teams/{team-id}/channels/{channel-id}/messages/{chatMessage-id}/hostedContents/{chatMessageHostedContent-id}/$value (Teams channel hosted content). For meeting recordings, use get-meeting-recording-content where available; Microsoft Graph returns authenticated recording bytes, not a pre-authenticated download URL.'
|
|
1114
1114
|
),
|
|
1115
|
-
fileName: z.string().describe(
|
|
1115
|
+
fileName: z.string().optional().describe(
|
|
1116
1116
|
"Name of the file, used as the last segment of the returned resource URI when the server runs with blob output. Optional."
|
|
1117
|
-
)
|
|
1117
|
+
)
|
|
1118
1118
|
};
|
|
1119
1119
|
if (ctx.multiAccount) {
|
|
1120
1120
|
schema["account"] = z.string().optional().describe(
|
|
@@ -1595,14 +1595,23 @@ function bodySchemaShape(schema) {
|
|
|
1595
1595
|
if (current instanceof z.ZodObject) {
|
|
1596
1596
|
return current.shape;
|
|
1597
1597
|
}
|
|
1598
|
-
const def = current.
|
|
1599
|
-
current = def
|
|
1598
|
+
const def = current.def;
|
|
1599
|
+
current = def.innerType ?? def.in ?? def.getter?.();
|
|
1600
1600
|
}
|
|
1601
1601
|
return null;
|
|
1602
1602
|
}
|
|
1603
|
+
const lenientBodySchemas = /* @__PURE__ */ new WeakMap();
|
|
1603
1604
|
function lenientBodySchema(schema) {
|
|
1605
|
+
let lenient = lenientBodySchemas.get(schema);
|
|
1606
|
+
if (!lenient) {
|
|
1607
|
+
lenient = buildLenientBodySchema(schema);
|
|
1608
|
+
lenientBodySchemas.set(schema, lenient);
|
|
1609
|
+
}
|
|
1610
|
+
return lenient;
|
|
1611
|
+
}
|
|
1612
|
+
function buildLenientBodySchema(schema) {
|
|
1604
1613
|
if (schema instanceof z.ZodObject) {
|
|
1605
|
-
return schema.
|
|
1614
|
+
return schema.loose();
|
|
1606
1615
|
}
|
|
1607
1616
|
if (schema instanceof z.ZodOptional) {
|
|
1608
1617
|
return lenientBodySchema(schema.unwrap()).optional();
|
|
@@ -1611,7 +1620,7 @@ function lenientBodySchema(schema) {
|
|
|
1611
1620
|
return lenientBodySchema(schema.unwrap()).nullable();
|
|
1612
1621
|
}
|
|
1613
1622
|
if (schema instanceof z.ZodLazy) {
|
|
1614
|
-
return z.lazy(() => lenientBodySchema(schema.
|
|
1623
|
+
return z.lazy(() => lenientBodySchema(schema.unwrap()));
|
|
1615
1624
|
}
|
|
1616
1625
|
return schema;
|
|
1617
1626
|
}
|
|
@@ -2332,37 +2341,37 @@ function registerGraphToolWithMcp(server, tool, endpointConfig, graphClient, opt
|
|
|
2332
2341
|
}
|
|
2333
2342
|
}
|
|
2334
2343
|
if (endpointConfig?.acceptType && paramSchema["Accept"] === void 0) {
|
|
2335
|
-
paramSchema["Accept"] = z.string().describe(getAcceptParamDescription(endpointConfig.acceptType))
|
|
2344
|
+
paramSchema["Accept"] = z.string().optional().describe(getAcceptParamDescription(endpointConfig.acceptType));
|
|
2336
2345
|
}
|
|
2337
2346
|
if (endpointConfig?.blobOutput && paramSchema["fileName"] === void 0) {
|
|
2338
|
-
paramSchema["fileName"] = z.string().describe(
|
|
2347
|
+
paramSchema["fileName"] = z.string().optional().describe(
|
|
2339
2348
|
"Name of the file, used as the last segment of the returned resource URI when the server runs with blob output. Optional."
|
|
2340
|
-
)
|
|
2349
|
+
);
|
|
2341
2350
|
}
|
|
2342
2351
|
if (isFetchAllPagesApplicable(tool)) {
|
|
2343
2352
|
const maxPages = getMaxPages();
|
|
2344
|
-
paramSchema["fetchAllPages"] = z.boolean().describe(getFetchAllPagesParamDescription(maxPages, endpointConfig))
|
|
2353
|
+
paramSchema["fetchAllPages"] = z.boolean().optional().describe(getFetchAllPagesParamDescription(maxPages, endpointConfig));
|
|
2345
2354
|
}
|
|
2346
2355
|
if (endpointConfig?.nameFilter) {
|
|
2347
|
-
paramSchema["name"] = z.string().
|
|
2356
|
+
paramSchema["name"] = z.string().optional().describe(MEMBER_NAME_PARAM_DESCRIPTION);
|
|
2348
2357
|
}
|
|
2349
2358
|
if (isSkiptokenApplicable(tool, Object.keys(paramSchema), endpointConfig)) {
|
|
2350
|
-
paramSchema["skiptoken"] = z.string().
|
|
2359
|
+
paramSchema["skiptoken"] = z.string().optional().describe(SKIPTOKEN_PARAM_DESCRIPTION);
|
|
2351
2360
|
}
|
|
2352
2361
|
if (multiAccount) {
|
|
2353
|
-
paramSchema["account"] = z.string().describe(getAccountParamDescription(accountNames))
|
|
2362
|
+
paramSchema["account"] = z.string().optional().describe(getAccountParamDescription(accountNames));
|
|
2354
2363
|
}
|
|
2355
|
-
paramSchema["includeHeaders"] = z.boolean().describe("Include response headers (including ETag) in the response metadata")
|
|
2356
|
-
paramSchema["excludeResponse"] = z.boolean().describe("Exclude the full response body and only return success or failure indication")
|
|
2364
|
+
paramSchema["includeHeaders"] = z.boolean().optional().describe("Include response headers (including ETag) in the response metadata");
|
|
2365
|
+
paramSchema["excludeResponse"] = z.boolean().optional().describe("Exclude the full response body and only return success or failure indication");
|
|
2357
2366
|
const destructive = isDestructiveOperation(tool.method, endpointConfig);
|
|
2358
2367
|
if (destructive) {
|
|
2359
|
-
paramSchema["confirm"] = z.boolean().
|
|
2368
|
+
paramSchema["confirm"] = z.boolean().optional().describe(CONFIRM_PARAM_DESCRIPTION);
|
|
2360
2369
|
}
|
|
2361
2370
|
if (endpointConfig?.supportsTimezone) {
|
|
2362
|
-
paramSchema["timezone"] = z.string().
|
|
2371
|
+
paramSchema["timezone"] = z.string().optional().describe(TIMEZONE_PARAM_DESCRIPTION);
|
|
2363
2372
|
}
|
|
2364
2373
|
if (endpointConfig?.supportsExpandExtendedProperties) {
|
|
2365
|
-
paramSchema["expandExtendedProperties"] = z.boolean().
|
|
2374
|
+
paramSchema["expandExtendedProperties"] = z.boolean().optional().describe(EXPAND_EXTENDED_PROPERTIES_PARAM_DESCRIPTION);
|
|
2366
2375
|
}
|
|
2367
2376
|
let toolDescription = withApiVersionPrefix(
|
|
2368
2377
|
(endpointConfig?.descriptionOverride ?? tool.description) || `Execute ${tool.method.toUpperCase()} request to ${tool.path}`,
|
|
@@ -2379,7 +2388,7 @@ function registerGraphToolWithMcp(server, tool, endpointConfig, graphClient, opt
|
|
|
2379
2388
|
{
|
|
2380
2389
|
title: tool.alias,
|
|
2381
2390
|
description: toolDescription,
|
|
2382
|
-
inputSchema: z.object(paramSchema).
|
|
2391
|
+
inputSchema: z.object(paramSchema).loose(),
|
|
2383
2392
|
annotations: {
|
|
2384
2393
|
title: tool.alias,
|
|
2385
2394
|
readOnlyHint: isReadOnlyTool,
|
|
@@ -2726,11 +2735,11 @@ function registerDiscoveryTools(server, graphClient, options = {}) {
|
|
|
2726
2735
|
"search-tools",
|
|
2727
2736
|
`Search through ${totalCount} tools (${toolsRegistry.size} Microsoft Graph API operations + ${utilityTools.length} server utilities like download-bytes). Ranks results by BM25 over tool name, llmTip, description, and path. After picking a tool, call get-tool-schema for parameters, then execute-tool.`,
|
|
2728
2737
|
{
|
|
2729
|
-
query: z.string().describe(
|
|
2738
|
+
query: z.string().optional().describe(
|
|
2730
2739
|
'Natural-language query. Tokenized and BM25-ranked. E.g. "send email", "download photo", "list unread messages".'
|
|
2731
|
-
)
|
|
2732
|
-
category: z.string().describe(`Optional pre-filter by category: ${categoryNames}`)
|
|
2733
|
-
limit: z.number().describe("Maximum results (default: 10, max: 50)")
|
|
2740
|
+
),
|
|
2741
|
+
category: z.string().optional().describe(`Optional pre-filter by category: ${categoryNames}`),
|
|
2742
|
+
limit: z.number().optional().describe("Maximum results (default: 10, max: 50)")
|
|
2734
2743
|
},
|
|
2735
2744
|
{
|
|
2736
2745
|
title: "search-tools",
|
|
@@ -2815,9 +2824,9 @@ function registerDiscoveryTools(server, graphClient, options = {}) {
|
|
|
2815
2824
|
"Execute a Microsoft Graph API tool by name. Workflow: search-tools \u2192 get-tool-schema \u2192 execute-tool. Call get-tool-schema first for any tool you have not seen before \u2014 passing the wrong shape to parameters will fail validation or return a Graph 400. For list endpoints, prefer modest $top plus $select.",
|
|
2816
2825
|
{
|
|
2817
2826
|
tool_name: z.string().describe('Name of the tool to execute (e.g., "list-mail-messages")'),
|
|
2818
|
-
parameters: z.record(z.any()).describe(
|
|
2827
|
+
parameters: z.record(z.string(), z.any()).optional().describe(
|
|
2819
2828
|
'Parameters shaped per get-tool-schema. Path/query/header params go at the top level; request bodies go under "body".'
|
|
2820
|
-
)
|
|
2829
|
+
)
|
|
2821
2830
|
},
|
|
2822
2831
|
{
|
|
2823
2832
|
title: "execute-tool",
|
package/dist/lib/tool-schema.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { z } from "zod";
|
|
2
2
|
import { queryParameterSchema } from "./query-parameter-schema.js";
|
|
3
|
+
import { tidyToolJsonSchema, zodToToolJsonSchema } from "../normalize-tool-schema.js";
|
|
3
4
|
import { isDestructiveOperation } from "./destructive-ops.js";
|
|
4
5
|
import {
|
|
5
6
|
isFetchAllPagesApplicable,
|
|
@@ -15,27 +16,53 @@ import {
|
|
|
15
16
|
MEMBER_NAME_PARAM_DESCRIPTION
|
|
16
17
|
} from "./param-descriptions.js";
|
|
17
18
|
function unwrapOptional(schema) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (typeName === "ZodOptional" || typeName === "ZodDefault" || typeName === "ZodNullable") {
|
|
21
|
-
return { inner: def.innerType, optional: true };
|
|
19
|
+
if (schema instanceof z.ZodOptional || schema instanceof z.ZodDefault || schema instanceof z.ZodNullable) {
|
|
20
|
+
return { inner: schema.unwrap(), optional: true };
|
|
22
21
|
}
|
|
23
22
|
return { inner: schema, optional: false };
|
|
24
23
|
}
|
|
24
|
+
function toParamJsonSchema(schema) {
|
|
25
|
+
const json = zodToToolJsonSchema(schema, "inline");
|
|
26
|
+
delete json.$schema;
|
|
27
|
+
const definitions = json.definitions ?? {};
|
|
28
|
+
delete json.definitions;
|
|
29
|
+
const expanded = expandRecursion(json, definitions, /* @__PURE__ */ new Set());
|
|
30
|
+
tidyToolJsonSchema(expanded);
|
|
31
|
+
return expanded;
|
|
32
|
+
}
|
|
33
|
+
function expandRecursion(node, definitions, expanding) {
|
|
34
|
+
if (!node || typeof node !== "object") return node;
|
|
35
|
+
if (Array.isArray(node)) return node.map((item) => expandRecursion(item, definitions, expanding));
|
|
36
|
+
const { $ref, ...rest } = node;
|
|
37
|
+
const siblings = {};
|
|
38
|
+
for (const [key, value] of Object.entries(rest)) {
|
|
39
|
+
siblings[key] = expandRecursion(value, definitions, expanding);
|
|
40
|
+
}
|
|
41
|
+
if (typeof $ref !== "string") return siblings;
|
|
42
|
+
const name = $ref.startsWith("#/definitions/") ? $ref.slice("#/definitions/".length) : null;
|
|
43
|
+
if (name === null || expanding.has(name) || !Object.prototype.hasOwnProperty.call(definitions, name)) {
|
|
44
|
+
return siblings;
|
|
45
|
+
}
|
|
46
|
+
const target = expandRecursion(
|
|
47
|
+
definitions[name],
|
|
48
|
+
definitions,
|
|
49
|
+
/* @__PURE__ */ new Set([...expanding, name])
|
|
50
|
+
);
|
|
51
|
+
return { ...target, ...siblings };
|
|
52
|
+
}
|
|
25
53
|
function describeToolSchema(tool, config, ctx = {}) {
|
|
26
54
|
const params = (tool.parameters ?? []).flatMap((p) => {
|
|
27
55
|
const effectiveSchema = p.type === "Query" ? queryParameterSchema(p.name, p.schema, config) : p.schema;
|
|
28
56
|
if (!effectiveSchema) return [];
|
|
29
57
|
const { inner, optional } = unwrapOptional(effectiveSchema);
|
|
30
58
|
const isPath = p.type === "Path";
|
|
31
|
-
const
|
|
32
|
-
const { $schema: _s, ...schema } = jsonSchema;
|
|
59
|
+
const schema = toParamJsonSchema(inner);
|
|
33
60
|
return [
|
|
34
61
|
{
|
|
35
62
|
name: p.name,
|
|
36
63
|
in: p.type,
|
|
37
64
|
required: isPath || !optional,
|
|
38
|
-
description: effectiveSchema.description ?? p.description,
|
|
65
|
+
description: effectiveSchema.description ?? inner.description ?? p.description,
|
|
39
66
|
schema
|
|
40
67
|
}
|
|
41
68
|
];
|
|
@@ -130,13 +157,12 @@ function describeUtilityToolSchema(utility, ctx) {
|
|
|
130
157
|
const schemaMap = utility.buildSchema(ctx);
|
|
131
158
|
const params = Object.entries(schemaMap).map(([name, zodSchema]) => {
|
|
132
159
|
const { inner, optional } = unwrapOptional(zodSchema);
|
|
133
|
-
const
|
|
134
|
-
const { $schema: _s, ...schema } = jsonSchema;
|
|
160
|
+
const schema = toParamJsonSchema(inner);
|
|
135
161
|
return {
|
|
136
162
|
name,
|
|
137
163
|
in: "Query",
|
|
138
164
|
required: !optional,
|
|
139
|
-
description: zodSchema.description,
|
|
165
|
+
description: zodSchema.description ?? inner.description,
|
|
140
166
|
schema
|
|
141
167
|
};
|
|
142
168
|
});
|
|
@@ -150,5 +176,6 @@ function describeUtilityToolSchema(utility, ctx) {
|
|
|
150
176
|
}
|
|
151
177
|
export {
|
|
152
178
|
describeToolSchema,
|
|
153
|
-
describeUtilityToolSchema
|
|
179
|
+
describeUtilityToolSchema,
|
|
180
|
+
toParamJsonSchema
|
|
154
181
|
};
|
|
@@ -1,5 +1,142 @@
|
|
|
1
1
|
import { ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import { z } from "zod";
|
|
2
3
|
import logger from "./logger.js";
|
|
4
|
+
function dropZodOnlyChecks(node) {
|
|
5
|
+
if (!node || typeof node !== "object") return;
|
|
6
|
+
if (Array.isArray(node)) {
|
|
7
|
+
for (const item of node) dropZodOnlyChecks(item);
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const record = node;
|
|
11
|
+
const allOf = record.allOf;
|
|
12
|
+
if (typeof record.format === "string" && Array.isArray(allOf) && allOf.length > 0 && allOf.every(
|
|
13
|
+
(item) => isPlainObject(item) && Object.keys(item).every((key) => key === "type" || key === "pattern")
|
|
14
|
+
)) {
|
|
15
|
+
record.pattern = allOf[0].pattern;
|
|
16
|
+
delete record.allOf;
|
|
17
|
+
}
|
|
18
|
+
if (record.type === "integer") {
|
|
19
|
+
if (record.maximum === Number.MAX_SAFE_INTEGER) delete record.maximum;
|
|
20
|
+
if (record.minimum === Number.MIN_SAFE_INTEGER) delete record.minimum;
|
|
21
|
+
}
|
|
22
|
+
for (const value of Object.values(record)) dropZodOnlyChecks(value);
|
|
23
|
+
}
|
|
24
|
+
function closesUnknownKeys(schema) {
|
|
25
|
+
const def = schema._zod?.def;
|
|
26
|
+
return def?.type === "object" && def.catchall === void 0;
|
|
27
|
+
}
|
|
28
|
+
function zodToToolJsonSchema(schema, reused = "ref") {
|
|
29
|
+
const json = z.toJSONSchema(schema, {
|
|
30
|
+
target: "draft-07",
|
|
31
|
+
io: "input",
|
|
32
|
+
unrepresentable: "any",
|
|
33
|
+
reused,
|
|
34
|
+
override: ({ zodSchema, jsonSchema }) => {
|
|
35
|
+
if (closesUnknownKeys(zodSchema)) jsonSchema.additionalProperties = false;
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
dropZodOnlyChecks(json);
|
|
39
|
+
return json;
|
|
40
|
+
}
|
|
41
|
+
const parameterJsonCache = /* @__PURE__ */ new WeakMap();
|
|
42
|
+
function parameterJson(schema) {
|
|
43
|
+
let json = parameterJsonCache.get(schema);
|
|
44
|
+
if (!json) {
|
|
45
|
+
json = zodToToolJsonSchema(schema);
|
|
46
|
+
delete json.$schema;
|
|
47
|
+
parameterJsonCache.set(schema, json);
|
|
48
|
+
}
|
|
49
|
+
return structuredClone(json);
|
|
50
|
+
}
|
|
51
|
+
function anchorRefs(node, base) {
|
|
52
|
+
if (!node || typeof node !== "object") return;
|
|
53
|
+
if (Array.isArray(node)) {
|
|
54
|
+
for (const item of node) anchorRefs(item, base);
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
const record = node;
|
|
58
|
+
for (const [key, value] of Object.entries(record)) {
|
|
59
|
+
if (key === "$ref" && typeof value === "string" && value.startsWith("#")) {
|
|
60
|
+
record.$ref = `#${base}${value.slice(1)}`;
|
|
61
|
+
} else {
|
|
62
|
+
anchorRefs(value, base);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function toolInputJsonSchema(schema) {
|
|
67
|
+
const { shape, catchall } = schema._zod.def;
|
|
68
|
+
const properties = {};
|
|
69
|
+
const required = [];
|
|
70
|
+
for (const [name, parameter] of Object.entries(shape)) {
|
|
71
|
+
const json = parameterJson(parameter);
|
|
72
|
+
anchorRefs(json, `/properties/${escapePointer(name)}`);
|
|
73
|
+
properties[name] = json;
|
|
74
|
+
if (inputOptin(parameter) === void 0) required.push(name);
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
$schema: "http://json-schema.org/draft-07/schema#",
|
|
78
|
+
type: "object",
|
|
79
|
+
properties,
|
|
80
|
+
...required.length > 0 ? { required } : {},
|
|
81
|
+
// .loose() tools take flattened body fields at the top level (#569). A tool with no
|
|
82
|
+
// parameters says nothing, like the SDK's empty schema did.
|
|
83
|
+
...catchall === void 0 && Object.keys(shape).length === 0 ? {} : { additionalProperties: !(catchall === void 0 || catchall._zod.def.type === "never") }
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function inputOptin(schema) {
|
|
87
|
+
const def = schema._zod.def;
|
|
88
|
+
if (def.type === "pipe" && def.in?._zod.def.type === "transform" && def.out) {
|
|
89
|
+
return inputOptin(def.out);
|
|
90
|
+
}
|
|
91
|
+
if (def.type === "catch" && def.innerType) return inputOptin(def.innerType);
|
|
92
|
+
return schema._zod.optin;
|
|
93
|
+
}
|
|
94
|
+
function tidyToolJsonSchema(node) {
|
|
95
|
+
if (!node || typeof node !== "object") return;
|
|
96
|
+
if (Array.isArray(node)) {
|
|
97
|
+
for (const item of node) tidyToolJsonSchema(item);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const record = node;
|
|
101
|
+
for (const value of Object.values(record)) tidyToolJsonSchema(value);
|
|
102
|
+
const allOf = record.allOf;
|
|
103
|
+
if (Array.isArray(allOf) && allOf.length === 1 && isPlainObject(allOf[0])) {
|
|
104
|
+
const only = allOf[0];
|
|
105
|
+
const clashes = Object.keys(only).filter((key) => key !== "description" && key in record);
|
|
106
|
+
const keepsWrapper = "$ref" in only && Object.keys(record).length > 1;
|
|
107
|
+
if (clashes.length === 0 && !keepsWrapper) {
|
|
108
|
+
delete record.allOf;
|
|
109
|
+
for (const [key, value] of Object.entries(only)) {
|
|
110
|
+
if (!(key in record)) record[key] = value;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
const anyOf = record.anyOf;
|
|
115
|
+
if (Array.isArray(anyOf) && anyOf.length === 2 && !("type" in record)) {
|
|
116
|
+
const [value, nullable] = anyOf;
|
|
117
|
+
if (isPlainObject(value) && typeof value.type === "string" && Object.keys(value).every((key) => key === "type" || key === "description") && isPlainObject(nullable) && Object.keys(nullable).length === 1 && nullable.type === "null") {
|
|
118
|
+
delete record.anyOf;
|
|
119
|
+
record.type = [value.type, "null"];
|
|
120
|
+
if (value.description !== void 0 && record.description === void 0) {
|
|
121
|
+
record.description = value.description;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const extra = record.additionalProperties;
|
|
126
|
+
if (isPlainObject(extra) && Object.keys(extra).length === 0) {
|
|
127
|
+
record.additionalProperties = true;
|
|
128
|
+
}
|
|
129
|
+
const names = record.propertyNames;
|
|
130
|
+
if (isPlainObject(names) && Object.keys(names).length === 1 && names.type === "string") {
|
|
131
|
+
delete record.propertyNames;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function isPlainObject(value) {
|
|
135
|
+
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
136
|
+
}
|
|
137
|
+
function escapePointer(token) {
|
|
138
|
+
return token.replace(/~/g, "~0").replace(/\//g, "~1");
|
|
139
|
+
}
|
|
3
140
|
const MAX_INLINE_GROWTH = 2;
|
|
4
141
|
function unescapePointer(token) {
|
|
5
142
|
return token.replace(/~1/g, "/").replace(/~0/g, "~");
|
|
@@ -157,6 +294,18 @@ function normalizeToolSchemaRefs(schema) {
|
|
|
157
294
|
}
|
|
158
295
|
repointRefs(clone, nameFor);
|
|
159
296
|
for (const name of Object.keys(defs)) repointRefs(defs[name], nameFor);
|
|
297
|
+
const definitionOwners = /* @__PURE__ */ new Set();
|
|
298
|
+
for (const pointer of slots.keys()) {
|
|
299
|
+
const match = /^(.*)\/definitions\/[^/]+$/.exec(pointer);
|
|
300
|
+
if (match) definitionOwners.add(match[1]);
|
|
301
|
+
}
|
|
302
|
+
for (const owner of definitionOwners) {
|
|
303
|
+
const holder = owner === "" ? clone : resolvePointer(clone, owner)?.obj;
|
|
304
|
+
const block = isPlainObject(holder) ? holder.definitions : void 0;
|
|
305
|
+
if (isPlainObject(holder) && isPlainObject(block) && Object.keys(block).every((name) => slots.has(`${owner}/definitions/${escapePointer(name)}`))) {
|
|
306
|
+
delete holder.definitions;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
160
309
|
const existingDefs = clone.$defs ?? {};
|
|
161
310
|
delete clone.$defs;
|
|
162
311
|
const pinned = findCyclicDefs(defs);
|
|
@@ -198,17 +347,37 @@ function installToolSchemaRefNormalization(server) {
|
|
|
198
347
|
logger.warn("Skipping tool-schema $ref normalization: tools/list handler not found");
|
|
199
348
|
return;
|
|
200
349
|
}
|
|
350
|
+
const registered = server._registeredTools;
|
|
201
351
|
lowLevel.setRequestHandler(ListToolsRequestSchema, async (request, extra) => {
|
|
352
|
+
for (const [name, tool] of Object.entries(registered ?? {})) {
|
|
353
|
+
if (tool.inputSchema instanceof z.core.$ZodObject) useOwnConversion(name, tool.inputSchema);
|
|
354
|
+
}
|
|
202
355
|
const result = await original(request, extra);
|
|
203
356
|
for (const tool of result.tools ?? []) {
|
|
204
357
|
if (tool.inputSchema && typeof tool.inputSchema === "object") {
|
|
205
358
|
tool.inputSchema = normalizeToolSchemaRefs(tool.inputSchema);
|
|
359
|
+
tidyToolJsonSchema(tool.inputSchema);
|
|
206
360
|
}
|
|
207
361
|
}
|
|
208
362
|
return result;
|
|
209
363
|
});
|
|
210
364
|
}
|
|
365
|
+
function useOwnConversion(name, schema) {
|
|
366
|
+
const internals = schema._zod;
|
|
367
|
+
if (internals.toJSONSchema) return;
|
|
368
|
+
internals.toJSONSchema = () => {
|
|
369
|
+
try {
|
|
370
|
+
return toolInputJsonSchema(schema);
|
|
371
|
+
} catch (error) {
|
|
372
|
+
logger.warn(`Could not convert the input schema of ${name}: ${error}`);
|
|
373
|
+
return void 0;
|
|
374
|
+
}
|
|
375
|
+
};
|
|
376
|
+
}
|
|
211
377
|
export {
|
|
212
378
|
installToolSchemaRefNormalization,
|
|
213
|
-
normalizeToolSchemaRefs
|
|
379
|
+
normalizeToolSchemaRefs,
|
|
380
|
+
tidyToolJsonSchema,
|
|
381
|
+
toolInputJsonSchema,
|
|
382
|
+
zodToToolJsonSchema
|
|
214
383
|
};
|
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.
|
|
4
|
+
"version": "0.176.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",
|
|
@@ -47,8 +47,7 @@
|
|
|
47
47
|
"open": "^11.0.0",
|
|
48
48
|
"parse5": "^8.0.1",
|
|
49
49
|
"winston": "^3.17.0",
|
|
50
|
-
"zod": "^
|
|
51
|
-
"zod-to-json-schema": "^3.25.1"
|
|
50
|
+
"zod": "^4.6.7"
|
|
52
51
|
},
|
|
53
52
|
"optionalDependencies": {
|
|
54
53
|
"@azure/identity": "^4.5.0",
|
package/src/endpoints.json
CHANGED
|
@@ -1204,6 +1204,41 @@
|
|
|
1204
1204
|
"presets": ["onenote", "personal"],
|
|
1205
1205
|
"scopes": ["Notes.Read"]
|
|
1206
1206
|
},
|
|
1207
|
+
{
|
|
1208
|
+
"pathPattern": "/me/onenote/pages/{onenotePage-id}/content",
|
|
1209
|
+
"method": "patch",
|
|
1210
|
+
"toolName": "update-onenote-page-content",
|
|
1211
|
+
"presets": ["onenote", "personal"],
|
|
1212
|
+
"scopes": ["Notes.ReadWrite"],
|
|
1213
|
+
"requestBodySchema": {
|
|
1214
|
+
"type": "array",
|
|
1215
|
+
"description": "Array of patchContentCommand objects applied in order to the page's HTML.",
|
|
1216
|
+
"items": {
|
|
1217
|
+
"type": "object",
|
|
1218
|
+
"required": ["target", "action"],
|
|
1219
|
+
"properties": {
|
|
1220
|
+
"target": {
|
|
1221
|
+
"type": "string",
|
|
1222
|
+
"description": "Element to change: a data-id, the generated id, or a known name like 'body' or 'title'."
|
|
1223
|
+
},
|
|
1224
|
+
"action": {
|
|
1225
|
+
"type": "string",
|
|
1226
|
+
"enum": ["append", "insert", "prepend", "replace", "delete"],
|
|
1227
|
+
"description": "What to do at the target. 'delete' takes no content."
|
|
1228
|
+
},
|
|
1229
|
+
"position": {
|
|
1230
|
+
"type": "string",
|
|
1231
|
+
"enum": ["after", "before"],
|
|
1232
|
+
"description": "For 'insert'/'append', whether content goes after (default) or before the target's content."
|
|
1233
|
+
},
|
|
1234
|
+
"content": {
|
|
1235
|
+
"type": "string",
|
|
1236
|
+
"description": "HTML to add. Required for all actions except 'delete'."
|
|
1237
|
+
}
|
|
1238
|
+
}
|
|
1239
|
+
}
|
|
1240
|
+
}
|
|
1241
|
+
},
|
|
1207
1242
|
{
|
|
1208
1243
|
"pathPattern": "/sites/{site-id}/onenote/notebooks",
|
|
1209
1244
|
"method": "get",
|
|
@@ -1358,7 +1393,15 @@
|
|
|
1358
1393
|
"presets": ["personal", "tasks"],
|
|
1359
1394
|
"scopes": ["Tasks.Read"],
|
|
1360
1395
|
"queryParams": ["top", "skip", "filter", "skiptoken"],
|
|
1361
|
-
"llmTip": "
|
|
1396
|
+
"llmTip": "If it returns only 'Flagged Emails', use list-todo-task-lists-delta instead."
|
|
1397
|
+
},
|
|
1398
|
+
{
|
|
1399
|
+
"pathPattern": "/me/todo/lists/delta()",
|
|
1400
|
+
"method": "get",
|
|
1401
|
+
"toolName": "list-todo-task-lists-delta",
|
|
1402
|
+
"presets": ["personal", "tasks"],
|
|
1403
|
+
"scopes": ["Tasks.ReadWrite"],
|
|
1404
|
+
"queryParams": ["select", "skiptoken"]
|
|
1362
1405
|
},
|
|
1363
1406
|
{
|
|
1364
1407
|
"pathPattern": "/me/todo/lists/{todoTaskList-id}/tasks",
|
|
@@ -2172,6 +2215,28 @@
|
|
|
2172
2215
|
"workScopes": [["Sites.Read.All"], ["Sites.Selected"]],
|
|
2173
2216
|
"llmTip": "Add $expand=fields to include actual column values. Without it, only metadata is returned."
|
|
2174
2217
|
},
|
|
2218
|
+
{
|
|
2219
|
+
"pathPattern": "/sites/{site-id}/lists/{list-id}/items/delta()",
|
|
2220
|
+
"method": "get",
|
|
2221
|
+
"toolName": "list-sharepoint-site-list-items-delta",
|
|
2222
|
+
"presets": ["work"],
|
|
2223
|
+
"workScopes": [["Sites.Read.All"], ["Sites.Selected"]],
|
|
2224
|
+
"queryParams": ["select", "expand", "top"]
|
|
2225
|
+
},
|
|
2226
|
+
{
|
|
2227
|
+
"pathPattern": "/sites/{site-id}/lists/{list-id}/items/{listItem-id}/versions",
|
|
2228
|
+
"method": "get",
|
|
2229
|
+
"toolName": "list-sharepoint-site-list-item-versions",
|
|
2230
|
+
"presets": ["work"],
|
|
2231
|
+
"workScopes": [["Sites.Read.All"], ["Sites.Selected"]]
|
|
2232
|
+
},
|
|
2233
|
+
{
|
|
2234
|
+
"pathPattern": "/sites/{site-id}/lists/{list-id}/items/{listItem-id}/versions/{listItemVersion-id}",
|
|
2235
|
+
"method": "get",
|
|
2236
|
+
"toolName": "get-sharepoint-site-list-item-version",
|
|
2237
|
+
"presets": ["work"],
|
|
2238
|
+
"workScopes": [["Sites.Read.All"], ["Sites.Selected"]]
|
|
2239
|
+
},
|
|
2175
2240
|
{
|
|
2176
2241
|
"pathPattern": "/sites/{site-id}/lists/{list-id}/items",
|
|
2177
2242
|
"method": "post",
|