@softeria/ms-365-mcp-server 0.182.2 → 0.183.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/.gitattributes +1 -0
- package/PRESETS.md +15 -9
- package/README.md +1 -1
- package/dist/__tests__/log-safe.test.js +153 -0
- package/dist/app-mode.js +1 -0
- package/dist/attachment-route.js +11 -4
- package/dist/audit-log.js +2 -0
- package/dist/auth.js +4 -1
- package/dist/crash-logging.js +27 -13
- package/dist/endpoints.json +12 -2
- package/dist/generated/client.js +59 -0
- package/dist/graph-client.js +6 -5
- package/dist/graph-tools.js +25 -14
- package/dist/lib/bounded-file-transport.js +99 -0
- package/dist/lib/log-limits.js +12 -0
- package/dist/lib/log-safe.js +405 -0
- package/dist/lib/microsoft-auth.js +99 -1
- package/dist/logger.js +11 -4
- package/dist/server.js +38 -5
- package/package.json +1 -1
- package/src/endpoints.json +12 -2
package/.gitattributes
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
* text=auto eol=lf
|
package/PRESETS.md
CHANGED
|
@@ -10,8 +10,8 @@ Every preset also includes the account tools (`login`, `logout`, `verify-login`,
|
|
|
10
10
|
|
|
11
11
|
| Preset | Mode | Tools | Scopes | Org mode | Description |
|
|
12
12
|
| ------------- | ---------------------------------------------------------------- | ---------: | -------: | -------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
|
|
13
|
-
| `all` | [full](#all-full)<br>[read only](#all-read-only) |
|
|
14
|
-
| `calendar` | [full](#calendar-full)<br>[read only](#calendar-read-only) |
|
|
13
|
+
| `all` | [full](#all-full)<br>[read only](#all-read-only) | 371<br>181 | 65<br>38 | -<br>- | All available tools |
|
|
14
|
+
| `calendar` | [full](#calendar-full)<br>[read only](#calendar-read-only) | 48<br>23 | 7<br>5 | -<br>- | Calendar and event management |
|
|
15
15
|
| `contacts` | [full](#contacts-full)<br>[read only](#contacts-read-only) | 15<br>7 | 1<br>1 | -<br>- | Outlook contacts management |
|
|
16
16
|
| `excel` | [full](#excel-full)<br>[read only](#excel-read-only) | 25<br>9 | 1<br>1 | -<br>- | Excel spreadsheet operations |
|
|
17
17
|
| `files` | [full](#files-full)<br>[read only](#files-read-only) | 26<br>14 | 3<br>2 | -<br>- | OneDrive file and folder operations |
|
|
@@ -25,13 +25,13 @@ Every preset also includes the account tools (`login`, `logout`, `verify-login`,
|
|
|
25
25
|
| `teams` | [full](#teams-full)<br>[read only](#teams-read-only) | 73<br>43 | 31<br>18 | required<br>required | Teams app only: chats, channels, meetings and presence |
|
|
26
26
|
| `teams-write` | [full](#teams-write-full)<br>[read only](#teams-write-read-only) | 11<br>7 | 6<br>3 | required<br>required | Teams send-only: send/reply in chats and channels, list chats/teams/channels by name, activity notifications - no message reading |
|
|
27
27
|
| `users` | [full](#users-full)<br>[read only](#users-read-only) | 11<br>11 | 4<br>4 | required<br>required | User directory access |
|
|
28
|
-
| `work` | [full](#work-full)<br>[read only](#work-read-only) |
|
|
28
|
+
| `work` | [full](#work-full)<br>[read only](#work-read-only) | 191<br>111 | 55<br>33 | required<br>required | Organization/work tools (Teams, SharePoint, shared mailboxes, search) |
|
|
29
29
|
|
|
30
30
|
## `all` full
|
|
31
31
|
|
|
32
32
|
All available tools
|
|
33
33
|
|
|
34
|
-
Tools (
|
|
34
|
+
Tools (371):
|
|
35
35
|
|
|
36
36
|
- `accept-calendar-event`
|
|
37
37
|
- `add-calendar-event-attachment`
|
|
@@ -290,6 +290,7 @@ Tools (370):
|
|
|
290
290
|
- `list-planner-tasks`
|
|
291
291
|
- `list-relevant-people`
|
|
292
292
|
- `list-room-list-rooms`
|
|
293
|
+
- `list-rooms`
|
|
293
294
|
- `list-sensitivity-labels`
|
|
294
295
|
- `list-shared-calendar-events`
|
|
295
296
|
- `list-shared-mailbox-attachments`
|
|
@@ -476,7 +477,7 @@ Scopes (65):
|
|
|
476
477
|
|
|
477
478
|
All available tools
|
|
478
479
|
|
|
479
|
-
Tools (
|
|
480
|
+
Tools (181):
|
|
480
481
|
|
|
481
482
|
- `copilot-retrieve`
|
|
482
483
|
- `download-bytes`
|
|
@@ -618,6 +619,7 @@ Tools (180):
|
|
|
618
619
|
- `list-planner-tasks`
|
|
619
620
|
- `list-relevant-people`
|
|
620
621
|
- `list-room-list-rooms`
|
|
622
|
+
- `list-rooms`
|
|
621
623
|
- `list-sensitivity-labels`
|
|
622
624
|
- `list-shared-calendar-events`
|
|
623
625
|
- `list-shared-mailbox-attachments`
|
|
@@ -704,7 +706,7 @@ Scopes (38):
|
|
|
704
706
|
|
|
705
707
|
Calendar and event management
|
|
706
708
|
|
|
707
|
-
Tools (
|
|
709
|
+
Tools (48):
|
|
708
710
|
|
|
709
711
|
- `accept-calendar-event`
|
|
710
712
|
- `add-calendar-event-attachment`
|
|
@@ -742,6 +744,7 @@ Tools (47):
|
|
|
742
744
|
- `list-my-calendar-permissions`
|
|
743
745
|
- `list-outlook-categories`
|
|
744
746
|
- `list-room-list-rooms`
|
|
747
|
+
- `list-rooms`
|
|
745
748
|
- `list-specific-calendar-events`
|
|
746
749
|
- `list-supported-languages`
|
|
747
750
|
- `list-supported-time-zones`
|
|
@@ -768,7 +771,7 @@ Scopes (7):
|
|
|
768
771
|
|
|
769
772
|
Calendar and event management
|
|
770
773
|
|
|
771
|
-
Tools (
|
|
774
|
+
Tools (23):
|
|
772
775
|
|
|
773
776
|
- `download-bytes`
|
|
774
777
|
- `download-bytes-to-file`
|
|
@@ -789,6 +792,7 @@ Tools (22):
|
|
|
789
792
|
- `list-my-calendar-permissions`
|
|
790
793
|
- `list-outlook-categories`
|
|
791
794
|
- `list-room-list-rooms`
|
|
795
|
+
- `list-rooms`
|
|
792
796
|
- `list-specific-calendar-events`
|
|
793
797
|
- `list-supported-languages`
|
|
794
798
|
- `list-supported-time-zones`
|
|
@@ -2093,7 +2097,7 @@ Organization/work tools (Teams, SharePoint, shared mailboxes, search)
|
|
|
2093
2097
|
|
|
2094
2098
|
Requires `--org-mode`.
|
|
2095
2099
|
|
|
2096
|
-
Tools (
|
|
2100
|
+
Tools (191):
|
|
2097
2101
|
|
|
2098
2102
|
- `add-group-member`
|
|
2099
2103
|
- `add-group-owner`
|
|
@@ -2217,6 +2221,7 @@ Tools (190):
|
|
|
2217
2221
|
- `list-planner-tasks`
|
|
2218
2222
|
- `list-relevant-people`
|
|
2219
2223
|
- `list-room-list-rooms`
|
|
2224
|
+
- `list-rooms`
|
|
2220
2225
|
- `list-shared-calendar-events`
|
|
2221
2226
|
- `list-shared-mailbox-attachments`
|
|
2222
2227
|
- `list-shared-mailbox-child-folders`
|
|
@@ -2350,7 +2355,7 @@ Organization/work tools (Teams, SharePoint, shared mailboxes, search)
|
|
|
2350
2355
|
|
|
2351
2356
|
Requires `--org-mode`.
|
|
2352
2357
|
|
|
2353
|
-
Tools (
|
|
2358
|
+
Tools (111):
|
|
2354
2359
|
|
|
2355
2360
|
- `copilot-retrieve`
|
|
2356
2361
|
- `download-bytes`
|
|
@@ -2434,6 +2439,7 @@ Tools (110):
|
|
|
2434
2439
|
- `list-planner-tasks`
|
|
2435
2440
|
- `list-relevant-people`
|
|
2436
2441
|
- `list-room-list-rooms`
|
|
2442
|
+
- `list-rooms`
|
|
2437
2443
|
- `list-shared-calendar-events`
|
|
2438
2444
|
- `list-shared-mailbox-attachments`
|
|
2439
2445
|
- `list-shared-mailbox-child-folders`
|
package/README.md
CHANGED
|
@@ -883,7 +883,7 @@ Environment variables:
|
|
|
883
883
|
- `MS365_MCP_GRAPH_BASE_URL=<url>`: Send Graph API requests to this base URL instead of the cloud's `graph.microsoft.com` (e.g. `http://127.0.0.1:10255/tenant-a/graph` for an egress proxy that originates TLS itself). Absolute http(s) URL without query or fragment; a path prefix is kept, so requests go to `<url>/v1.0/...`. The login authority and the On-Behalf-Of token resource are unchanged. Two things bypass it: `get-download-url` returns Graph's pre-authenticated SharePoint URL, and the `302` from `/content` points straight at SharePoint, so whoever follows either connects to SharePoint directly; if you control egress, allow those SharePoint hosts or disable those tools. Not read from `.env`
|
|
884
884
|
- `LOG_LEVEL`: Set logging level (default: 'info')
|
|
885
885
|
- `SILENT=true|1`: Disable console output
|
|
886
|
-
- `MS365_MCP_REDACT_PII=false|0`: Disable scrubbing of JWTs, Bearer headers, OAuth token fields, and email addresses from log messages (default: enabled). The server handles live Graph bearer tokens, so redaction is on unless you opt out for fully verbose local debugging.
|
|
886
|
+
- `MS365_MCP_REDACT_PII=false|0`: Disable scrubbing of JWTs, Bearer headers, OAuth token fields, and email addresses from log messages, and log tool parameters, request bodies, URLs, error messages and crash dumps in full instead of by shape only (default: enabled). The server handles live Graph bearer tokens, so redaction is on unless you opt out for fully verbose local debugging.
|
|
887
887
|
- `MS365_MCP_CLIENT_ID`: Custom Azure app client ID (defaults to built-in app)
|
|
888
888
|
- `MS365_MCP_TENANT_ID`: Custom tenant ID (defaults to 'common' for multi-tenant). **Personal Microsoft accounts should set this to `consumers`** - as of June 2026, refresh tokens issued via the default 'common' authority are rejected at the first refresh, so sessions die roughly an hour after login
|
|
889
889
|
- `MS365_MCP_OAUTH_TOKEN`: Pre-existing OAuth token for Microsoft Graph API (BYOT method)
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import { afterEach, beforeEach, describe, it, expect } from "vitest";
|
|
2
|
+
import {
|
|
3
|
+
describeShape,
|
|
4
|
+
describeText,
|
|
5
|
+
describeUrl,
|
|
6
|
+
describeError,
|
|
7
|
+
describeStack,
|
|
8
|
+
serializedSize,
|
|
9
|
+
summarizeError
|
|
10
|
+
} from "../lib/log-safe.js";
|
|
11
|
+
import { dumpError } from "../crash-logging.js";
|
|
12
|
+
import { GraphApiError } from "../graph-client.js";
|
|
13
|
+
const SECRET = "SENTINEL-the quarterly numbers are bad, do not forward";
|
|
14
|
+
describe("log-safe", () => {
|
|
15
|
+
it("describes parameters by shape, never by value", () => {
|
|
16
|
+
const out = describeShape({
|
|
17
|
+
top: 10,
|
|
18
|
+
filter: `subject eq '${SECRET}'`,
|
|
19
|
+
search: `"${SECRET}"`,
|
|
20
|
+
body: { subject: SECRET, body: { contentType: "html", content: SECRET } },
|
|
21
|
+
messageIds: [SECRET, SECRET],
|
|
22
|
+
confirm: true,
|
|
23
|
+
skiptoken: null
|
|
24
|
+
});
|
|
25
|
+
expect(out).not.toContain(SECRET);
|
|
26
|
+
expect(out).toContain("top: 10");
|
|
27
|
+
expect(out).toContain(`filter: string(${SECRET.length + 13})`);
|
|
28
|
+
expect(out).toContain("body: object(2 keys)");
|
|
29
|
+
expect(out).toContain("messageIds: array(2)");
|
|
30
|
+
expect(out).toContain("confirm: true");
|
|
31
|
+
expect(out).toContain("skiptoken: null");
|
|
32
|
+
});
|
|
33
|
+
it("counts keys that are not on the known list instead of naming them", () => {
|
|
34
|
+
const out = describeShape({ [SECRET]: "x", top: 1, [`${SECRET}-2`]: 2 });
|
|
35
|
+
expect(out).toBe("{top: 1, +2 other}");
|
|
36
|
+
});
|
|
37
|
+
it("describes a string or array at the top level without its content", () => {
|
|
38
|
+
expect(describeShape(SECRET)).toBe(`string(${SECRET.length})`);
|
|
39
|
+
expect(describeShape([SECRET])).toBe("array(1)");
|
|
40
|
+
});
|
|
41
|
+
it("masks every path segment that is not a fixed Graph word", () => {
|
|
42
|
+
expect(describeUrl(`/me/drive/root:/${SECRET}.txt:/content`)).toBe(
|
|
43
|
+
"/me/drive/root:/{\u2026}/content"
|
|
44
|
+
);
|
|
45
|
+
expect(describeUrl("/me/messages/AAMkAGVj-abc=/attachments/ATT1/$value")).toBe(
|
|
46
|
+
"/me/messages/{\u2026}/attachments/{\u2026}/$value"
|
|
47
|
+
);
|
|
48
|
+
expect(describeUrl(`/users/${SECRET}@contoso.com/mailFolders/inbox/messages`)).toBe(
|
|
49
|
+
"/users/{\u2026}/mailFolders/inbox/messages"
|
|
50
|
+
);
|
|
51
|
+
});
|
|
52
|
+
it("drops the query string and lists only $-prefixed OData names", () => {
|
|
53
|
+
const url = `https://graph.microsoft.com/v1.0/me/messages?$search=%22${encodeURIComponent(SECRET)}%22&$top=5&${encodeURIComponent(SECRET)}=x`;
|
|
54
|
+
const out = describeUrl(url);
|
|
55
|
+
expect(out).not.toContain(SECRET);
|
|
56
|
+
expect(out).not.toContain(encodeURIComponent(SECRET));
|
|
57
|
+
expect(out).toBe(
|
|
58
|
+
"https://graph.microsoft.com/v1.0/me/messages [query: $search, $top, +1 other]"
|
|
59
|
+
);
|
|
60
|
+
expect(describeUrl("/me/messages")).toBe("/me/messages");
|
|
61
|
+
});
|
|
62
|
+
it("never throws on malformed input", () => {
|
|
63
|
+
expect(describeUrl("/me/messages?%malformed=x&%E0%A4%A=y")).toBe(
|
|
64
|
+
"/me/messages [query: +2 other]"
|
|
65
|
+
);
|
|
66
|
+
expect(describeUrl("")).toBe("");
|
|
67
|
+
expect(describeUrl(`http://${SECRET}/me`)).toBe("{origin}/me");
|
|
68
|
+
expect(describeUrl(void 0)).toBe("undefined");
|
|
69
|
+
});
|
|
70
|
+
it("describes a Graph error by status and code, never by message", () => {
|
|
71
|
+
const err = new GraphApiError(`Invalid filter clause: ${SECRET}`, 400, "BadRequest");
|
|
72
|
+
expect(describeError(err)).toBe("GraphApiError status=400 code=BadRequest");
|
|
73
|
+
});
|
|
74
|
+
it("shows only known error names, HTTP statuses and short codes", () => {
|
|
75
|
+
const named = new Error(`connect failed while sending ${SECRET}`);
|
|
76
|
+
named.name = SECRET;
|
|
77
|
+
expect(describeError(Object.assign(named, { code: SECRET, status: 999 }))).toBe(
|
|
78
|
+
`Error code=unlisted(${SECRET.length})`
|
|
79
|
+
);
|
|
80
|
+
expect(describeError(Object.assign(new Error("x"), { code: 7000215 }))).toBe(
|
|
81
|
+
"Error code=7000215"
|
|
82
|
+
);
|
|
83
|
+
expect(describeError(Object.assign(new Error("x"), { code: "ECONNRESET", status: 502 }))).toBe(
|
|
84
|
+
"Error status=502 code=ECONNRESET"
|
|
85
|
+
);
|
|
86
|
+
expect(describeError(SECRET)).toBe("non-error(string)");
|
|
87
|
+
});
|
|
88
|
+
it("keeps stack frames but not the message line", () => {
|
|
89
|
+
const frames = describeStack(new Error(`boom ${SECRET}`));
|
|
90
|
+
expect(frames.length).toBeGreaterThan(0);
|
|
91
|
+
for (const f of frames) {
|
|
92
|
+
expect(f.startsWith("at ")).toBe(true);
|
|
93
|
+
expect(f).not.toContain(SECRET);
|
|
94
|
+
}
|
|
95
|
+
expect(describeStack("x")).toEqual([]);
|
|
96
|
+
});
|
|
97
|
+
it("reports a serialized size without the content", () => {
|
|
98
|
+
expect(serializedSize({ a: "bc" })).toBe(Buffer.byteLength('{"a":"bc"}'));
|
|
99
|
+
const cyclic = {};
|
|
100
|
+
cyclic.self = cyclic;
|
|
101
|
+
expect(serializedSize(cyclic)).toBe(-1);
|
|
102
|
+
});
|
|
103
|
+
it("describes free text by length", () => {
|
|
104
|
+
expect(describeText(SECRET)).toBe(`(${SECRET.length} chars)`);
|
|
105
|
+
});
|
|
106
|
+
});
|
|
107
|
+
describe("log-safe with MS365_MCP_REDACT_PII=false", () => {
|
|
108
|
+
const prev = process.env.MS365_MCP_REDACT_PII;
|
|
109
|
+
beforeEach(() => {
|
|
110
|
+
process.env.MS365_MCP_REDACT_PII = "false";
|
|
111
|
+
});
|
|
112
|
+
afterEach(() => {
|
|
113
|
+
if (prev === void 0) delete process.env.MS365_MCP_REDACT_PII;
|
|
114
|
+
else process.env.MS365_MCP_REDACT_PII = prev;
|
|
115
|
+
});
|
|
116
|
+
it("logs values, URLs and free text in full", () => {
|
|
117
|
+
const params = { filter: `subject eq '${SECRET}'`, [SECRET]: 1 };
|
|
118
|
+
expect(describeShape(params)).toBe(JSON.stringify(params));
|
|
119
|
+
const cyclic = {};
|
|
120
|
+
cyclic.self = cyclic;
|
|
121
|
+
expect(describeShape(cyclic)).toBe("[unserializable: TypeError]");
|
|
122
|
+
const url = `/me/drive/root:/${SECRET}.txt:/content?$search=${SECRET}`;
|
|
123
|
+
expect(describeUrl(url)).toBe(url);
|
|
124
|
+
expect(describeText(SECRET)).toBe(SECRET);
|
|
125
|
+
});
|
|
126
|
+
it("logs the real error name, code and message", () => {
|
|
127
|
+
const err = new GraphApiError(
|
|
128
|
+
`Insufficient privileges: ${SECRET}`,
|
|
129
|
+
403,
|
|
130
|
+
"Authorization_RequestDenied"
|
|
131
|
+
);
|
|
132
|
+
expect(describeError(err)).toBe(
|
|
133
|
+
`GraphApiError status=403 code=Authorization_RequestDenied: Insufficient privileges: ${SECRET}`
|
|
134
|
+
);
|
|
135
|
+
expect(describeError(SECRET)).toBe(JSON.stringify(SECRET));
|
|
136
|
+
});
|
|
137
|
+
it("keeps the self-test summary short, since /health returns it", () => {
|
|
138
|
+
const err = Object.assign(new Error(`connect ${SECRET}`), { code: "ECONNREFUSED" });
|
|
139
|
+
expect(summarizeError(err)).toBe("Error code=ECONNREFUSED");
|
|
140
|
+
});
|
|
141
|
+
it("dumps a crash with message, properties and cause", () => {
|
|
142
|
+
const crash = Object.assign(new Error(`boom ${SECRET}`), {
|
|
143
|
+
response: { body: SECRET },
|
|
144
|
+
cause: new Error(`inner ${SECRET}`)
|
|
145
|
+
});
|
|
146
|
+
expect(dumpError(crash)).toMatchObject({
|
|
147
|
+
name: "Error",
|
|
148
|
+
message: `boom ${SECRET}`,
|
|
149
|
+
properties: { response: { body: SECRET } },
|
|
150
|
+
cause: { message: `inner ${SECRET}` }
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
});
|
package/dist/app-mode.js
CHANGED
package/dist/attachment-route.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Readable } from "node:stream";
|
|
2
2
|
import { pipeline } from "node:stream/promises";
|
|
3
3
|
import logger from "./logger.js";
|
|
4
|
+
import { describeError, describeUrl } from "./lib/log-safe.js";
|
|
4
5
|
import {
|
|
5
6
|
isPlainGraphPath,
|
|
6
7
|
TICKET_PARAM
|
|
@@ -105,7 +106,7 @@ function createAttachmentHandler(deps) {
|
|
|
105
106
|
stream = await graphClient.downloadStream(ticket.target, { accessToken });
|
|
106
107
|
} catch (error) {
|
|
107
108
|
logger.error(
|
|
108
|
-
`Attachment redemption failed for ${ticket.target}: ${error
|
|
109
|
+
`Attachment redemption failed for ${describeUrl(ticket.target)}: ${describeError(error)}`
|
|
109
110
|
);
|
|
110
111
|
res.status(502).type("text/plain").send("Upstream fetch failed");
|
|
111
112
|
return;
|
|
@@ -128,7 +129,9 @@ function createAttachmentHandler(deps) {
|
|
|
128
129
|
try {
|
|
129
130
|
await pipeline(Readable.fromWeb(stream.body), res);
|
|
130
131
|
} catch (error) {
|
|
131
|
-
logger.error(
|
|
132
|
+
logger.error(
|
|
133
|
+
`Attachment stream aborted for ${describeUrl(ticket.target)}: ${describeError(error)}`
|
|
134
|
+
);
|
|
132
135
|
res.destroy();
|
|
133
136
|
}
|
|
134
137
|
};
|
|
@@ -179,7 +182,9 @@ function createAttachmentUploadHandler(deps) {
|
|
|
179
182
|
accessToken = ticket.kind === "request-token" ? ticket.accessToken : await deps.authManager.getTokenForAccount(ticket.accountName);
|
|
180
183
|
if (!accessToken) throw new Error("No access token for this ticket");
|
|
181
184
|
} catch (error) {
|
|
182
|
-
logger.error(
|
|
185
|
+
logger.error(
|
|
186
|
+
`Attachment upload failed for ${describeUrl(ticket.target)}: ${describeError(error)}`
|
|
187
|
+
);
|
|
183
188
|
res.status(502).type("text/plain").send("Upstream upload failed");
|
|
184
189
|
return;
|
|
185
190
|
}
|
|
@@ -233,7 +238,9 @@ function createAttachmentUploadHandler(deps) {
|
|
|
233
238
|
...ticket.contentId ? { contentId: ticket.contentId } : {}
|
|
234
239
|
});
|
|
235
240
|
} catch (error) {
|
|
236
|
-
logger.error(
|
|
241
|
+
logger.error(
|
|
242
|
+
`Attachment upload failed for ${describeUrl(ticket.target)}: ${describeError(error)}`
|
|
243
|
+
);
|
|
237
244
|
if (!res.headersSent) res.status(502).type("text/plain").send("Upstream upload failed");
|
|
238
245
|
}
|
|
239
246
|
};
|
package/dist/audit-log.js
CHANGED
|
@@ -35,6 +35,8 @@ const auditLogger = winston.createLogger({
|
|
|
35
35
|
stderrLevels: ["info"],
|
|
36
36
|
silent: process.env.SILENT === "true" || process.env.SILENT === "1" || process.env.VITEST === "true"
|
|
37
37
|
}),
|
|
38
|
+
// Not bounded like the diagnostic logs: this is the audit trail, so when old
|
|
39
|
+
// records go is up to the operator.
|
|
38
40
|
new winston.transports.File({
|
|
39
41
|
filename: auditLogPath,
|
|
40
42
|
options: { flags: "a", mode: FILE_MODE }
|
package/dist/auth.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AuthError, PublicClientApplication } from "@azure/msal-node";
|
|
2
2
|
import logger from "./logger.js";
|
|
3
|
+
import { describeText } from "./lib/log-safe.js";
|
|
3
4
|
import { readFileSync } from "fs";
|
|
4
5
|
import { fileURLToPath } from "url";
|
|
5
6
|
import path from "path";
|
|
@@ -974,7 +975,9 @@ class AuthManager {
|
|
|
974
975
|
};
|
|
975
976
|
} else {
|
|
976
977
|
const errorText = await response.text();
|
|
977
|
-
logger.error(
|
|
978
|
+
logger.error(
|
|
979
|
+
`Graph API user data fetch failed: ${response.status} ${describeText(errorText)}`
|
|
980
|
+
);
|
|
978
981
|
return {
|
|
979
982
|
success: false,
|
|
980
983
|
message: `Login successful but Graph API access failed: ${response.status}`
|
package/dist/crash-logging.js
CHANGED
|
@@ -1,28 +1,42 @@
|
|
|
1
|
+
import { redactionEnabled } from "./lib/log-redactor.js";
|
|
2
|
+
import { describeError, describeStack } from "./lib/log-safe.js";
|
|
1
3
|
function dumpError(reason, depth = 0) {
|
|
2
4
|
if (depth > 5) {
|
|
3
5
|
return { truncated: true };
|
|
4
6
|
}
|
|
7
|
+
if (!redactionEnabled()) return fullDump(reason, depth);
|
|
5
8
|
if (reason instanceof Error) {
|
|
6
9
|
const dump = {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
message: reason.message,
|
|
10
|
-
stack: reason.stack
|
|
10
|
+
summary: describeError(reason),
|
|
11
|
+
stack: describeStack(reason)
|
|
11
12
|
};
|
|
12
|
-
const properties = {};
|
|
13
|
-
for (const key of Object.getOwnPropertyNames(reason)) {
|
|
14
|
-
if (key === "name" || key === "message" || key === "stack" || key === "cause") continue;
|
|
15
|
-
properties[key] = reason[key];
|
|
16
|
-
}
|
|
17
|
-
if (Object.keys(properties).length > 0) {
|
|
18
|
-
dump.properties = properties;
|
|
19
|
-
}
|
|
20
13
|
if ("cause" in reason && reason.cause !== void 0) {
|
|
21
14
|
dump.cause = dumpError(reason.cause, depth + 1);
|
|
22
15
|
}
|
|
23
16
|
return dump;
|
|
24
17
|
}
|
|
25
|
-
return { type: typeof reason
|
|
18
|
+
return { type: typeof reason };
|
|
19
|
+
}
|
|
20
|
+
function fullDump(reason, depth) {
|
|
21
|
+
if (!(reason instanceof Error)) return { type: typeof reason, value: reason };
|
|
22
|
+
const dump = {
|
|
23
|
+
name: reason.name,
|
|
24
|
+
constructor: reason.constructor?.name,
|
|
25
|
+
message: reason.message,
|
|
26
|
+
stack: reason.stack
|
|
27
|
+
};
|
|
28
|
+
const properties = {};
|
|
29
|
+
for (const key of Object.getOwnPropertyNames(reason)) {
|
|
30
|
+
if (key === "name" || key === "message" || key === "stack" || key === "cause") continue;
|
|
31
|
+
properties[key] = reason[key];
|
|
32
|
+
}
|
|
33
|
+
if (Object.keys(properties).length > 0) {
|
|
34
|
+
dump.properties = properties;
|
|
35
|
+
}
|
|
36
|
+
if ("cause" in reason && reason.cause !== void 0) {
|
|
37
|
+
dump.cause = dumpError(reason.cause, depth + 1);
|
|
38
|
+
}
|
|
39
|
+
return dump;
|
|
26
40
|
}
|
|
27
41
|
function getActiveResources() {
|
|
28
42
|
const fn = process.getActiveResourcesInfo;
|
package/dist/endpoints.json
CHANGED
|
@@ -2782,6 +2782,16 @@
|
|
|
2782
2782
|
"appScopes": ["VirtualEvent.Read.All"],
|
|
2783
2783
|
"llmTip": "Lists sessions for a webinar. Each session has startDateTime, endDateTime, joinWebUrl, subject, and is essentially an online meeting associated with the webinar."
|
|
2784
2784
|
},
|
|
2785
|
+
{
|
|
2786
|
+
"pathPattern": "/places/graph.room",
|
|
2787
|
+
"method": "get",
|
|
2788
|
+
"toolName": "list-rooms",
|
|
2789
|
+
"descriptionOverride": "List the meeting rooms in the tenant: displayName, emailAddress (to book the room), capacity, building, floorNumber and address. An empty list does not prove there are no rooms: Microsoft Places may not be set up in the tenant.",
|
|
2790
|
+
"presets": ["calendar", "work"],
|
|
2791
|
+
"workScopes": ["Place.Read.All"],
|
|
2792
|
+
"appScopes": ["Place.Read.All"],
|
|
2793
|
+
"queryParams": ["select", "top", "skip", "filter", "skiptoken"]
|
|
2794
|
+
},
|
|
2785
2795
|
{
|
|
2786
2796
|
"pathPattern": "/places/{place-id}/graph.room",
|
|
2787
2797
|
"method": "get",
|
|
@@ -2808,7 +2818,7 @@
|
|
|
2808
2818
|
"presets": ["calendar", "work"],
|
|
2809
2819
|
"workScopes": ["Place.Read.All"],
|
|
2810
2820
|
"appScopes": ["Place.Read.All"],
|
|
2811
|
-
"llmTip": "The place-id
|
|
2821
|
+
"llmTip": "The place-id must be the room list's email address (from get-room-list), not its ID. Returns rooms with displayName, emailAddress, capacity, building, floorNumber, floorLabel, and AV equipment details. Combine with find-meeting-times to find available rooms for booking."
|
|
2812
2822
|
},
|
|
2813
2823
|
{
|
|
2814
2824
|
"pathPattern": "/places/{place-id}/graph.roomList/rooms/{room-id}",
|
|
@@ -2818,7 +2828,7 @@
|
|
|
2818
2828
|
"presets": ["calendar", "work"],
|
|
2819
2829
|
"workScopes": ["Place.Read.All"],
|
|
2820
2830
|
"appScopes": ["Place.Read.All"],
|
|
2821
|
-
"llmTip": "The place-id is the room list
|
|
2831
|
+
"llmTip": "The place-id is the room list's email address (as for list-room-list-rooms), and room-id is the specific room ID. Returns full room details including capacity, building, floor, and AV equipment."
|
|
2822
2832
|
},
|
|
2823
2833
|
{
|
|
2824
2834
|
"pathPattern": "/places/{place-id}",
|
package/dist/generated/client.js
CHANGED
|
@@ -12910,6 +12910,65 @@ you can query for incremental changes in the todoTaskList. This allows you to ma
|
|
|
12910
12910
|
],
|
|
12911
12911
|
response: z.void()
|
|
12912
12912
|
},
|
|
12913
|
+
{
|
|
12914
|
+
method: "get",
|
|
12915
|
+
path: "/places/graph.room",
|
|
12916
|
+
alias: "list-rooms",
|
|
12917
|
+
description: `Get a collection of the specified type of place objects defined in a tenant. You can do the following for a given tenant:
|
|
12918
|
+
- List all buildings.
|
|
12919
|
+
- List all floors.
|
|
12920
|
+
- List all sections.
|
|
12921
|
+
- List all desks.
|
|
12922
|
+
- List all rooms.
|
|
12923
|
+
- List all workspaces.
|
|
12924
|
+
- List all room lists.
|
|
12925
|
+
- List rooms in a specific room list.
|
|
12926
|
+
- List workspaces in a specific room list.`,
|
|
12927
|
+
requestFormat: "json",
|
|
12928
|
+
parameters: [
|
|
12929
|
+
{
|
|
12930
|
+
name: "$top",
|
|
12931
|
+
type: "Query",
|
|
12932
|
+
schema: z.number().int().gte(0).describe("Show only the first n items").optional()
|
|
12933
|
+
},
|
|
12934
|
+
{
|
|
12935
|
+
name: "$skip",
|
|
12936
|
+
type: "Query",
|
|
12937
|
+
schema: z.number().int().gte(0).describe("Skip the first n items").optional()
|
|
12938
|
+
},
|
|
12939
|
+
{
|
|
12940
|
+
name: "$search",
|
|
12941
|
+
type: "Query",
|
|
12942
|
+
schema: z.string().describe("Search items by search phrases").optional()
|
|
12943
|
+
},
|
|
12944
|
+
{
|
|
12945
|
+
name: "$filter",
|
|
12946
|
+
type: "Query",
|
|
12947
|
+
schema: z.string().describe("Filter items by property values").optional()
|
|
12948
|
+
},
|
|
12949
|
+
{
|
|
12950
|
+
name: "$count",
|
|
12951
|
+
type: "Query",
|
|
12952
|
+
schema: z.boolean().describe("Include count of items").optional()
|
|
12953
|
+
},
|
|
12954
|
+
{
|
|
12955
|
+
name: "$orderby",
|
|
12956
|
+
type: "Query",
|
|
12957
|
+
schema: z.array(z.string()).describe("Order items by property values").optional()
|
|
12958
|
+
},
|
|
12959
|
+
{
|
|
12960
|
+
name: "$select",
|
|
12961
|
+
type: "Query",
|
|
12962
|
+
schema: z.array(z.string()).describe("Select properties to be returned").optional()
|
|
12963
|
+
},
|
|
12964
|
+
{
|
|
12965
|
+
name: "$expand",
|
|
12966
|
+
type: "Query",
|
|
12967
|
+
schema: z.array(z.string()).describe("Expand related entities").optional()
|
|
12968
|
+
}
|
|
12969
|
+
],
|
|
12970
|
+
response: z.void()
|
|
12971
|
+
},
|
|
12913
12972
|
{
|
|
12914
12973
|
method: "post",
|
|
12915
12974
|
path: "/planner/buckets",
|
package/dist/graph-client.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import logger from "./logger.js";
|
|
2
|
+
import { describeError, describeShape, describeUrl } from "./lib/log-safe.js";
|
|
2
3
|
import { encode as toonEncode } from "@toon-format/toon";
|
|
3
4
|
import { getGraphBaseUrl } from "./cloud-config.js";
|
|
4
5
|
import { getRequestTokens } from "./request-context.js";
|
|
@@ -246,7 +247,7 @@ class GraphClient {
|
|
|
246
247
|
}
|
|
247
248
|
return { data: result, metadata };
|
|
248
249
|
} catch (error) {
|
|
249
|
-
logger.error(
|
|
250
|
+
logger.error(`Microsoft Graph API request failed: ${describeError(error)}`);
|
|
250
251
|
throw error;
|
|
251
252
|
}
|
|
252
253
|
}
|
|
@@ -340,7 +341,7 @@ class GraphClient {
|
|
|
340
341
|
httpStatus: response.status
|
|
341
342
|
};
|
|
342
343
|
} catch (error) {
|
|
343
|
-
logger.error(
|
|
344
|
+
logger.error(`Microsoft Graph file download failed: ${describeError(error)}`);
|
|
344
345
|
throw error;
|
|
345
346
|
} finally {
|
|
346
347
|
await fileHandle.close().catch(() => void 0);
|
|
@@ -404,7 +405,7 @@ class GraphClient {
|
|
|
404
405
|
async performRequest(endpoint, accessToken, options) {
|
|
405
406
|
const apiVersion = options.apiVersion || "v1.0";
|
|
406
407
|
const url = `${getGraphBaseUrl(this.secrets.cloudType)}/${apiVersion}${endpoint}`;
|
|
407
|
-
logger.info(`[GRAPH CLIENT]
|
|
408
|
+
logger.info(`[GRAPH CLIENT] Request ${options.method || "GET"} ${describeUrl(url)}`);
|
|
408
409
|
const method = options.method || "GET";
|
|
409
410
|
const signedBody = applyMessageSignoffToRequest(method, endpoint, options.body);
|
|
410
411
|
const body = applyBatchContentType(method, endpoint, signedBody);
|
|
@@ -448,7 +449,7 @@ class GraphClient {
|
|
|
448
449
|
try {
|
|
449
450
|
const { accessToken: _redacted, ...safeOptions } = options;
|
|
450
451
|
logger.info(
|
|
451
|
-
`Calling ${endpoint} with options: ${
|
|
452
|
+
`Calling ${describeUrl(endpoint)} [${options.method || "GET"}] with options: ${describeShape(safeOptions)}${_redacted ? " [accessToken=REDACTED]" : ""}`
|
|
452
453
|
);
|
|
453
454
|
const { data, metadata } = await this.makeRequestWithMetadata(endpoint, options);
|
|
454
455
|
const outputFormat = options.forceJsonOutput ? "json" : this.outputFormat;
|
|
@@ -458,7 +459,7 @@ class GraphClient {
|
|
|
458
459
|
metadata
|
|
459
460
|
);
|
|
460
461
|
} catch (error) {
|
|
461
|
-
logger.error(`Error in Graph API request: ${error}`);
|
|
462
|
+
logger.error(`Error in Graph API request: ${describeError(error)}`);
|
|
462
463
|
const metadata = error instanceof GraphApiError ? definedMetadata({
|
|
463
464
|
http_status: error.httpStatus,
|
|
464
465
|
error_code: error.graphErrorCode
|