@softeria/ms-365-mcp-server 0.179.1 → 0.180.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 +1 -0
- package/dist/generated/client-beta.js +3 -4
- package/dist/generated/client.js +68 -1
- package/dist/server.js +43 -4
- package/docs/deployment.md +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -852,6 +852,7 @@ Environment variables:
|
|
|
852
852
|
- `MS365_MCP_MESSAGE_SIGNOFF_PREFIX=<text>`: Signoff prepended to outgoing messages so recipients can tell they were agent-sent, e.g. `🤖`. Default: none. CLI equivalent: `--message-signoff-prefix <text>` (see Message Signoff below)
|
|
853
853
|
- `MS365_MCP_MESSAGE_SIGNOFF_SUFFIX=<text>`: Signoff appended to outgoing messages. Default: none. CLI equivalent: `--message-signoff-suffix <text>`. `--no-message-signoff` disables both (see Message Signoff below)
|
|
854
854
|
- `MS365_MCP_RATE_LIMIT_DISABLED=true|1`: Disable per-IP rate limiting in HTTP mode (default: enabled — 30 req/min on `/authorize`, `/token`, `/register`; 120 req/min on `/mcp`)
|
|
855
|
+
- `MS365_MCP_PKCE_SECRET=<32+ random characters>`: For HTTP mode with more than one instance (replicas, serverless, a restart between sign-in steps). The server derives its side of the two-leg PKCE flow from this secret instead of keeping it in process memory, so `/token` works on any instance that has the same secret. Without it, `/token` must reach the instance that served `/authorize`, or sign-in fails with `AADSTS501481`. A shorter secret fails startup
|
|
855
856
|
- `MS365_MCP_TRUST_PROXY_HOPS=<n>`: Number of trusted reverse-proxy hops in HTTP mode (default `1`). Accurate per-IP rate limiting depends on this matching your deployment — set to the number of proxies in front of the server, `0` to use the raw socket peer IP, or a comma-separated subnet list
|
|
856
857
|
- `MS365_MCP_ATTACHMENT_PORT=<port>`: Serve the attachment route on its own listener on this port (alternative to --attachment-port; requires `--enable-attachment-urls`)
|
|
857
858
|
- `MS365_MCP_ATTACHMENT_HOST=<host>`: Interface the `MS365_MCP_ATTACHMENT_PORT` listener binds (alternative to --attachment-host; requires `--attachment-port`). Defaults to the host `--http` bound — which for a wildcard `--http` means both ports answer everywhere and the port split isolates nothing. See "Splitting the attachment listener"
|
|
@@ -752,9 +752,8 @@ const microsoft_graph_customEmojiFromIdentitySet = z.object({
|
|
|
752
752
|
}).loose();
|
|
753
753
|
const microsoft_graph_teamworkCustomEmoji = z.object({
|
|
754
754
|
id: z.string().describe("The unique identifier for an entity. Read-only.").optional(),
|
|
755
|
-
contentBytes: z.string().describe(
|
|
756
|
-
|
|
757
|
-
).nullish(),
|
|
755
|
+
contentBytes: z.string().describe("Write only. Bytes for the hosted content (such as images).").nullish(),
|
|
756
|
+
contentType: z.string().describe("Write only. Content type, such as image/png, image/jpg.").nullish(),
|
|
758
757
|
createdBy: microsoft_graph_customEmojiFromIdentitySet.optional(),
|
|
759
758
|
createdDateTime: z.string().regex(
|
|
760
759
|
/^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$/
|
|
@@ -762,7 +761,7 @@ const microsoft_graph_teamworkCustomEmoji = z.object({
|
|
|
762
761
|
"The date and time when the emoji was created. The timestamp type represents date and time information using ISO 8601 format and is always in UTC. For example, midnight UTC on Jan 1, 2024, is 2024-01-01T00:00:00Z."
|
|
763
762
|
).optional(),
|
|
764
763
|
displayName: z.string().describe(
|
|
765
|
-
"The unique display name of the custom emoji.
|
|
764
|
+
"The unique display name of the custom emoji. This property is an alternate key and must not conflict with existing emoji names."
|
|
766
765
|
).optional()
|
|
767
766
|
}).loose();
|
|
768
767
|
const microsoft_graph_teamworkCustomEmojiCollectionResponse = z.object({
|
package/dist/generated/client.js
CHANGED
|
@@ -2284,6 +2284,9 @@ const microsoft_graph_calendar = z.object({
|
|
|
2284
2284
|
"true if this is the default calendar where new events are created by default, false otherwise."
|
|
2285
2285
|
).nullish(),
|
|
2286
2286
|
isRemovable: z.boolean().describe("Indicates whether this user calendar can be deleted from the user mailbox.").nullish(),
|
|
2287
|
+
isSharedWithMe: z.boolean().describe(
|
|
2288
|
+
"true if someone shared this calendar with the user; false otherwise. This property is always false for a calendar owner. This property is set when sharing is initiated in an Outlook client and can be reset when sharing is canceled through the client or the corresponding calendarPermission resource. Read-only."
|
|
2289
|
+
).nullish(),
|
|
2287
2290
|
isTallyingResponses: z.boolean().describe(
|
|
2288
2291
|
"Indicates whether this user calendar supports tracking of meeting responses. Only meeting invites sent from users' primary calendars support tracking of meeting responses."
|
|
2289
2292
|
).nullish(),
|
|
@@ -2390,6 +2393,12 @@ const microsoft_graph_labelActionSource = z.enum([
|
|
|
2390
2393
|
"none",
|
|
2391
2394
|
"unknownFutureValue"
|
|
2392
2395
|
]);
|
|
2396
|
+
const microsoft_graph_applicationMode = z.enum([
|
|
2397
|
+
"manual",
|
|
2398
|
+
"automatic",
|
|
2399
|
+
"recommended",
|
|
2400
|
+
"unknownFutureValue"
|
|
2401
|
+
]);
|
|
2393
2402
|
const microsoft_graph_usageRights = z.enum([
|
|
2394
2403
|
"unknown",
|
|
2395
2404
|
"docEdit",
|
|
@@ -2424,6 +2433,7 @@ const microsoft_graph_sensitivityLabel = z.lazy(
|
|
|
2424
2433
|
() => z.object({
|
|
2425
2434
|
id: z.string().describe("The unique identifier for an entity. Read-only.").optional(),
|
|
2426
2435
|
actionSource: microsoft_graph_labelActionSource.optional(),
|
|
2436
|
+
applicationMode: microsoft_graph_applicationMode.optional(),
|
|
2427
2437
|
autoTooltip: z.string().nullish(),
|
|
2428
2438
|
description: z.string().nullish(),
|
|
2429
2439
|
displayName: z.string().nullish(),
|
|
@@ -3837,6 +3847,24 @@ const microsoft_graph_attendanceInterval = z.object({
|
|
|
3837
3847
|
/^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$/
|
|
3838
3848
|
).datetime({ offset: true }).describe("The time the attendee left in UTC.").nullish()
|
|
3839
3849
|
}).loose();
|
|
3850
|
+
const microsoft_graph_meetingEngagementType = z.enum([
|
|
3851
|
+
"reaction",
|
|
3852
|
+
"hand",
|
|
3853
|
+
"camera",
|
|
3854
|
+
"microphone",
|
|
3855
|
+
"unknownFutureValue"
|
|
3856
|
+
]);
|
|
3857
|
+
const microsoft_graph_meetingEngagement = z.object({
|
|
3858
|
+
dateTime: z.string().regex(
|
|
3859
|
+
/^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$/
|
|
3860
|
+
).datetime({ offset: true }).describe(
|
|
3861
|
+
"The date and time when the engagement event occurred. The timestamp type represents date and time information using ISO 8601 format and is always in UTC time. For example, midnight UTC on Jan 1, 2026 is 2026-01-01T00:00:00Z."
|
|
3862
|
+
).nullish(),
|
|
3863
|
+
engagementSubType: z.string().describe(
|
|
3864
|
+
"The specific engagement action within the engagement type. The possible values are: like, love, applause, laugh, surprised for reaction; raiseHand for hand; cameraOn, cameraOff for camera; and mute, unmute for microphone."
|
|
3865
|
+
).nullish(),
|
|
3866
|
+
engagementType: microsoft_graph_meetingEngagementType.optional()
|
|
3867
|
+
}).loose();
|
|
3840
3868
|
const microsoft_graph_virtualEventExternalRegistrationInformation = z.object({
|
|
3841
3869
|
referrer: z.string().describe(
|
|
3842
3870
|
"A URL or string that represents the location from which the registrant registered. Optional."
|
|
@@ -3849,6 +3877,7 @@ const microsoft_graph_attendanceRecord = z.object({
|
|
|
3849
3877
|
id: z.string().describe("The unique identifier for an entity. Read-only.").optional(),
|
|
3850
3878
|
attendanceIntervals: z.array(microsoft_graph_attendanceInterval).describe("List of time periods between joining and leaving a meeting.").optional(),
|
|
3851
3879
|
emailAddress: z.string().describe("Email address of the user associated with this attendance record.").nullish(),
|
|
3880
|
+
engagements: z.array(microsoft_graph_meetingEngagement).describe("The list of real-time participant interaction behaviors during a meeting.").optional(),
|
|
3852
3881
|
externalRegistrationInformation: microsoft_graph_virtualEventExternalRegistrationInformation.optional(),
|
|
3853
3882
|
identity: microsoft_graph_identity.optional(),
|
|
3854
3883
|
registrationId: z.string().describe(
|
|
@@ -4124,6 +4153,10 @@ const microsoft_graph_wellknownListName = z.enum([
|
|
|
4124
4153
|
"flaggedEmails",
|
|
4125
4154
|
"unknownFutureValue"
|
|
4126
4155
|
]);
|
|
4156
|
+
const microsoft_graph_singleValueExtendedProperty = z.object({
|
|
4157
|
+
id: z.string().describe("The unique identifier for an entity. Read-only.").optional(),
|
|
4158
|
+
value: z.string().describe("The value of the property.").nullish()
|
|
4159
|
+
}).loose();
|
|
4127
4160
|
const microsoft_graph_taskStatus = z.enum([
|
|
4128
4161
|
"notStarted",
|
|
4129
4162
|
"inProgress",
|
|
@@ -4209,7 +4242,8 @@ const microsoft_graph_todoTask = z.object({
|
|
|
4209
4242
|
attachmentSessions: z.array(microsoft_graph_attachmentSession).optional(),
|
|
4210
4243
|
checklistItems: z.array(microsoft_graph_checklistItem).describe("A collection of checklistItems linked to a task.").optional(),
|
|
4211
4244
|
extensions: z.array(microsoft_graph_extension).describe("The collection of open extensions defined for the task. Nullable.").optional(),
|
|
4212
|
-
linkedResources: z.array(microsoft_graph_linkedResource).describe("A collection of resources linked to the task.").optional()
|
|
4245
|
+
linkedResources: z.array(microsoft_graph_linkedResource).describe("A collection of resources linked to the task.").optional(),
|
|
4246
|
+
singleValueExtendedProperties: z.array(microsoft_graph_singleValueExtendedProperty).describe("A collection of custom fields linked to the task.").optional()
|
|
4213
4247
|
}).loose();
|
|
4214
4248
|
const microsoft_graph_todoTaskList = z.object({
|
|
4215
4249
|
id: z.string().describe("The unique identifier for an entity. Read-only.").optional(),
|
|
@@ -4218,6 +4252,9 @@ const microsoft_graph_todoTaskList = z.object({
|
|
|
4218
4252
|
isShared: z.boolean().describe("True if the task list is shared with other users").optional(),
|
|
4219
4253
|
wellknownListName: microsoft_graph_wellknownListName.optional(),
|
|
4220
4254
|
extensions: z.array(microsoft_graph_extension).describe("The collection of open extensions defined for the task list. Nullable.").optional(),
|
|
4255
|
+
singleValueExtendedProperties: z.array(microsoft_graph_singleValueExtendedProperty).describe(
|
|
4256
|
+
"The collection of single-value extended properties defined for the task list. Nullable."
|
|
4257
|
+
).optional(),
|
|
4221
4258
|
tasks: z.array(microsoft_graph_todoTask).describe("The tasks in this task list. Read-only. Nullable.").optional()
|
|
4222
4259
|
}).loose();
|
|
4223
4260
|
const microsoft_graph_todoTaskListCollectionResponse = z.object({
|
|
@@ -4240,6 +4277,7 @@ const microsoft_graph_linkedResourceCollectionResponse = z.object({
|
|
|
4240
4277
|
"@odata.nextLink": z.string().nullable(),
|
|
4241
4278
|
value: z.array(microsoft_graph_linkedResource)
|
|
4242
4279
|
}).partial().loose();
|
|
4280
|
+
const microsoft_graph_stringDictionary = z.object({}).loose();
|
|
4243
4281
|
const microsoft_graph_checkInMethod = z.enum([
|
|
4244
4282
|
"unspecified",
|
|
4245
4283
|
"manual",
|
|
@@ -4261,10 +4299,16 @@ const microsoft_graph_checkInClaim = z.object({
|
|
|
4261
4299
|
const microsoft_graph_place = z.object({
|
|
4262
4300
|
id: z.string().describe("The unique identifier for an entity. Read-only.").optional(),
|
|
4263
4301
|
address: microsoft_graph_physicalAddress.optional(),
|
|
4302
|
+
customProperties: microsoft_graph_stringDictionary.optional(),
|
|
4264
4303
|
displayName: z.string().describe("The name that is associated with the place.").optional(),
|
|
4265
4304
|
geoCoordinates: microsoft_graph_outlookGeoCoordinates.optional(),
|
|
4266
4305
|
isWheelChairAccessible: z.boolean().describe("Indicates whether the place is wheelchair accessible.").nullish(),
|
|
4267
4306
|
label: z.string().describe("User-defined description of the place.").nullish(),
|
|
4307
|
+
lastUpdatedTime: z.string().regex(
|
|
4308
|
+
/^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$/
|
|
4309
|
+
).datetime({ offset: true }).describe(
|
|
4310
|
+
"The date and time when the place was last updated. The timestamp is in ISO 8601 format and is always in UTC. Read-only. Nullable."
|
|
4311
|
+
).nullish(),
|
|
4268
4312
|
parentId: z.string().describe("The ID of a parent place.").nullish(),
|
|
4269
4313
|
phone: z.string().describe("The phone number of the place.").nullish(),
|
|
4270
4314
|
placeId: z.string().describe("A stable service-level identifier for the place object used by Places workloads.").nullish(),
|
|
@@ -4283,10 +4327,16 @@ const microsoft_graph_placeFeatureEnablement = z.enum([
|
|
|
4283
4327
|
const microsoft_graph_room = z.object({
|
|
4284
4328
|
id: z.string().describe("The unique identifier for an entity. Read-only.").optional(),
|
|
4285
4329
|
address: microsoft_graph_physicalAddress.optional(),
|
|
4330
|
+
customProperties: microsoft_graph_stringDictionary.optional(),
|
|
4286
4331
|
displayName: z.string().describe("The name that is associated with the place.").optional(),
|
|
4287
4332
|
geoCoordinates: microsoft_graph_outlookGeoCoordinates.optional(),
|
|
4288
4333
|
isWheelChairAccessible: z.boolean().describe("Indicates whether the place is wheelchair accessible.").nullish(),
|
|
4289
4334
|
label: z.string().describe("User-defined description of the place.").nullish(),
|
|
4335
|
+
lastUpdatedTime: z.string().regex(
|
|
4336
|
+
/^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$/
|
|
4337
|
+
).datetime({ offset: true }).describe(
|
|
4338
|
+
"The date and time when the place was last updated. The timestamp is in ISO 8601 format and is always in UTC. Read-only. Nullable."
|
|
4339
|
+
).nullish(),
|
|
4290
4340
|
parentId: z.string().describe("The ID of a parent place.").nullish(),
|
|
4291
4341
|
phone: z.string().describe("The phone number of the place.").nullish(),
|
|
4292
4342
|
placeId: z.string().describe("A stable service-level identifier for the place object used by Places workloads.").nullish(),
|
|
@@ -4310,10 +4360,16 @@ const microsoft_graph_placeMode = z.object({}).loose();
|
|
|
4310
4360
|
const microsoft_graph_workspace = z.object({
|
|
4311
4361
|
id: z.string().describe("The unique identifier for an entity. Read-only.").optional(),
|
|
4312
4362
|
address: microsoft_graph_physicalAddress.optional(),
|
|
4363
|
+
customProperties: microsoft_graph_stringDictionary.optional(),
|
|
4313
4364
|
displayName: z.string().describe("The name that is associated with the place.").optional(),
|
|
4314
4365
|
geoCoordinates: microsoft_graph_outlookGeoCoordinates.optional(),
|
|
4315
4366
|
isWheelChairAccessible: z.boolean().describe("Indicates whether the place is wheelchair accessible.").nullish(),
|
|
4316
4367
|
label: z.string().describe("User-defined description of the place.").nullish(),
|
|
4368
|
+
lastUpdatedTime: z.string().regex(
|
|
4369
|
+
/^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$/
|
|
4370
|
+
).datetime({ offset: true }).describe(
|
|
4371
|
+
"The date and time when the place was last updated. The timestamp is in ISO 8601 format and is always in UTC. Read-only. Nullable."
|
|
4372
|
+
).nullish(),
|
|
4317
4373
|
parentId: z.string().describe("The ID of a parent place.").nullish(),
|
|
4318
4374
|
phone: z.string().describe("The phone number of the place.").nullish(),
|
|
4319
4375
|
placeId: z.string().describe("A stable service-level identifier for the place object used by Places workloads.").nullish(),
|
|
@@ -4336,10 +4392,16 @@ const microsoft_graph_workspace = z.object({
|
|
|
4336
4392
|
const microsoft_graph_roomList = z.object({
|
|
4337
4393
|
id: z.string().describe("The unique identifier for an entity. Read-only.").optional(),
|
|
4338
4394
|
address: microsoft_graph_physicalAddress.optional(),
|
|
4395
|
+
customProperties: microsoft_graph_stringDictionary.optional(),
|
|
4339
4396
|
displayName: z.string().describe("The name that is associated with the place.").optional(),
|
|
4340
4397
|
geoCoordinates: microsoft_graph_outlookGeoCoordinates.optional(),
|
|
4341
4398
|
isWheelChairAccessible: z.boolean().describe("Indicates whether the place is wheelchair accessible.").nullish(),
|
|
4342
4399
|
label: z.string().describe("User-defined description of the place.").nullish(),
|
|
4400
|
+
lastUpdatedTime: z.string().regex(
|
|
4401
|
+
/^[0-9]{4,}-(0[1-9]|1[012])-(0[1-9]|[12][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]([.][0-9]{1,12})?(Z|[+-][0-9][0-9]:[0-9][0-9])$/
|
|
4402
|
+
).datetime({ offset: true }).describe(
|
|
4403
|
+
"The date and time when the place was last updated. The timestamp is in ISO 8601 format and is always in UTC. Read-only. Nullable."
|
|
4404
|
+
).nullish(),
|
|
4343
4405
|
parentId: z.string().describe("The ID of a parent place.").nullish(),
|
|
4344
4406
|
phone: z.string().describe("The phone number of the place.").nullish(),
|
|
4345
4407
|
placeId: z.string().describe("A stable service-level identifier for the place object used by Places workloads.").nullish(),
|
|
@@ -5134,6 +5196,7 @@ const schemas = {
|
|
|
5134
5196
|
microsoft_graph_contactFolderCollectionResponse,
|
|
5135
5197
|
microsoft_graph_contactCollectionResponse,
|
|
5136
5198
|
microsoft_graph_labelActionSource,
|
|
5199
|
+
microsoft_graph_applicationMode,
|
|
5137
5200
|
microsoft_graph_usageRights,
|
|
5138
5201
|
microsoft_graph_usageRightsIncluded,
|
|
5139
5202
|
microsoft_graph_sensitivityLabel,
|
|
@@ -5275,6 +5338,8 @@ const schemas = {
|
|
|
5275
5338
|
microsoft_graph_onlineMeetingCollectionResponse,
|
|
5276
5339
|
microsoft_graph_virtualEventExternalInformation,
|
|
5277
5340
|
microsoft_graph_attendanceInterval,
|
|
5341
|
+
microsoft_graph_meetingEngagementType,
|
|
5342
|
+
microsoft_graph_meetingEngagement,
|
|
5278
5343
|
microsoft_graph_virtualEventExternalRegistrationInformation,
|
|
5279
5344
|
microsoft_graph_attendanceRecord,
|
|
5280
5345
|
microsoft_graph_meetingAttendanceReport,
|
|
@@ -5310,6 +5375,7 @@ const schemas = {
|
|
|
5310
5375
|
microsoft_graph_keyValuePair,
|
|
5311
5376
|
send_my_activity_notification_Body,
|
|
5312
5377
|
microsoft_graph_wellknownListName,
|
|
5378
|
+
microsoft_graph_singleValueExtendedProperty,
|
|
5313
5379
|
microsoft_graph_taskStatus,
|
|
5314
5380
|
microsoft_graph_attachmentBase,
|
|
5315
5381
|
microsoft_graph_attachmentSession,
|
|
@@ -5321,6 +5387,7 @@ const schemas = {
|
|
|
5321
5387
|
microsoft_graph_todoTaskCollectionResponse,
|
|
5322
5388
|
microsoft_graph_checklistItemCollectionResponse,
|
|
5323
5389
|
microsoft_graph_linkedResourceCollectionResponse,
|
|
5390
|
+
microsoft_graph_stringDictionary,
|
|
5324
5391
|
microsoft_graph_checkInMethod,
|
|
5325
5392
|
microsoft_graph_checkInClaim,
|
|
5326
5393
|
microsoft_graph_place,
|
package/dist/server.js
CHANGED
|
@@ -143,6 +143,20 @@ function describeBoundAddress(bound) {
|
|
|
143
143
|
return { label: authority, authority };
|
|
144
144
|
}
|
|
145
145
|
const PKCE_MAX_AGE_MS = 60 * 60 * 1e3;
|
|
146
|
+
const PKCE_SECRET_MIN_LENGTH = 32;
|
|
147
|
+
function deriveServerCodeVerifier(secret, clientCodeChallenge) {
|
|
148
|
+
return crypto.createHmac("sha256", secret).update(clientCodeChallenge).digest("base64url");
|
|
149
|
+
}
|
|
150
|
+
function statelessPkceSecret(env = process.env) {
|
|
151
|
+
const secret = env.MS365_MCP_PKCE_SECRET;
|
|
152
|
+
if (secret === void 0 || secret === "") return void 0;
|
|
153
|
+
if (secret.length < PKCE_SECRET_MIN_LENGTH) {
|
|
154
|
+
throw new Error(
|
|
155
|
+
`MS365_MCP_PKCE_SECRET must be at least ${PKCE_SECRET_MIN_LENGTH} characters; a short secret makes the derived PKCE verifier guessable.`
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
return secret;
|
|
159
|
+
}
|
|
146
160
|
class MicrosoftGraphServer {
|
|
147
161
|
constructor(authManager, options = {}) {
|
|
148
162
|
this.version = "0.0.0";
|
|
@@ -340,6 +354,10 @@ class MicrosoftGraphServer {
|
|
|
340
354
|
}
|
|
341
355
|
if (this.options.http) {
|
|
342
356
|
const { host, port } = parseHttpOption(this.options.http);
|
|
357
|
+
this.pkceSecret = statelessPkceSecret();
|
|
358
|
+
if (this.pkceSecret) {
|
|
359
|
+
logger.info("Two-leg PKCE is stateless (MS365_MCP_PKCE_SECRET set)");
|
|
360
|
+
}
|
|
343
361
|
const app = express();
|
|
344
362
|
if (this.isLoopbackOnlyHttp()) {
|
|
345
363
|
app.use(hostHeaderValidation(LOOPBACK_HOSTNAMES));
|
|
@@ -498,7 +516,20 @@ class MicrosoftGraphServer {
|
|
|
498
516
|
}
|
|
499
517
|
}
|
|
500
518
|
}
|
|
501
|
-
if (clientCodeChallenge &&
|
|
519
|
+
if (clientCodeChallenge && this.pkceSecret) {
|
|
520
|
+
if (clientCodeChallengeMethod !== "S256") {
|
|
521
|
+
res.status(400).json({
|
|
522
|
+
error: "invalid_request",
|
|
523
|
+
error_description: "code_challenge_method must be S256"
|
|
524
|
+
});
|
|
525
|
+
return;
|
|
526
|
+
}
|
|
527
|
+
const serverCodeVerifier = deriveServerCodeVerifier(this.pkceSecret, clientCodeChallenge);
|
|
528
|
+
const serverCodeChallenge = crypto.createHash("sha256").update(serverCodeVerifier).digest("base64url");
|
|
529
|
+
microsoftAuthUrl.searchParams.set("code_challenge", serverCodeChallenge);
|
|
530
|
+
microsoftAuthUrl.searchParams.set("code_challenge_method", "S256");
|
|
531
|
+
logger.info("Two-leg PKCE (stateless): derived server challenge");
|
|
532
|
+
} else if (clientCodeChallenge && state) {
|
|
502
533
|
const serverCodeVerifier = crypto.randomBytes(32).toString("base64url");
|
|
503
534
|
const serverCodeChallenge = crypto.createHash("sha256").update(serverCodeVerifier).digest("base64url");
|
|
504
535
|
const maxEntries = 1e3;
|
|
@@ -581,7 +612,12 @@ class MicrosoftGraphServer {
|
|
|
581
612
|
});
|
|
582
613
|
let matchedPkceState;
|
|
583
614
|
let matchedPkceEntry;
|
|
584
|
-
|
|
615
|
+
let derivedServerVerifier;
|
|
616
|
+
if (body.code_verifier && this.pkceSecret) {
|
|
617
|
+
const clientChallenge = crypto.createHash("sha256").update(body.code_verifier).digest("base64url");
|
|
618
|
+
derivedServerVerifier = deriveServerCodeVerifier(this.pkceSecret, clientChallenge);
|
|
619
|
+
logger.info("Two-leg PKCE (stateless): derived server verifier");
|
|
620
|
+
} else if (body.code_verifier) {
|
|
585
621
|
const clientVerifier = body.code_verifier;
|
|
586
622
|
const clientChallengeComputed = crypto.createHash("sha256").update(clientVerifier).digest("base64url");
|
|
587
623
|
for (const [state, pkceData] of this.pkceStore) {
|
|
@@ -601,7 +637,7 @@ class MicrosoftGraphServer {
|
|
|
601
637
|
clientId,
|
|
602
638
|
clientSecret,
|
|
603
639
|
tenantId,
|
|
604
|
-
matchedPkceEntry?.serverCodeVerifier || body.code_verifier,
|
|
640
|
+
derivedServerVerifier || matchedPkceEntry?.serverCodeVerifier || body.code_verifier,
|
|
605
641
|
this.secrets.cloudType,
|
|
606
642
|
this.oboRedemptionScope()
|
|
607
643
|
);
|
|
@@ -899,10 +935,13 @@ class MicrosoftGraphServer {
|
|
|
899
935
|
}
|
|
900
936
|
var server_default = MicrosoftGraphServer;
|
|
901
937
|
export {
|
|
938
|
+
PKCE_SECRET_MIN_LENGTH,
|
|
902
939
|
server_default as default,
|
|
940
|
+
deriveServerCodeVerifier,
|
|
903
941
|
isLoopbackHost,
|
|
904
942
|
loopbackOriginValidation,
|
|
905
943
|
parseAttachmentHostOption,
|
|
906
944
|
parseAttachmentPortOption,
|
|
907
|
-
parseHttpOption
|
|
945
|
+
parseHttpOption,
|
|
946
|
+
statelessPkceSecret
|
|
908
947
|
};
|
package/docs/deployment.md
CHANGED
|
@@ -97,8 +97,10 @@ docker run -p 3000:3000 \
|
|
|
97
97
|
--max-replicas 3 \
|
|
98
98
|
--cpu 0.5 --memory 1Gi \
|
|
99
99
|
--system-assigned \
|
|
100
|
+
--secrets "pkce-secret=$(openssl rand -base64 48)" \
|
|
100
101
|
--env-vars \
|
|
101
102
|
"MS365_MCP_KEYVAULT_URL=https://your-keyvault.vault.azure.net" \
|
|
103
|
+
"MS365_MCP_PKCE_SECRET=secretref:pkce-secret" \
|
|
102
104
|
"MS365_MCP_ORG_MODE=true" \
|
|
103
105
|
"MS365_MCP_PUBLIC_URL=https://mcp.example.com" \
|
|
104
106
|
--command "node" "dist/index.js" "--http" "3000" "--org-mode"
|
|
@@ -224,6 +226,7 @@ The client automatically discovers OAuth endpoints and opens a browser for authe
|
|
|
224
226
|
## Security Considerations
|
|
225
227
|
|
|
226
228
|
- **Stateless**: the server does not store tokens — each request carries the user's Bearer token
|
|
229
|
+
- **More than one instance? Set `MS365_MCP_PKCE_SECRET`** (32+ random characters, the same on every instance). Otherwise the two-leg PKCE flow keeps a mapping in process memory between `/authorize` and `/token`, and a sign-in whose `/token` lands on another replica, or comes after a restart, fails with `AADSTS501481`. With the secret, the server side of the PKCE pair is derived from the client's challenge and nothing is stored. A single instance can leave it unset. Clients must use `code_challenge_method=S256`. Setting or rotating the secret fails sign-ins that are in progress at that moment.
|
|
227
230
|
- **Account pinning**: `MS365_MCP_EXPECTED_USERNAME` and `MS365_MCP_EXPECTED_HOME_ACCOUNT_ID` protect local MSAL cache flows for headless stdio deployments. In `--http`, `--obo`, or `MS365_MCP_OAUTH_TOKEN` deployments they are warning-only because Graph calls use request-provided tokens.
|
|
228
231
|
- **Admin consent**: grant tenant-wide consent to avoid per-user consent prompts
|
|
229
232
|
- **Managed identity**: use managed identity for Key Vault access (no secrets in environment variables)
|
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.180.0",
|
|
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",
|