@teamnetwork-nz/m365-mcp-server 1.7.4 → 1.8.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.
- package/README.md +2 -0
- package/dist/strict-tools.js +39 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @teamnetwork-nz/m365-mcp-server
|
|
2
2
|
|
|
3
|
+
Tools accept optional `outputFormat: "json"` to return valid JSON text. The option is removed locally and is never sent to Microsoft Graph.
|
|
4
|
+
|
|
3
5
|
## Streamable HTTP
|
|
4
6
|
|
|
5
7
|
Set `M365_TRANSPORT=http` to serve stateless MCP at `/mcp`. It binds to `127.0.0.1` by default; remote binding requires `M365_HTTP_BEARER_TOKEN` and `M365_HTTP_ALLOWED_HOSTS`. Optional controls include `M365_HTTP_PORT`, `M365_HTTP_ALLOWED_ORIGINS`, and `M365_HTTP_MAX_BODY_BYTES`; `/health` is available for health checks.
|
package/dist/strict-tools.js
CHANGED
|
@@ -17,13 +17,50 @@ function strictSchema(schema) {
|
|
|
17
17
|
return schema.strict();
|
|
18
18
|
return schema;
|
|
19
19
|
}
|
|
20
|
+
function addOutputFormat(schema) {
|
|
21
|
+
const strict = strictSchema(schema);
|
|
22
|
+
if (typeof strict.extend !== "function")
|
|
23
|
+
return strict;
|
|
24
|
+
return strict.extend({
|
|
25
|
+
outputFormat: z.enum(["json"]).optional().describe("Return the result as valid JSON text without Markdown wrappers."),
|
|
26
|
+
}).strict?.() ?? strict;
|
|
27
|
+
}
|
|
28
|
+
function toJsonValue(text) {
|
|
29
|
+
const fenced = text.match(/\x60\x60\x60json\s*([\s\S]*?)\s*\x60\x60\x60/i)?.[1];
|
|
30
|
+
const candidate = fenced ?? text;
|
|
31
|
+
try {
|
|
32
|
+
return JSON.parse(candidate);
|
|
33
|
+
}
|
|
34
|
+
catch {
|
|
35
|
+
return text;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
20
38
|
/** Make every tool object reject undeclared arguments, including no-argument tools. */
|
|
21
39
|
export function enforceStrictToolInputs(server) {
|
|
22
40
|
const mutable = server;
|
|
23
41
|
const createRegisteredTool = mutable._createRegisteredTool.bind(server);
|
|
24
42
|
mutable._createRegisteredTool = (...args) => {
|
|
25
|
-
//
|
|
26
|
-
args[3] =
|
|
43
|
+
// The MCP-only output option is stripped here so it cannot leak into vendor API parameters.
|
|
44
|
+
args[3] = addOutputFormat(args[3]);
|
|
45
|
+
const handler = args[8];
|
|
46
|
+
if (typeof handler === "function") {
|
|
47
|
+
args[8] = async (input, ...rest) => {
|
|
48
|
+
const values = input && typeof input === "object" ? input : {};
|
|
49
|
+
const { outputFormat, ...toolArgs } = values;
|
|
50
|
+
const result = await handler(toolArgs, ...rest);
|
|
51
|
+
if (outputFormat !== "json" || result?.isError || !Array.isArray(result?.content))
|
|
52
|
+
return result;
|
|
53
|
+
const textItems = result.content.filter((item) => item.type === "text" && typeof item.text === "string");
|
|
54
|
+
if (textItems.length === 0)
|
|
55
|
+
return result;
|
|
56
|
+
const data = result.structuredContent !== undefined
|
|
57
|
+
? result.structuredContent
|
|
58
|
+
: textItems.length === 1
|
|
59
|
+
? toJsonValue((textItems[0]?.text ?? ''))
|
|
60
|
+
: textItems.map((item) => toJsonValue(item.text));
|
|
61
|
+
return { ...result, content: [{ type: "text", text: JSON.stringify(data, null, 2) }], ...(result.structuredContent === undefined && data && typeof data === "object" ? { structuredContent: data } : {}) };
|
|
62
|
+
};
|
|
63
|
+
}
|
|
27
64
|
return createRegisteredTool(...args);
|
|
28
65
|
};
|
|
29
66
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teamnetwork-nz/m365-mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.8.0",
|
|
4
4
|
"description": "MCP server for Microsoft 365 — Email, Calendar, To Do, SharePoint document libraries, and Teams — using client credentials (app-only auth). Supports multiple accounts, shared mailboxes, per-mailbox read-only access, and grant-based SharePoint access control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|