@chrischall/microsoft-teams-mcp 0.5.1 → 0.6.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/bundle.js CHANGED
@@ -248,6 +248,7 @@ __export(util_exports, {
248
248
  required: () => required,
249
249
  safeExtend: () => safeExtend,
250
250
  shallowClone: () => shallowClone,
251
+ sizeCaps: () => sizeCaps,
251
252
  slugify: () => slugify,
252
253
  stringifyPrimitive: () => stringifyPrimitive,
253
254
  toZod: () => toZod,
@@ -671,6 +672,18 @@ function prefixIssues(path, issues) {
671
672
  function unwrapMessage(message) {
672
673
  return typeof message === "string" ? message : message?.message;
673
674
  }
675
+ function sizeCaps(defChecks) {
676
+ const caps = [];
677
+ for (const ch of defChecks ?? []) {
678
+ const d = ch._zod.def;
679
+ if (!/_(length|size)$|_equals$/.test(d.check))
680
+ break;
681
+ const max = d.maximum ?? d.length ?? d.size;
682
+ if (max >= 0)
683
+ caps.push([max, ch]);
684
+ }
685
+ return caps;
686
+ }
674
687
  function attachSchema(issues, start, inst) {
675
688
  var _a3;
676
689
  for (let i = start; i < issues.length; i++) {
@@ -2234,7 +2247,7 @@ var init_versions = __esm({
2234
2247
  version = {
2235
2248
  major: 4,
2236
2249
  minor: 6,
2237
- patch: 5
2250
+ patch: 7
2238
2251
  };
2239
2252
  }
2240
2253
  });
@@ -2396,6 +2409,28 @@ function isValidJWT(token, algorithm = null) {
2396
2409
  return false;
2397
2410
  }
2398
2411
  }
2412
+ function capSize(inst, size) {
2413
+ const caps = sizeCaps(inst._zod.def.checks);
2414
+ if (!caps.length)
2415
+ return;
2416
+ const cap = Math.min(...caps.map((c) => c[0]));
2417
+ const parse3 = inst._zod.parse;
2418
+ inst._zod.parse = (payload, ctx) => {
2419
+ const n = size(payload.value);
2420
+ if (n > cap && !ctx?.skipChecks && ctx?.direction !== "backward") {
2421
+ for (const [max, ch] of sizeCaps(inst._zod.def.checks)) {
2422
+ if (n > max && ch._zod.def.when(payload)) {
2423
+ const start = payload.issues.length;
2424
+ ch._zod.check(payload);
2425
+ payload.issues[start].continue = false;
2426
+ attachSchema(payload.issues, start, inst);
2427
+ return payload;
2428
+ }
2429
+ }
2430
+ }
2431
+ return parse3(payload, ctx);
2432
+ };
2433
+ }
2399
2434
  function handleArrayResult(result, final, index) {
2400
2435
  if (result.issues.length) {
2401
2436
  final.issues.push(...prefixIssues(index, result.issues));
@@ -2896,7 +2931,7 @@ function handleRefineResult(result, payload, input2, inst) {
2896
2931
  payload.issues.push(issue(_iss));
2897
2932
  }
2898
2933
  }
2899
- var $ZodType, toStandardResult, $ZodString, $ZodStringFormat, $ZodGUID, $ZodUUID, $ZodEmail, URL_BAD_FORMAT, URL_UNPARSEABLE, asciiTabOrNewline, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodISODateTime, $ZodISODate, $ZodISOTime, $ZodISODuration, $ZodIPv4, ipv6Alphabet, $ZodIPv6, $ZodMAC, $ZodCIDRv4, $ZodCIDRv6, base64Charset, $ZodBase64, base64urlCharset, $ZodBase64URL, $ZodE164, CC_SANITIZE, $ZodCreditCard, $ZodIBAN, $ZodJWT, $ZodCustomStringFormat, $ZodNumber, $ZodNumberFormat, $ZodBoolean, $ZodBigInt, $ZodBigIntFormat, $ZodSymbol, $ZodUndefined, $ZodNull, $ZodAny, $ZodUnknown, $ZodNever, $ZodVoid, $ZodDate, $ZodArray, NO_SYMBOL_KEYS, $ZodObject, $ZodObjectJIT, $ZodUnion, $ZodXor, $ZodDiscriminatedUnion, $ZodIntersection, $ZodTuple, $ZodRecord, $ZodMap, $ZodSet, $ZodEnum, $ZodLiteral, $ZodFile, $ZodTransform, $ZodOptional, $ZodExactOptional, $ZodNullable, $ZodDefault, $ZodPrefault, $ZodNonOptional, $ZodSuccess, $ZodCatch, $ZodNaN, $ZodPipe, $ZodCodec, $ZodPreprocess, $ZodReadonly, $ZodTemplateLiteral, $ZodFunction, $ZodPromise, $ZodLazy, $ZodCustom;
2934
+ var $ZodType, toStandardResult, $ZodString, $ZodStringFormat, $ZodGUID, $ZodUUID, $ZodEmail, URL_BAD_FORMAT, URL_UNPARSEABLE, asciiTabOrNewline, $ZodURL, $ZodEmoji, $ZodNanoID, $ZodCUID, $ZodCUID2, $ZodULID, $ZodXID, $ZodKSUID, $ZodISODateTime, $ZodISODate, $ZodISOTime, $ZodISODuration, $ZodIPv4, ipv6Alphabet, $ZodIPv6, $ZodMAC, $ZodCIDRv4, $ZodCIDRv6, base64Charset, $ZodBase64, base64urlCharset, $ZodBase64URL, $ZodE164, CC_SANITIZE, $ZodCreditCard, $ZodIBAN, $ZodJWT, $ZodCustomStringFormat, $ZodNumber, $ZodNumberFormat, $ZodBoolean, $ZodBigInt, $ZodBigIntFormat, $ZodSymbol, $ZodUndefined, $ZodNull, $ZodAny, $ZodUnknown, $ZodNever, $ZodVoid, $ZodDate, arraySize, mapSize, setSize, $ZodArray, NO_SYMBOL_KEYS, $ZodObject, $ZodObjectJIT, $ZodUnion, $ZodXor, $ZodDiscriminatedUnion, $ZodIntersection, $ZodTuple, $ZodRecord, $ZodMap, $ZodSet, $ZodEnum, $ZodLiteral, $ZodFile, $ZodTransform, $ZodOptional, $ZodExactOptional, $ZodNullable, $ZodDefault, $ZodPrefault, $ZodNonOptional, $ZodSuccess, $ZodCatch, $ZodNaN, $ZodPipe, $ZodCodec, $ZodPreprocess, $ZodReadonly, $ZodTemplateLiteral, $ZodFunction, $ZodPromise, $ZodLazy, $ZodCustom;
2900
2935
  var init_schemas = __esm({
2901
2936
  "node_modules/zod/v4/core/schemas.js"() {
2902
2937
  init_checks();
@@ -3503,6 +3538,9 @@ var init_schemas = __esm({
3503
3538
  return payload;
3504
3539
  };
3505
3540
  });
3541
+ arraySize = (input2) => Array.isArray(input2) ? input2.length : -1;
3542
+ mapSize = (input2) => input2 instanceof Map ? input2.size : -1;
3543
+ setSize = (input2) => input2 instanceof Set ? input2.size : -1;
3506
3544
  $ZodArray = /* @__PURE__ */ $constructor("$ZodArray", (inst, def) => {
3507
3545
  $ZodType.init(inst, def);
3508
3546
  const memo3 = globalConfig.memoizer;
@@ -3540,6 +3578,7 @@ var init_schemas = __esm({
3540
3578
  }
3541
3579
  return payload;
3542
3580
  };
3581
+ capSize(inst, arraySize);
3543
3582
  });
3544
3583
  NO_SYMBOL_KEYS = [];
3545
3584
  $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
@@ -4178,6 +4217,7 @@ var init_schemas = __esm({
4178
4217
  return Promise.all(proms).then(() => payload);
4179
4218
  return payload;
4180
4219
  };
4220
+ capSize(inst, mapSize);
4181
4221
  });
4182
4222
  $ZodSet = /* @__PURE__ */ $constructor("$ZodSet", (inst, def) => {
4183
4223
  $ZodType.init(inst, def);
@@ -4214,6 +4254,7 @@ var init_schemas = __esm({
4214
4254
  return Promise.all(proms).then(() => payload);
4215
4255
  return payload;
4216
4256
  };
4257
+ capSize(inst, setSize);
4217
4258
  });
4218
4259
  $ZodEnum = /* @__PURE__ */ $constructor("$ZodEnum", (inst, def) => {
4219
4260
  $ZodType.init(inst, def);
@@ -14003,9 +14044,15 @@ function generateNullableCheck(doc, ctx, schema, accessor, buildsValue = true) {
14003
14044
  doc.write(`}`);
14004
14045
  return outputVar;
14005
14046
  }
14047
+ function generateSizeGate(doc, schema, size) {
14048
+ for (const [max, check2] of sizeCaps(schema._zod.def.checks)) {
14049
+ doc.write(`if (${size} > ${numericOperand(max, check2._zod.def.check)}) return INVALID;`);
14050
+ }
14051
+ }
14006
14052
  function generateArrayCheck(doc, ctx, schema, accessor, buildsValue = true) {
14007
14053
  const def = schema._zod.def;
14008
14054
  doc.write(`if (!Array.isArray(${accessor})) return INVALID;`);
14055
+ generateSizeGate(doc, schema, `${accessor}.length`);
14009
14056
  const outputVar = buildsValue ? newVar(ctx) : null;
14010
14057
  const iVar = newVar(ctx);
14011
14058
  const elemVar = newVar(ctx);
@@ -14405,6 +14452,7 @@ function literalPropertyKey(ctx, key) {
14405
14452
  function generateMapCheck(doc, ctx, schema, accessor) {
14406
14453
  const def = schema._zod.def;
14407
14454
  doc.write(`if (!(${accessor} instanceof Map)) return INVALID;`);
14455
+ generateSizeGate(doc, schema, `${accessor}.size`);
14408
14456
  const outputVar = newVar(ctx);
14409
14457
  const kVar = newVar(ctx);
14410
14458
  const valVar = newVar(ctx);
@@ -14421,6 +14469,7 @@ function generateMapCheck(doc, ctx, schema, accessor) {
14421
14469
  function generateSetCheck(doc, ctx, schema, accessor) {
14422
14470
  const def = schema._zod.def;
14423
14471
  doc.write(`if (!(${accessor} instanceof Set)) return INVALID;`);
14472
+ generateSizeGate(doc, schema, `${accessor}.size`);
14424
14473
  const outputVar = newVar(ctx);
14425
14474
  const valVar = newVar(ctx);
14426
14475
  doc.write(`const ${outputVar} = new Set();`);
@@ -20542,10 +20591,10 @@ var init_v4 = __esm({
20542
20591
  }
20543
20592
  });
20544
20593
 
20545
- // node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs
20594
+ // node_modules/@modelcontextprotocol/server/node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs
20546
20595
  var LATEST_PROTOCOL_VERSION, SUPPORTED_PROTOCOL_VERSIONS, RELATED_TASK_META_KEY, PROTOCOL_VERSION_META_KEY, CLIENT_INFO_META_KEY, SERVER_INFO_META_KEY, CLIENT_CAPABILITIES_META_KEY, SUBSCRIPTION_ID_META_KEY, LOG_LEVEL_META_KEY, JSONRPC_VERSION, JSONValueSchema, JSONObjectSchema, JSONArraySchema, ProgressTokenSchema, CursorSchema, TaskMetadataSchema, RelatedTaskMetadataSchema, RequestMetaSchema, BaseRequestParamsSchema, TaskAugmentedRequestParamsSchema, RequestSchema, NotificationsParamsSchema, NotificationSchema, ResultMetaObjectSchema, ResultSchema, RequestIdSchema, JSONRPCRequestSchema, JSONRPCNotificationSchema, JSONRPCResultResponseSchema, JSONRPCErrorResponseSchema, JSONRPCMessageSchema, JSONRPCResponseSchema, EmptyResultSchema, CancelledNotificationParamsSchema, CancelledNotificationSchema, IconSchema, IconsSchema, BaseMetadataSchema, ImplementationSchema, FormElicitationCapabilitySchema, ElicitationCapabilitySchema, ClientTasksCapabilitySchema, ServerTasksCapabilitySchema, ClientCapabilitiesSchema, InitializeRequestParamsSchema, InitializeRequestSchema, ServerCapabilitiesSchema, InitializeResultSchema, InitializedNotificationSchema, DiscoverRequestSchema, DiscoverResultSchema, PingRequestSchema, ProgressSchema, ProgressNotificationParamsSchema, ProgressNotificationSchema, PaginatedRequestParamsSchema, PaginatedRequestSchema, PaginatedResultSchema, ResourceContentsSchema, TextResourceContentsSchema, Base64Schema, BlobResourceContentsSchema, RoleSchema, AnnotationsSchema, ResourceSchema, ResourceTemplateSchema, ListResourcesRequestSchema, ListResourcesResultSchema, ListResourceTemplatesRequestSchema, ListResourceTemplatesResultSchema, ResourceRequestParamsSchema, ReadResourceRequestParamsSchema, ReadResourceRequestSchema, ReadResourceResultSchema, ResourceListChangedNotificationSchema, SubscribeRequestParamsSchema, SubscribeRequestSchema, UnsubscribeRequestParamsSchema, UnsubscribeRequestSchema, SubscriptionFilterSchema, SubscriptionsListenRequestParamsSchema, SubscriptionsListenRequestSchema, SubscriptionsAcknowledgedNotificationParamsSchema, SubscriptionsAcknowledgedNotificationSchema, SubscriptionsListenResultMetaSchema, SubscriptionsListenResultSchema, ResourceUpdatedNotificationParamsSchema, ResourceUpdatedNotificationSchema, PromptArgumentSchema, PromptSchema, ListPromptsRequestSchema, ListPromptsResultSchema, GetPromptRequestParamsSchema, GetPromptRequestSchema, TextContentSchema, ImageContentSchema, AudioContentSchema, ToolUseContentSchema, EmbeddedResourceSchema, ResourceLinkSchema, ContentBlockSchema, PromptMessageSchema, GetPromptResultSchema, PromptListChangedNotificationSchema, ToolAnnotationsSchema, ToolExecutionSchema, ToolSchema, ListToolsRequestSchema, ListToolsResultSchema, CallToolResultSchema, CompatibilityCallToolResultSchema, CallToolRequestParamsSchema, CallToolRequestSchema, ToolListChangedNotificationSchema, ListChangedOptionsBaseSchema, LoggingLevelSchema, SetLevelRequestParamsSchema, SetLevelRequestSchema, LoggingMessageNotificationParamsSchema, LoggingMessageNotificationSchema, ModelHintSchema, ModelPreferencesSchema, ToolChoiceSchema, ToolResultContentSchema, SamplingContentSchema, SamplingMessageContentBlockSchema, SamplingMessageSchema, CreateMessageRequestParamsSchema, CreateMessageRequestSchema, CreateMessageResultSchema, CreateMessageResultWithToolsSchema, BooleanSchemaSchema, StringSchemaSchema, NumberSchemaSchema, UntitledSingleSelectEnumSchemaSchema, TitledSingleSelectEnumSchemaSchema, LegacyTitledEnumSchemaSchema, SingleSelectEnumSchemaSchema, UntitledMultiSelectEnumSchemaSchema, TitledMultiSelectEnumSchemaSchema, MultiSelectEnumSchemaSchema, EnumSchemaSchema, PrimitiveSchemaDefinitionSchema, ElicitRequestFormParamsSchema, ElicitRequestURLParamsSchema, ElicitRequestParamsSchema, ElicitRequestSchema, ElicitationCompleteNotificationParamsSchema, ElicitationCompleteNotificationSchema, ElicitResultSchema, ResourceTemplateReferenceSchema, PromptReferenceSchema, CompleteRequestParamsSchema, CompleteRequestSchema, CompleteResultSchema, RootSchema, ListRootsRequestSchema, ListRootsResultSchema, RootsListChangedNotificationSchema, TaskCreationParamsSchema, TaskStatusSchema, TaskSchema, CreateTaskResultSchema, TaskStatusNotificationParamsSchema, TaskStatusNotificationSchema, GetTaskRequestSchema, GetTaskResultSchema, GetTaskPayloadRequestSchema, GetTaskPayloadResultSchema, ListTasksRequestSchema, ListTasksResultSchema, CancelTaskRequestSchema, CancelTaskResultSchema, ClientRequestSchema, ClientNotificationSchema, ClientResultSchema, ServerRequestSchema, ServerNotificationSchema, ServerResultSchema, SafeUrlSchema, OAuthProtectedResourceMetadataSchema, OAuthMetadataSchema, OpenIdProviderMetadataSchema, OpenIdProviderDiscoveryMetadataSchema, OAuthTokensSchema, IdJagTokenExchangeResponseSchema, OAuthErrorResponseSchema, OptionalSafeUrlSchema, OAuthClientMetadataSchema, OAuthClientInformationSchema, OAuthClientInformationFullSchema, OAuthClientRegistrationErrorSchema, OAuthTokenRevocationRequestSchema;
20547
20596
  var init_auth_BNDyLTqp = __esm({
20548
- "node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs"() {
20597
+ "node_modules/@modelcontextprotocol/server/node_modules/@modelcontextprotocol/core/dist/auth-BNDyLTqp.mjs"() {
20549
20598
  init_v4();
20550
20599
  LATEST_PROTOCOL_VERSION = "2025-11-25";
20551
20600
  SUPPORTED_PROTOCOL_VERSIONS = [
@@ -21489,9 +21538,9 @@ var init_auth_BNDyLTqp = __esm({
21489
21538
  }
21490
21539
  });
21491
21540
 
21492
- // node_modules/@modelcontextprotocol/core/dist/internal.mjs
21541
+ // node_modules/@modelcontextprotocol/server/node_modules/@modelcontextprotocol/core/dist/internal.mjs
21493
21542
  var init_internal = __esm({
21494
- "node_modules/@modelcontextprotocol/core/dist/internal.mjs"() {
21543
+ "node_modules/@modelcontextprotocol/server/node_modules/@modelcontextprotocol/core/dist/internal.mjs"() {
21495
21544
  init_auth_BNDyLTqp();
21496
21545
  }
21497
21546
  });
@@ -35442,7 +35491,7 @@ var init_errors3 = __esm({
35442
35491
  // webhook signing secret (Stripe-style)
35443
35492
  ].map((p) => `\\b${p}`).join("|"), "g");
35444
35493
  GOOGLE_OAUTH_TOKEN_RE = /(?<![A-Za-z0-9+/])(?:ya29\.|1\/\/)[A-Za-z0-9._-]{8,}/g;
35445
- QUERY_SECRET_RE = new RegExp(`([?&](?:(?:access|refresh|id|auth|session|csrf|xsrf)[_-]?token|client[_-]?secret|api[_-]?secret|api[_-]?key|password|passwd|signature|token|key|sig|(?:code[_-]?)?verifier|(?:php|j)?sess(?:ion)?[_-]?id|sid|x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN})=)[^&#\\s"'<>\`]+`, "gi");
35494
+ QUERY_SECRET_RE = new RegExp(`([?&#;](?:(?:access|refresh|id|auth|session|csrf|xsrf|api)[_-]?token|client[_-]?secret|api[_-]?secret|api[_-]?key|password|passwd|signature|secret|token|auth|key|sig|(?:code[_-]?)?verifier|(?:php|j)?sess(?:ion)?[_-]?id|sid|x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN})=)[^&#\\s"'<>\`]+`, "gi");
35446
35495
  OAUTH_CODE_RE = /([?&]code=)(?=[^&#\s"'<>`]{16,})[^&#\s"'<>`]+/gi;
35447
35496
  FORM_PASSWORD_RE = /((?:^|[\s,;:"'(\[{])(?:password|passwd)=)[^&#\s"'<>`]+/gim;
35448
35497
  HEADER_SECRET_RE = new RegExp(`(\\b(?:x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN}|api[-_]?key)\\s*:\\s*)[^\\s,;"'<>\`]+`, "gi");
@@ -35453,6 +35502,8 @@ var init_errors3 = __esm({
35453
35502
  "api[_-]?secret",
35454
35503
  "(?:x[_-])?api[_-]?key",
35455
35504
  "private[_-]?key",
35505
+ "aws[_-]?secret[_-]?access[_-]?key",
35506
+ // fleet-audit#1297
35456
35507
  "code[_-]?verifier",
35457
35508
  // PKCE; a bare `verifier` key is too generic for JSON
35458
35509
  `x[_-]${HEADER_NAME_RUN}?(?:api[_-]?key|token|secret|auth)${HEADER_NAME_RUN}`,
@@ -36552,12 +36603,24 @@ var init_fs = __esm({
36552
36603
  });
36553
36604
 
36554
36605
  // node_modules/@chrischall/mcp-utils/dist/internal/headers.js
36606
+ function responseHeader(res, name) {
36607
+ return getHeader(res?.headers, name);
36608
+ }
36609
+ function getHeader(headers, name) {
36610
+ if (!headers || typeof headers.get !== "function")
36611
+ return null;
36612
+ const value = headers.get.call(headers, name);
36613
+ return typeof value === "string" ? value : null;
36614
+ }
36555
36615
  var init_headers = __esm({
36556
36616
  "node_modules/@chrischall/mcp-utils/dist/internal/headers.js"() {
36557
36617
  }
36558
36618
  });
36559
36619
 
36560
36620
  // node_modules/@chrischall/mcp-utils/dist/internal/ascii.js
36621
+ function asciiLower(s) {
36622
+ return s.replace(/[A-Z]+/g, (m) => m.toLowerCase());
36623
+ }
36561
36624
  var init_ascii = __esm({
36562
36625
  "node_modules/@chrischall/mcp-utils/dist/internal/ascii.js"() {
36563
36626
  }
@@ -36569,16 +36632,42 @@ var init_code_point = __esm({
36569
36632
  }
36570
36633
  });
36571
36634
 
36635
+ // node_modules/@chrischall/mcp-utils/dist/internal/tags.js
36636
+ var init_tags = __esm({
36637
+ "node_modules/@chrischall/mcp-utils/dist/internal/tags.js"() {
36638
+ }
36639
+ });
36640
+
36572
36641
  // node_modules/@chrischall/mcp-utils/dist/scrape/index.js
36573
36642
  function isCloudflareChallenge(html) {
36574
- return /_cf_chl_opt/.test(html) || /<title[^>]*>\s*Just a moment/i.test(html);
36643
+ return html.includes("_cf_chl_opt") || hasJustAMomentTitle(html);
36644
+ }
36645
+ function hasJustAMomentTitle(html) {
36646
+ const lower = asciiLower(html);
36647
+ let i = 0;
36648
+ for (; ; ) {
36649
+ const open2 = lower.indexOf("<title", i);
36650
+ if (open2 < 0)
36651
+ return false;
36652
+ const gt = lower.indexOf(">", open2 + 6);
36653
+ if (gt < 0)
36654
+ return false;
36655
+ let j = gt + 1;
36656
+ while (j < lower.length && /\s/.test(lower[j]))
36657
+ j++;
36658
+ if (lower.startsWith(JUST_A_MOMENT, j))
36659
+ return true;
36660
+ i = gt + 1;
36661
+ }
36575
36662
  }
36576
- var NEXT_DATA_MAX_CHARS;
36663
+ var NEXT_DATA_MAX_CHARS, JUST_A_MOMENT;
36577
36664
  var init_scrape = __esm({
36578
36665
  "node_modules/@chrischall/mcp-utils/dist/scrape/index.js"() {
36579
36666
  init_ascii();
36580
36667
  init_code_point();
36668
+ init_tags();
36581
36669
  NEXT_DATA_MAX_CHARS = 16 * 1024 * 1024;
36670
+ JUST_A_MOMENT = "just a moment";
36582
36671
  }
36583
36672
  });
36584
36673
 
@@ -36604,7 +36693,7 @@ var init_net_atoms = __esm({
36604
36693
  // node_modules/@chrischall/mcp-utils/dist/http/body-limit.js
36605
36694
  async function readBytesCapped(res, maxBytes, service, bounded) {
36606
36695
  if (maxBytes !== void 0) {
36607
- const declared = Number(res.headers.get("content-length") ?? NaN);
36696
+ const declared = Number(responseHeader(res, "content-length") ?? NaN);
36608
36697
  if (Number.isFinite(declared) && declared > maxBytes) {
36609
36698
  cancelStream(res.body);
36610
36699
  throw new ResponseTooLargeError(service, maxBytes);
@@ -36649,6 +36738,7 @@ var ResponseTooLargeError;
36649
36738
  var init_body_limit = __esm({
36650
36739
  "node_modules/@chrischall/mcp-utils/dist/http/body-limit.js"() {
36651
36740
  init_errors3();
36741
+ init_headers();
36652
36742
  ResponseTooLargeError = class extends McpToolError {
36653
36743
  maxBytes;
36654
36744
  constructor(service, maxBytes) {
@@ -37080,7 +37170,7 @@ var init_version = __esm({
37080
37170
  "src/version.ts"() {
37081
37171
  "use strict";
37082
37172
  PACKAGE_NAME = "microsoft-teams-mcp";
37083
- VERSION = "0.5.1";
37173
+ VERSION = "0.6.1";
37084
37174
  }
37085
37175
  });
37086
37176
 
@@ -37635,6 +37725,21 @@ var init_public_suffix = __esm({
37635
37725
  }
37636
37726
  });
37637
37727
 
37728
+ // node_modules/@fetchproxy/protocol/dist/ip-literal.js
37729
+ function isIpLiteralHost(host) {
37730
+ if (host.includes(":") || host.startsWith("["))
37731
+ return true;
37732
+ const labels = host.split(".");
37733
+ if (labels.length > 1 && labels[labels.length - 1] === "")
37734
+ labels.pop();
37735
+ const last = labels[labels.length - 1] ?? "";
37736
+ return /^[0-9]+$/.test(last) || /^0x[0-9a-f]*$/i.test(last);
37737
+ }
37738
+ var init_ip_literal = __esm({
37739
+ "node_modules/@fetchproxy/protocol/dist/ip-literal.js"() {
37740
+ }
37741
+ });
37742
+
37638
37743
  // node_modules/@fetchproxy/protocol/dist/validate.js
37639
37744
  function assertObject(x, label) {
37640
37745
  if (typeof x !== "object" || x === null || Array.isArray(x)) {
@@ -38084,6 +38189,9 @@ function validateHello(raw) {
38084
38189
  if (!HOSTNAME_RE.test(d)) {
38085
38190
  throw new ProtocolError3(`hello.domains: invalid hostname ${JSON.stringify(d)}`);
38086
38191
  }
38192
+ if (isIpLiteralHost(d)) {
38193
+ throw new ProtocolError3(`hello.domains: ${JSON.stringify(d)} is an IP address \u2014 declare the site's DNS hostname; IP-literal origins (LAN, loopback, link-local) are not reachable through the bridge`);
38194
+ }
38087
38195
  if (isPublicSuffix(d)) {
38088
38196
  throw new ProtocolError3(`hello.domains: ${JSON.stringify(d)} is a public suffix \u2014 declare a registrable domain (e.g. "example.${d}"), not the suffix every site under it shares`);
38089
38197
  }
@@ -38857,6 +38965,7 @@ var init_validate = __esm({
38857
38965
  init_account_attest();
38858
38966
  init_json_pointer();
38859
38967
  init_public_suffix();
38968
+ init_ip_literal();
38860
38969
  ProtocolError3 = class extends Error {
38861
38970
  constructor(message) {
38862
38971
  super(message);
@@ -39036,6 +39145,7 @@ var init_dist3 = __esm({
39036
39145
  init_seal();
39037
39146
  init_encoding();
39038
39147
  init_public_suffix();
39148
+ init_ip_literal();
39039
39149
  init_json_pointer();
39040
39150
  }
39041
39151
  });
@@ -44006,7 +44116,7 @@ async function startHost(opts) {
44006
44116
  if (ownRetryableRefusal)
44007
44117
  resetSessionPromise();
44008
44118
  resolveOwnSession(ownSession);
44009
- } else {
44119
+ } else if (identified === "extension" && extensionWs === ws) {
44010
44120
  const slot = peers.get(frame.mcpId);
44011
44121
  if (slot)
44012
44122
  slot.ws.send(JSON.stringify(frame));
@@ -45094,6 +45204,9 @@ var init_ws_server = __esm({
45094
45204
  throw new Error("FetchproxyServer: opts.domains must be a non-empty array of hostnames");
45095
45205
  }
45096
45206
  for (const d of opts.domains) {
45207
+ if (typeof d === "string" && isIpLiteralHost(d)) {
45208
+ throw new Error(`FetchproxyServer: opts.domains entry ${JSON.stringify(d)} is an IP address \u2014 declare the site's DNS hostname; IP-literal origins (LAN, loopback, link-local) are not reachable through the bridge`);
45209
+ }
45097
45210
  if (typeof d === "string" && isPublicSuffix(d)) {
45098
45211
  throw new Error(`FetchproxyServer: opts.domains entry ${JSON.stringify(d)} is a public suffix \u2014 declare a registrable domain (e.g. "example.${d}"), not the suffix every site under it shares`);
45099
45212
  }
@@ -47039,8 +47152,10 @@ var init_bulk = __esm({
47039
47152
  });
47040
47153
 
47041
47154
  // node_modules/@fetchproxy/server/dist/bot-wall.js
47155
+ var CLOUDFLARE_TITLE_SCAN_MAX;
47042
47156
  var init_bot_wall = __esm({
47043
47157
  "node_modules/@fetchproxy/server/dist/bot-wall.js"() {
47158
+ CLOUDFLARE_TITLE_SCAN_MAX = 64 * 1024;
47044
47159
  }
47045
47160
  });
47046
47161
 
@@ -48618,6 +48733,11 @@ function localIsoTime(iso, timeZone) {
48618
48733
  const abs = Math.abs(offsetMin);
48619
48734
  return `${pad(get("year"), 4)}-${pad(get("month"))}-${pad(get("day"))}T${pad(get("hour"))}:${pad(get("minute"))}:${pad(get("second"))}.${pad(millis, 3)}${sign2}${pad(Math.floor(abs / 60))}:${pad(abs % 60)}`;
48620
48735
  }
48736
+ function changedMs(m) {
48737
+ const v = Number(m.version);
48738
+ const id = Number(m.id);
48739
+ return Math.max(Number.isFinite(v) ? v : 0, Number.isFinite(id) ? id : 0);
48740
+ }
48621
48741
  function normaliseMessage(m, meMri, opts = {}) {
48622
48742
  const props = m.properties ?? {};
48623
48743
  const mri = senderMri(m.from);
@@ -48734,7 +48854,30 @@ function causeMessage(err) {
48734
48854
  function isFetchFailed(err) {
48735
48855
  return err instanceof TypeError && err.message === "fetch failed";
48736
48856
  }
48737
- function hintFor(code2, host) {
48857
+ function proxyRefusalStatus(err) {
48858
+ for (const e of causes(err)) {
48859
+ if (codeOf(e) === "ERR_PROXY_TUNNEL") {
48860
+ const m = /\b(\d{3})\b/.exec(e instanceof Error ? e.message : "");
48861
+ return m ? Number(m[1]) : "unknown";
48862
+ }
48863
+ if (e instanceof Error) {
48864
+ const m = /^Proxy response \((\d{3})\) !== 200 when HTTP Tunneling/.exec(e.message);
48865
+ if (m) return Number(m[1]);
48866
+ }
48867
+ }
48868
+ return void 0;
48869
+ }
48870
+ function proxyRefusalHint(status, host) {
48871
+ if (status !== 403 && status !== 407 && status !== "unknown") return void 0;
48872
+ return `The outbound proxy this server runs behind refused the connection to ${host}: its egress policy does not allow that host. On a hosted (mcp-host) registration, the host must be on the registration's egress allow-list \u2014 the owner accepts the manifest's egress proposal (or adds the host) on the registration, then retries. Elsewhere, ask whoever runs the proxy to allow it.`;
48873
+ }
48874
+ function hintFor(code2, host, err) {
48875
+ const refused = proxyRefusalStatus(err);
48876
+ if (refused !== void 0) {
48877
+ const policy = proxyRefusalHint(refused, host);
48878
+ if (policy !== void 0) return policy;
48879
+ return `The outbound proxy this server runs behind could not open a connection to ${host} (it answered ${refused}). Retry; if it persists, check the proxy can reach the host.`;
48880
+ }
48738
48881
  if (code2 !== void 0 && DNS_CODES.has(code2)) {
48739
48882
  return `This machine could not resolve ${host}. Check DNS and VPN: a split-tunnel VPN that resolves teams.cloud.microsoft but not the regional *.asm.skype.com and *.sharepoint.com hosts fails exactly like this. \`nslookup ${host}\` on the machine running this server tells you which.`;
48740
48883
  }
@@ -48759,7 +48902,7 @@ function describeTransportFailure(err, url2, service) {
48759
48902
  const why = detail.length > 0 ? ` (${[...new Set(detail)].join(": ")})` : "";
48760
48903
  return new McpToolError(`Could not reach ${service} at ${host}${why}.`, {
48761
48904
  kind: "transport",
48762
- hint: hintFor(code2, host),
48905
+ hint: hintFor(code2, host, err),
48763
48906
  cause: err
48764
48907
  });
48765
48908
  }
@@ -48925,16 +49068,17 @@ var ChatServiceClient = class {
48925
49068
  }
48926
49069
  /**
48927
49070
  * A conversation's messages, newest first, paging back until `stopAt`
48928
- * accepts a message, `max` are collected, the pages run out, or 20 pages
48929
- * have been read.
49071
+ * accepts a message, `max` are collected, the pages run out, or `maxPages`
49072
+ * (default 20) have been read.
48930
49073
  */
48931
49074
  async getMessages(id, opts) {
48932
49075
  this.#requireConfigured();
48933
49076
  const out = [];
48934
49077
  if (!(opts.max > 0)) return out;
49078
+ const seen = /* @__PURE__ */ new Set();
48935
49079
  let url2 = `${this.#baseUrl}/users/ME/conversations/${encodeURIComponent(id)}/messages?view=msnp24Equivalent|supportsMessageProperties&pageSize=${opts.pageSize ?? DEFAULT_MESSAGE_PAGE_SIZE}&startTime=1`;
48936
49080
  for (let page = 0; url2 !== void 0; page++) {
48937
- if (page >= MAX_MESSAGE_PAGES) {
49081
+ if (page >= (opts.maxPages ?? MAX_MESSAGE_PAGES)) {
48938
49082
  opts.onCapped?.();
48939
49083
  break;
48940
49084
  }
@@ -48943,6 +49087,8 @@ var ChatServiceClient = class {
48943
49087
  if (msgs.length === 0) break;
48944
49088
  let stopped = false;
48945
49089
  for (const m of msgs) {
49090
+ if (seen.has(m.id)) continue;
49091
+ seen.add(m.id);
48946
49092
  if (opts.stopAt?.(m)) {
48947
49093
  stopped = true;
48948
49094
  continue;
@@ -50440,6 +50586,10 @@ function compactMessage(m) {
50440
50586
  ...m.subject !== void 0 ? { subject: m.subject } : {}
50441
50587
  };
50442
50588
  }
50589
+ function formatFlatMessage(m, format) {
50590
+ if (format === "full") return m;
50591
+ return { ...compactMessage(m), ...m.replyTo !== void 0 ? { replyTo: m.replyTo } : {} };
50592
+ }
50443
50593
  var isMissing = (root) => "missing" in root;
50444
50594
  var isOutside = (root) => "outside_window" in root;
50445
50595
  function newestTime(messages) {
@@ -50493,6 +50643,85 @@ function formatBody(kind, messages, format, roots = NO_ROOTS) {
50493
50643
  return channel ? { threads: groupThreads(messages, roots) } : { messages: [...messages] };
50494
50644
  }
50495
50645
 
50646
+ // src/tools/from.ts
50647
+ init_zod();
50648
+ init_dist2();
50649
+ var FROM_MAX_RAW = 2e4;
50650
+ var FROM_MAX_PAGES = 100;
50651
+ var fromArg = external_exports.string().min(1).optional().describe(
50652
+ "Page oldest first from here: a UTC time (ISO 8601, e.g. 2026-10-01T00:00:00Z; one with no zone is read as UTC) or a previous result's next_from, unchanged. Returns messages that arrived at or after it, oldest first, up to limit, with next_from (pass it back as from for the next page \u2014 also once has_more is false, to pick up what arrives later) and has_more."
50653
+ );
50654
+ var FROM_DESCRIPTION = `from pages oldest first for ingestion and backfill: messages that arrived at or after a UTC time (or a previous result's next_from), oldest first, at most limit; next_from (always returned, with next_from_time) resumes after the last message returned and has_more says whether more are already waiting. Pass an old from and keep passing next_from to backfill; once has_more is false the same next_from picks up what arrives later. Delivery is at-least-once: dedupe on message id. Teams pages newest first, so a from call reads everything since from (up to ${FROM_MAX_RAW} raw messages per conversation, past which it never skips silently: it says what it could not read): the further back from is, the slower the call. `;
50655
+ function badFrom(from) {
50656
+ return new McpToolError(`"${from}" is not a from position.`, {
50657
+ hint: "Pass a UTC time such as 2026-10-01T00:00:00Z, or a previous result's next_from unchanged."
50658
+ });
50659
+ }
50660
+ function decodeFrom(from) {
50661
+ if (/^[A-Za-z0-9_-]+$/.test(from)) {
50662
+ let parsed;
50663
+ try {
50664
+ parsed = JSON.parse(Buffer.from(from, "base64url").toString("utf8"));
50665
+ } catch {
50666
+ parsed = void 0;
50667
+ }
50668
+ if (parsed !== void 0) {
50669
+ const { t: t2, s } = parsed ?? {};
50670
+ const seen = s === void 0 ? [] : s;
50671
+ if (typeof t2 === "number" && Number.isFinite(t2) && t2 >= 0 && Array.isArray(seen) && seen.every((k) => typeof k === "string")) {
50672
+ return { t: t2, seen };
50673
+ }
50674
+ throw badFrom(from);
50675
+ }
50676
+ }
50677
+ if (!/^\d{4}-\d{2}-\d{2}/.test(from)) throw badFrom(from);
50678
+ const zoned = /T\d{2}:\d{2}(:\d{2}(\.\d+)?)?$/.test(from) ? `${from}Z` : from;
50679
+ const t = Date.parse(zoned);
50680
+ if (Number.isNaN(t)) throw badFrom(from);
50681
+ return { t, seen: [] };
50682
+ }
50683
+ function encodeFrom({ t, seen }) {
50684
+ return Buffer.from(JSON.stringify(seen.length > 0 ? { t, s: seen } : { t }), "utf8").toString("base64url");
50685
+ }
50686
+ function takePage(items, pos, limit, ceiling) {
50687
+ const seen = new Set(pos.seen);
50688
+ const pending = items.filter((i) => i.ms > pos.t || i.ms === pos.t && !seen.has(i.key)).sort((a, b) => a.ms - b.ms || (a.key < b.key ? -1 : a.key > b.key ? 1 : 0));
50689
+ const page = pending.slice(0, limit);
50690
+ const last = page.at(-1);
50691
+ let next = pos;
50692
+ if (last !== void 0) {
50693
+ const t = Math.max(pos.t, ceiling !== void 0 ? Math.min(last.ms, ceiling) : last.ms);
50694
+ const atT = page.filter((i) => i.ms === t).map((i) => i.key);
50695
+ next = { t, seen: t === pos.t ? [...pos.seen, ...atT] : atT };
50696
+ }
50697
+ return { page: page.map((i) => i.item), has_more: pending.length > page.length, remaining: pending.length - page.length, next };
50698
+ }
50699
+ function fromReport(pos, next, hasMore) {
50700
+ return {
50701
+ from_time: new Date(pos.t).toISOString(),
50702
+ has_more: hasMore,
50703
+ next_from: encodeFrom(next),
50704
+ next_from_time: new Date(next.t).toISOString()
50705
+ };
50706
+ }
50707
+ async function readFrom(chatsvc, id, boundary) {
50708
+ let capped = false;
50709
+ const messages = await chatsvc.getMessages(id, {
50710
+ stopAt: (m) => changedMs(m) < boundary,
50711
+ max: FROM_MAX_RAW,
50712
+ maxPages: FROM_MAX_PAGES,
50713
+ onCapped: () => capped = true
50714
+ });
50715
+ if (!capped) return { messages };
50716
+ return { messages, reachedMs: Math.min(...messages.map(changedMs)) };
50717
+ }
50718
+ function tooBusy(boundary, reachedMs) {
50719
+ return {
50720
+ error: `More than ${FROM_MAX_RAW} messages changed in this conversation since ${new Date(boundary).toISOString()}: a read reached back only to ${new Date(reachedMs).toISOString()}, as Teams pages newest first.`,
50721
+ hint: "Pass a later from."
50722
+ };
50723
+ }
50724
+
50496
50725
  // src/tools/roots.ts
50497
50726
  init_dist2();
50498
50727
  var MAX_ROOT_FETCHES = 25;
@@ -50960,7 +51189,37 @@ async function resolveListed(chatsvc, raw, me, conversation, verb) {
50960
51189
  }
50961
51190
  var MAX_CONVERSATIONS = 20;
50962
51191
  var READ_CONCURRENCY = 4;
50963
- async function readOne(chatsvc, raw, me, summary, { unreadOnly, since, afterMessageId, limit, timeZone, format, roots }) {
51192
+ async function readOneFrom(chatsvc, raw, me, summary, pos, { unreadOnly, limit, timeZone, format, roots }) {
51193
+ const conv = raw.find((c) => c.id === summary.id) ?? { id: summary.id };
51194
+ const horizon = readHorizon(conv);
51195
+ const wanted = (m) => isUserMessage(m) && (!unreadOnly || isUnread(m, horizon, me));
51196
+ const boundary = unreadOnly ? Math.max(pos.t, horizon + 1) : pos.t;
51197
+ const { messages: fetched, reachedMs } = await readFrom(chatsvc, summary.id, boundary);
51198
+ if (reachedMs !== void 0) {
51199
+ const { error: error62, hint } = tooBusy(boundary, reachedMs);
51200
+ throw new McpToolError(error62, { hint });
51201
+ }
51202
+ const { page, has_more, next } = takePage(
51203
+ fetched.filter(wanted).map((m) => ({ ms: arrivalMs(m), key: m.id, item: m })),
51204
+ pos,
51205
+ limit
51206
+ );
51207
+ const messages = page.map((m) => normaliseMessage(m, me, { timeZone }));
51208
+ const outsideRoots = summary.kind === "channel" ? await fetchOutsideRoots(chatsvc, summary.id, messages, me, { budget: roots, timeZone }) : void 0;
51209
+ return {
51210
+ summary,
51211
+ conv,
51212
+ newest: newestId(page),
51213
+ result: {
51214
+ conversation: formatConversation(summary, format),
51215
+ ...formatBody(summary.kind, messages, format, outsideRoots),
51216
+ ...fromReport(pos, next, has_more)
51217
+ }
51218
+ };
51219
+ }
51220
+ async function readOne(chatsvc, raw, me, summary, opts) {
51221
+ if (opts.from !== void 0) return readOneFrom(chatsvc, raw, me, summary, opts.from, opts);
51222
+ const { unreadOnly, since, afterMessageId, limit, timeZone, format, roots } = opts;
50964
51223
  const conv = raw.find((c) => c.id === summary.id) ?? { id: summary.id };
50965
51224
  const horizon = readHorizon(conv);
50966
51225
  const cutoff = since !== void 0 ? Date.parse(since) : void 0;
@@ -51069,7 +51328,7 @@ function registerConversationTools(server, { chatsvc }) {
51069
51328
  "teams_read_conversation",
51070
51329
  {
51071
51330
  title: "Read a Teams chat or channel",
51072
- description: `Read the messages of any chat or channel the signed-in user is in, by id (from teams_list_chats / teams_list_teams_and_channels) or by name, without opening it in Teams. "48:notes" (or the name "notes" / "self") is the user's own notes self-chat. Messages come oldest first, each with id, time (UTC, ISO 8601), sender, fromMe, text (never truncated; table cells separated by " | "), subject, edited/deleted flags and attachments; a channel is returned as threads, each root post with its replies. A root older than the window is fetched and marked outside_window: true (it is context, not counted or cursored); up to ${MAX_ROOT_FETCHES} roots are fetched per call, and any beyond that or that cannot be fetched is { id, missing: true }. unread_only returns just the messages the user has not read; since stops at a time; limit keeps the newest (truncated says when more exist; unread_count_scope "window" says unread_count only covers what limit/since/after_message_id let through). after_message_id returns only messages newer than that id; next_cursor is the newest returned message id (or after_message_id when nothing is new) \u2014 pass it back as after_message_id to read only what arrived since. after_message_id takes message-id cursors only: to read what teams_get_changes counted, pass that row's after_message_id, never teams_get_changes' next_cursor (a time token for teams_get_changes). ` + CURSOR_NO_CACHE_DESCRIPTION + FORMAT_DESCRIPTION + `conversation may also be an array of up to ${MAX_CONVERSATIONS} ids/names: the result is then { conversations: [...], errors, fetched_at }, one single-read result per conversation (the other arguments apply to each); an ambiguous name takes its place among them as the same { ambiguous: true, ... } object a single read returns, and one that cannot be resolved or read is listed in errors while the rest still come back. ` + MARK_READ_DESCRIPTION + "With mark_read the read marker of each conversation read moves up to the newest message returned (never backwards; outside_window roots do not count) and its result says marked_read; one whose limit or since cut off unread messages older than those returned is not marked (marked_read: { skipped, hint }), while a limit that cut only already-read messages does not stop it; the user confirms first \u2014 a prompt where the client supports one, otherwise the first call returns only a preview and a confirmToken, and the repeat call with it reads and marks. " + CONFIRM_INJECTION_RULE + " Attachments are listed per message (images by ref, files by name) and fetched with teams_get_attachment. A name that matches several conversations is not an error: the result is {ambiguous: true, query, match_count, candidates (up to 10, each with id, title, kind, team, lastActivity and match_reason), hint} and no messages \u2014 read again with one candidate's id. " + TIME_ZONE_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
51331
+ description: `Read the messages of any chat or channel the signed-in user is in, by id (from teams_list_chats / teams_list_teams_and_channels) or by name, without opening it in Teams. "48:notes" (or the name "notes" / "self") is the user's own notes self-chat. Messages come oldest first, each with id, time (UTC, ISO 8601), sender, fromMe, text (never truncated; table cells separated by " | "), subject, edited/deleted flags and attachments; a channel is returned as threads, each root post with its replies. A root older than the window is fetched and marked outside_window: true (it is context, not counted or cursored); up to ${MAX_ROOT_FETCHES} roots are fetched per call, and any beyond that or that cannot be fetched is { id, missing: true }. unread_only returns just the messages the user has not read; since stops at a time; limit keeps the newest (truncated says when more exist; unread_count_scope "window" says unread_count only covers what limit/since/after_message_id let through). after_message_id returns only messages newer than that id; next_cursor is the newest returned message id (or after_message_id when nothing is new) \u2014 pass it back as after_message_id to read only what arrived since. after_message_id takes message-id cursors only: to read what teams_get_changes counted, pass that row's after_message_id, never teams_get_changes' next_cursor (a time token for teams_get_changes). ` + CURSOR_NO_CACHE_DESCRIPTION + FORMAT_DESCRIPTION + `conversation may also be an array of up to ${MAX_CONVERSATIONS} ids/names: the result is then { conversations: [...], errors, fetched_at }, one single-read result per conversation (the other arguments apply to each); an ambiguous name takes its place among them as the same { ambiguous: true, ... } object a single read returns, and one that cannot be resolved or read is listed in errors while the rest still come back. ` + FROM_DESCRIPTION + "With from, limit keeps the OLDEST messages, unread_only pages only unread ones, and since, after_message_id and mark_read cannot be used; the result carries from_time, has_more, next_from and next_from_time in place of unread_count and next_cursor. " + MARK_READ_DESCRIPTION + "With mark_read the read marker of each conversation read moves up to the newest message returned (never backwards; outside_window roots do not count) and its result says marked_read; one whose limit or since cut off unread messages older than those returned is not marked (marked_read: { skipped, hint }), while a limit that cut only already-read messages does not stop it; the user confirms first \u2014 a prompt where the client supports one, otherwise the first call returns only a preview and a confirmToken, and the repeat call with it reads and marks. " + CONFIRM_INJECTION_RULE + " Attachments are listed per message (images by ref, files by name) and fetched with teams_get_attachment. A name that matches several conversations is not an error: the result is {ambiguous: true, query, match_count, candidates (up to 10, each with id, title, kind, team, lastActivity and match_reason), hint} and no messages \u2014 read again with one candidate's id. " + TIME_ZONE_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
51073
51332
  // A write only with mark_read, but a write: it moves the user's read marker (never backwards, so a repeat is a no-op).
51074
51333
  annotations: toolAnnotations({ readOnly: false, destructive: false, idempotent: true, openWorld: true }),
51075
51334
  inputSchema: {
@@ -51079,20 +51338,30 @@ function registerConversationTools(server, { chatsvc }) {
51079
51338
  unread_only: external_exports.boolean().optional().describe("Only return messages the user has not read yet (default false). Does not mark them read unless mark_read is set."),
51080
51339
  since: sinceArg,
51081
51340
  after_message_id: afterMessageIdArg,
51082
- limit: limitArg(MAX_MESSAGES, "messages"),
51341
+ from: fromArg,
51342
+ limit: limitArg(MAX_MESSAGES, "messages", "newest first kept; with from, oldest first kept"),
51083
51343
  tz: tzArg,
51084
51344
  format: formatArg,
51085
51345
  mark_read: markReadArg,
51086
51346
  confirmToken: confirmTokenParam
51087
51347
  }
51088
51348
  },
51089
- async ({ conversation, unread_only, since, after_message_id, limit, tz, format, mark_read, confirmToken }, ctx) => {
51349
+ async ({ conversation, unread_only, since, after_message_id, from, limit, tz, format, mark_read, confirmToken }, ctx) => {
51090
51350
  try {
51091
51351
  assertMarkReadFormat(mark_read, format);
51352
+ if (from !== void 0) {
51353
+ const clash = since !== void 0 ? "since" : after_message_id !== void 0 ? "after_message_id" : mark_read ? "mark_read" : void 0;
51354
+ if (clash !== void 0) {
51355
+ throw new McpToolError(`from cannot be combined with ${clash}.`, {
51356
+ hint: "from is its own position: pass a previous next_from to go on. To mark what was paged read, use teams_mark_read."
51357
+ });
51358
+ }
51359
+ }
51092
51360
  const opts = {
51093
51361
  unreadOnly: unread_only ?? false,
51094
51362
  since,
51095
51363
  afterMessageId: after_message_id,
51364
+ from: from !== void 0 ? decodeFrom(from) : void 0,
51096
51365
  limit: limit ?? DEFAULT_LIMIT,
51097
51366
  timeZone: resolveTimeZone(tz),
51098
51367
  format: format ?? "full",
@@ -51147,6 +51416,7 @@ var MAX_PER_CONVERSATION = 200;
51147
51416
  var DEFAULT_PER_CONVERSATION = 50;
51148
51417
  var MAX_CONVERSATIONS2 = 50;
51149
51418
  var DEFAULT_CONVERSATIONS = 20;
51419
+ var MAX_FROM_MESSAGES = 500;
51150
51420
  var MAX_RAW_MESSAGES2 = 4e3;
51151
51421
  var ROOT_CONVERSATION_CONCURRENCY = 4;
51152
51422
  var KIND_FILTERS = {
@@ -51162,12 +51432,77 @@ var TRUNCATED_SKIP = {
51162
51432
  function byLastActivityDesc2(a, b) {
51163
51433
  return (b.lastActivity ?? "").localeCompare(a.lastActivity ?? "");
51164
51434
  }
51435
+ async function unreadFrom(chatsvc, raw, me, candidates, pos, { limit, timeZone, format }) {
51436
+ const byId = new Map(raw.map((c) => [c.id, c]));
51437
+ const toRead = candidates.filter((s) => (lastChangeMs(byId.get(s.id) ?? { id: s.id }) ?? Infinity) >= pos.t);
51438
+ const results = await mapWithConcurrency(toRead, CONFIRM_CONCURRENCY, async (summary) => {
51439
+ const horizon = readHorizon(byId.get(summary.id) ?? { id: summary.id });
51440
+ try {
51441
+ const boundary = Math.max(pos.t, horizon + 1);
51442
+ const { messages, reachedMs } = await readFrom(chatsvc, summary.id, boundary);
51443
+ const known = (m) => reachedMs === void 0 || arrivalMs(m) > reachedMs;
51444
+ return { kind: "read", messages: messages.filter((m) => isUnread(m, horizon, me) && known(m)), boundary, reachedMs };
51445
+ } catch (error62) {
51446
+ return isUnreachable(error62) ? { kind: "unreachable" } : { kind: "failed", error: error62 };
51447
+ }
51448
+ });
51449
+ let skippedUnreachable = 0;
51450
+ let anyRead = false;
51451
+ const items = [];
51452
+ const failed = [];
51453
+ const tooDeep = [];
51454
+ results.forEach((r, i) => {
51455
+ const summary = toRead[i];
51456
+ if (r.kind === "unreachable") skippedUnreachable++;
51457
+ else if (r.kind === "failed") failed.push({ summary, error: r.error });
51458
+ else {
51459
+ anyRead = true;
51460
+ if (r.reachedMs !== void 0) tooDeep.push({ summary, boundary: r.boundary, reachedMs: r.reachedMs });
51461
+ for (const m of r.messages) items.push({ ms: arrivalMs(m), key: `${summary.id}/${m.id}`, item: { summary, m } });
51462
+ }
51463
+ });
51464
+ if (failed.length > 0 && !anyRead) throw failed[0].error;
51465
+ const listed = Math.max(pos.t, ...raw.map((c) => lastChangeMs(c) ?? 0));
51466
+ const { page, has_more, remaining, next } = takePage(items, pos, limit, failed.length > 0 ? pos.t : listed);
51467
+ const shown = [...new Map(page.map(({ summary }) => [summary.id, summary])).values()];
51468
+ const titled = await enrichTitles(chatsvc, raw, me, [
51469
+ ...shown,
51470
+ ...failed.map((f) => f.summary),
51471
+ ...tooDeep.map((d) => d.summary)
51472
+ ]);
51473
+ const titledDeep = titled.slice(shown.length + failed.length);
51474
+ return {
51475
+ total_unread: page.length + remaining,
51476
+ messages: page.map(({ summary, m }) => ({
51477
+ conversation_id: summary.id,
51478
+ ...formatFlatMessage(normaliseMessage(m, me, { timeZone }), format)
51479
+ })),
51480
+ conversations: titled.slice(0, shown.length).map((s) => formatConversation(confirmedSummary(s, true), format)),
51481
+ ...fromReport(pos, next, has_more),
51482
+ skipped_unreachable: skippedUnreachable,
51483
+ ...failed.length > 0 ? {
51484
+ errors: failed.map((f, i) => ({
51485
+ conversation: titled[shown.length + i],
51486
+ error: wrapApiError(f.error, "read this conversation").message
51487
+ }))
51488
+ } : {},
51489
+ ...tooDeep.length > 0 ? {
51490
+ incomplete: tooDeep.map((d, i) => ({
51491
+ conversation: titledDeep[i],
51492
+ unread_not_read_from: new Date(d.boundary).toISOString(),
51493
+ unread_not_read_until: new Date(d.reachedMs).toISOString(),
51494
+ ...tooBusy(d.boundary, d.reachedMs)
51495
+ }))
51496
+ } : {}
51497
+ };
51498
+ }
51499
+ var NOT_WITH_FROM = ["since_days", "cursors", "per_conversation_limit", "max_conversations", "mark_read", "older_unread"];
51165
51500
  function registerUnreadTools(server, { chatsvc }) {
51166
51501
  server.registerTool(
51167
51502
  "teams_get_unread",
51168
51503
  {
51169
51504
  title: "Get unread Teams messages",
51170
- description: `Get every unread message across all the chats and channels the signed-in user is in (or those matching kinds / query), grouped by conversation, most recent activity first. Each conversation comes with its summary (id, kind, title, team) and only the messages the user has not read, oldest first; a channel's are grouped as threads under their root post. A root the user already read is fetched and marked outside_window: true (it is context, not unread or counted); up to ${MAX_ROOT_FETCHES} roots are fetched per call, and any beyond that or that cannot be fetched is { id, missing: true }. Exact, as in Teams: every conversation with activity past its read marker (or never opened) is read past the marker and kept only if it holds a real message from someone else, so a call recording, transcript or other system event never makes a conversation unread. Channels the user has hidden in Teams are left out (include_hidden adds them); one that is gone or no longer readable (404/403) is skipped and counted in skipped_unreachable. Only conversations whose newest unread message is from the last 14 days are returned by default (since_days widens or narrows it); older unread conversations \u2014 typically dormant channels \u2014 are not read past their marker and are counted in older_unread_skipped; older_unread: true also lists them in older_unread_conversations (id, kind, title, team, lastActivity, and unread_count only for those already read \u2014 unread_count_known: false otherwise). Chats the user muted in Teams (muted: true) are left out too and counted in muted_skipped, without being read; include_muted adds them. Unread conversations past max_conversations are listed by id, title and unread_count in more_unread_conversations; read one with teams_read_conversation. A conversation that could not be read is listed in errors and the rest still come back. total_unread covers every unread conversation found; total_unread_exact is false when a per-conversation limit truncated or a read failed. cursors ({ conversationId: messageId }) returns only unread messages newer than each conversation's cursor (one with none is left out, and total_unread counts only those). Each returned conversation carries next_cursor, its newest returned message id; next_cursors is the cursors passed in updated with every returned conversation's next_cursor (not those only in more_unread_conversations) \u2014 pass it back as cursors to get only what is new. ` + CURSOR_NO_CACHE_DESCRIPTION + FORMAT_DESCRIPTION + MARK_READ_DESCRIPTION + 'With mark_read each conversation returned with its messages (not more_unread_conversations) has its read marker moved up to its newest unread message returned (outside_window roots do not count) and carries marked_read (false with mark_read_warning when that move failed); one per_conversation_limit cut is not marked \u2014 marked_read: { skipped: "truncated", hint }; the user confirms first \u2014 a prompt where the client supports one, otherwise the first call returns only a preview and a confirmToken, and the repeat call with it reads and marks. ' + CONFIRM_INJECTION_RULE + " " + GROUP_TITLE_DESCRIPTION + " query also matches those participant names, and the last-message preview. " + MATCH_REASON_DESCRIPTION + "Message times are UTC (ISO 8601); " + TIME_ZONE_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
51505
+ description: `Get every unread message across all the chats and channels the signed-in user is in (or those matching kinds / query), grouped by conversation, most recent activity first. Each conversation comes with its summary (id, kind, title, team) and only the messages the user has not read, oldest first; a channel's are grouped as threads under their root post. A root the user already read is fetched and marked outside_window: true (it is context, not unread or counted); up to ${MAX_ROOT_FETCHES} roots are fetched per call, and any beyond that or that cannot be fetched is { id, missing: true }. Exact, as in Teams: every conversation with activity past its read marker (or never opened) is read past the marker and kept only if it holds a real message from someone else, so a call recording, transcript or other system event never makes a conversation unread. Channels the user has hidden in Teams are left out (include_hidden adds them); one that is gone or no longer readable (404/403) is skipped and counted in skipped_unreachable. Only conversations whose newest unread message is from the last 14 days are returned by default (since_days widens or narrows it); older unread conversations \u2014 typically dormant channels \u2014 are not read past their marker and are counted in older_unread_skipped; older_unread: true also lists them in older_unread_conversations (id, kind, title, team, lastActivity, and unread_count only for those already read \u2014 unread_count_known: false otherwise). Chats the user muted in Teams (muted: true) are left out too and counted in muted_skipped, without being read; include_muted adds them. Unread conversations past max_conversations are listed by id, title and unread_count in more_unread_conversations; read one with teams_read_conversation. A conversation that could not be read is listed in errors and the rest still come back. total_unread covers every unread conversation found; total_unread_exact is false when a per-conversation limit truncated or a read failed. cursors ({ conversationId: messageId }) returns only unread messages newer than each conversation's cursor (one with none is left out, and total_unread counts only those). Each returned conversation carries next_cursor, its newest returned message id; next_cursors is the cursors passed in updated with every returned conversation's next_cursor (not those only in more_unread_conversations) \u2014 pass it back as cursors to get only what is new. ` + CURSOR_NO_CACHE_DESCRIPTION + FROM_DESCRIPTION + "With from the result is one list across every conversation instead: messages (each with its conversation_id; a channel reply keeps replyTo), oldest first, at most limit; conversations (the summary of each one on the page); total_unread (every unread message past from, this page and later ones); from_time, has_more, next_from, next_from_time; skipped_unreachable, muted_skipped and errors. next_from does not move while a read failed (call again). A conversation with more messages since from than a read can reach is listed in incomplete instead (unread_not_read_from / unread_not_read_until name the stretch not read; what arrived after it is returned) and does not hold next_from. from takes the place of since_days, cursors, per_conversation_limit, max_conversations, older_unread and mark_read, and format summary does not apply. " + FORMAT_DESCRIPTION + MARK_READ_DESCRIPTION + 'With mark_read each conversation returned with its messages (not more_unread_conversations) has its read marker moved up to its newest unread message returned (outside_window roots do not count) and carries marked_read (false with mark_read_warning when that move failed); one per_conversation_limit cut is not marked \u2014 marked_read: { skipped: "truncated", hint }; the user confirms first \u2014 a prompt where the client supports one, otherwise the first call returns only a preview and a confirmToken, and the repeat call with it reads and marks. ' + CONFIRM_INJECTION_RULE + " " + GROUP_TITLE_DESCRIPTION + " query also matches those participant names, and the last-message preview. " + MATCH_REASON_DESCRIPTION + "Message times are UTC (ISO 8601); " + TIME_ZONE_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
51171
51506
  // A write only with mark_read, but a write: it moves the user's read markers (never backwards, so a repeat is a no-op).
51172
51507
  annotations: toolAnnotations({ readOnly: false, destructive: false, idempotent: true, openWorld: true }),
51173
51508
  inputSchema: {
@@ -51190,6 +51525,10 @@ function registerUnreadTools(server, { chatsvc }) {
51190
51525
  `Maximum unread conversations returned with their messages, most recent activity first (default ${DEFAULT_CONVERSATIONS}, max ${MAX_CONVERSATIONS2}); the rest are listed in more_unread_conversations.`
51191
51526
  ),
51192
51527
  cursors: cursorsArg,
51528
+ from: fromArg,
51529
+ limit: external_exports.number().int().min(1).max(MAX_FROM_MESSAGES).optional().describe(
51530
+ `With from only: maximum messages returned across every conversation, oldest first (default ${DEFAULT_LIMIT}, max ${MAX_FROM_MESSAGES}).`
51531
+ ),
51193
51532
  tz: tzArg,
51194
51533
  format: formatArg,
51195
51534
  mark_read: markReadArg,
@@ -51206,6 +51545,8 @@ function registerUnreadTools(server, { chatsvc }) {
51206
51545
  per_conversation_limit,
51207
51546
  max_conversations,
51208
51547
  cursors,
51548
+ from,
51549
+ limit,
51209
51550
  tz,
51210
51551
  format,
51211
51552
  mark_read,
@@ -51213,6 +51554,21 @@ function registerUnreadTools(server, { chatsvc }) {
51213
51554
  }, ctx) => {
51214
51555
  try {
51215
51556
  assertMarkReadFormat(mark_read, format);
51557
+ if (from === void 0 && limit !== void 0) {
51558
+ throw new McpToolError("limit applies only with from.", {
51559
+ hint: "Without from, use per_conversation_limit and max_conversations."
51560
+ });
51561
+ }
51562
+ if (from !== void 0) {
51563
+ const args = { since_days, cursors, per_conversation_limit, max_conversations, mark_read, older_unread };
51564
+ const clash = NOT_WITH_FROM.find((k) => args[k] !== void 0 && args[k] !== false);
51565
+ if (clash !== void 0 || format === "summary") {
51566
+ throw new McpToolError(`from cannot be combined with ${clash ?? "format summary"}.`, {
51567
+ hint: "from pages one oldest-first list across every conversation: pass a previous next_from to go on, and use teams_mark_read to mark what was paged read."
51568
+ });
51569
+ }
51570
+ }
51571
+ const pos = from !== void 0 ? decodeFrom(from) : void 0;
51216
51572
  const timeZone = resolveTimeZone(tz);
51217
51573
  const fetched_at = (/* @__PURE__ */ new Date()).toISOString();
51218
51574
  const [raw, me] = await Promise.all([chatsvc.listConversations(), chatsvc.meMri()]);
@@ -51224,6 +51580,14 @@ function registerUnreadTools(server, { chatsvc }) {
51224
51580
  const mutedSkipped = include_muted ? 0 : candidates.filter((s) => s.muted).length;
51225
51581
  if (!include_muted) candidates = candidates.filter((s) => !s.muted);
51226
51582
  candidates.sort(byLastActivityDesc2);
51583
+ if (pos !== void 0) {
51584
+ const page = await unreadFrom(chatsvc, raw, me, candidates, pos, {
51585
+ limit: limit ?? DEFAULT_LIMIT,
51586
+ timeZone,
51587
+ format: format === "compact" ? "compact" : "full"
51588
+ });
51589
+ return untrustedResult2({ ...page, muted_skipped: mutedSkipped, fetched_at });
51590
+ }
51227
51591
  const perLimit = per_conversation_limit ?? DEFAULT_PER_CONVERSATION;
51228
51592
  const outcome = await confirmUnreadCandidates(
51229
51593
  chatsvc,
@@ -51354,11 +51718,6 @@ function decodeChangesCursor(cursor) {
51354
51718
  if (Number.isNaN(t)) throw badCursor(cursor);
51355
51719
  return t;
51356
51720
  }
51357
- function changedMs(m) {
51358
- const v = Number(m.version);
51359
- const id = Number(m.id);
51360
- return Math.max(Number.isFinite(v) ? v : 0, Number.isFinite(id) ? id : 0);
51361
- }
51362
51721
  async function readChanges(chatsvc, summary, t, me) {
51363
51722
  let capped = false;
51364
51723
  const fetched = await chatsvc.getMessages(summary.id, {