mcp-teams 0.3.43 → 0.3.45

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 CHANGED
@@ -92,7 +92,7 @@ Teams on the web talks to several services, each with its own sign-in token: cha
92
92
 
93
93
  The extension never reloads your Teams tab, so a call, meeting, draft or screen share there goes on. When a tool needs a session that isn't there, or Teams rejects one (tokens expire after about an hour), Teams' own tab gets a few seconds to send a fresh one; if it doesn't (and at once after a rejection), the extension opens Teams in a background tab, notes the tokens from that tab's requests and closes it again as soon as the sessions the waiting calls need are back, or after at most a minute (it stays open if you switch to it, and closing it ends the wait). There is only ever one such tab: calls that need different services at the same time wait on the same one. No tab is opened while your Teams tab is still loading, since it signs in by itself; the call waits up to 30 s for it instead. If the session still isn't back, the call says so and asks you to reload Teams yourself. Search is the exception: Teams signs in to it only once you have used its search box, so no tab is opened for it, and `search_messages` and `find_people` say so after a short wait.
94
94
 
95
- The browser clears that memory when the extension is reloaded or updated. A Teams tab left in the background may not call its services again for a while, so if it hasn't within 15 s, the extension opens Teams in the same kind of background tab until the chat session is back, or at the latest about 75 s after the reload. A tool call made meanwhile uses that tab too. Nothing is opened after a reload or update when no Teams tab is open, when the Teams tab is still loading (it signs in by itself), or when the browser has put every Teams tab to sleep (discarded).
95
+ The sessions are kept in memory only, so the browser clears them when it restarts and when the extension is reloaded or updated. An idle Teams tab, such as one restored at a browser start, may not call its services again until you use it. So once per browser session the extension checks for a Teams tab that has loaded, is awake and hasn't brought the chat session back: right after the start, reload or update, then every 30 s until it finds one. That tab gets 15 s to send the session; if it doesn't, the extension opens Teams in the same kind of background tab until the chat session is back, or for at most about a minute. A tool call made meanwhile uses that tab too. Nothing is opened while no Teams tab is open, while the Teams tab is still loading (it signs in by itself), or while the browser has put every Teams tab to sleep (discarded). This happens at most once per browser session, so a Teams tab stuck at sign-in doesn't get a new background tab every 30 s.
96
96
 
97
97
  ## Several sessions at once
98
98
 
package/dist/build.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.3.43",
3
- "buildId": "08927041e6f2"
2
+ "version": "0.3.45",
3
+ "buildId": "5318fa979921"
4
4
  }
@@ -370,7 +370,7 @@ const RECAPTURE_WAIT_MS = 60_000;
370
370
  const RECAPTURE_JOIN_MIN_MS = 20_000;
371
371
  // How long a call waits for a user's Teams tab that is still loading to bring the session.
372
372
  const LOADING_TAB_WAIT_MS = 30_000;
373
- let recapturing = null; // Promise of recaptureAfterReload while it runs, so a second report of the reload starts none
373
+ let recapturing = null; // Promise of recaptureMissingChatSession while it runs, so a second trigger starts none
374
374
  // The background tab (one at a time), kept in chrome.storage.session so a later worker can close it.
375
375
  const HELPER_TAB_KEY = "recaptureHelperTab";
376
376
  // The background tab's run while it is open: { since, waits (Promise<capture|null>[]), tabGone, done, closing }.
@@ -434,28 +434,52 @@ async function helperTabId() {
434
434
  return tabId ?? null;
435
435
  }
436
436
 
437
+ /** The Teams tabs that have loaded and are awake (not discarded or unloaded). */
438
+ async function awakeTeamsTabs() {
439
+ return (await chrome.tabs.query({ url: TEAMS_URLS })).filter((t) => TEAMS_TAB.test(t.url ?? "") && !t.discarded && t.status === "complete");
440
+ }
441
+
437
442
  /**
438
- * Chrome clears chrome.storage.session when the extension is reloaded or updated, so the
439
- * captured sessions are gone; a Teams tab left in the background may not call its services
440
- * again for a long time. Unless Teams does so within RECAPTURE_GRACE_MS, this gets the chat
441
- * session back through the background tab (recaptureInHelperTab). Nothing is done without a
442
- * Teams tab that has loaded and is awake: one still loading calls its services itself, and a
443
- * discarded or unloaded one isn't woken.
443
+ * Chrome clears chrome.storage.session when the extension is reloaded or updated, and when the
444
+ * browser restarts, so the captured sessions are gone; a Teams tab left in the background may
445
+ * not call its services again for a long time (a tab restored at a browser start may even have
446
+ * made its first calls before this worker listened). Unless Teams does so within
447
+ * RECAPTURE_GRACE_MS, this gets the chat session back through the background tab
448
+ * (recaptureInHelperTab). Nothing is done without a Teams tab that has loaded and is awake: one
449
+ * still loading calls its services itself, and a discarded or unloaded one isn't woken.
444
450
  */
445
- function recaptureAfterReload() {
451
+ function recaptureMissingChatSession() {
446
452
  recapturing ??= (async () => {
447
453
  const since = Date.now();
448
- if (await getCapture("chatsvc")) return;
449
- const awake = (await chrome.tabs.query({ url: TEAMS_URLS })).filter((t) => TEAMS_TAB.test(t.url ?? "") && !t.discarded && t.status === "complete");
450
- if (!awake.length) return;
451
- if (await waitForCapture("chatsvc", since, RECAPTURE_GRACE_MS)) return;
454
+ if (await getCapture("chatsvc")) return true;
455
+ const awake = await awakeTeamsTabs();
456
+ if (!awake.length) return false; // nothing decided: no Teams tab loaded and awake
457
+ if (await waitForCapture("chatsvc", since, RECAPTURE_GRACE_MS)) return true;
452
458
  await recaptureInHelperTab("chatsvc", teamsOrigin(awake[0]), since);
459
+ return true;
453
460
  })()
454
- .catch(() => {})
461
+ .catch(() => false)
455
462
  .finally(() => (recapturing = null));
456
463
  return recapturing;
457
464
  }
458
465
 
466
+ // Set in chrome.storage.session once this browser session's (or extension load's) check for a
467
+ // missing chat session has finished, so it runs once: a Teams tab stuck at sign-in gets one
468
+ // background tab, not one per alarm.
469
+ const START_CHECK_KEY = "startRecaptureChecked";
470
+
471
+ /**
472
+ * After a browser start, an extension reload or update, and on each reconnect alarm: once per
473
+ * browser session, recaptureMissingChatSession (calls while it runs share that run). The flag is
474
+ * set only once the run has finished and decided something, so a worker suspended mid-run, or a
475
+ * Teams tab still loading or asleep, leaves it unset: a later alarm checks again.
476
+ * Use this, not recaptureMissingChatSession, for any new trigger.
477
+ */
478
+ async function recaptureOnce() {
479
+ if ((await chrome.storage.session.get(START_CHECK_KEY))[START_CHECK_KEY]) return;
480
+ if (await recaptureMissingChatSession()) await chrome.storage.session.set({ [START_CHECK_KEY]: true });
481
+ }
482
+
459
483
  /** Closes the background tab, unless the user switched to it, and forgets it. */
460
484
  async function closeHelperTab(tabId) {
461
485
  const tab = await chrome.tabs.get(tabId).catch(() => null);
@@ -2098,13 +2122,15 @@ export function registerListeners() {
2098
2122
  if (a.name !== "reconnect") return;
2099
2123
  connect();
2100
2124
  closeLeftoverHelperTab().catch(() => {});
2125
+ recaptureOnce().catch(() => {});
2101
2126
  });
2102
2127
  chrome.storage.onChanged.addListener(onStorageChanged);
2103
2128
  chrome.runtime.onStartup.addListener(connect);
2104
2129
  chrome.runtime.onInstalled.addListener(connect);
2105
- // The captured sessions were cleared (see recaptureAfterReload); a browser update isn't a
2106
- // reload, and on a browser start the restored tabs load (or sleep) by themselves.
2107
- chrome.runtime.onInstalled.addListener((d) => (d?.reason === "install" || d?.reason === "update") && recaptureAfterReload());
2130
+ // The captured sessions were cleared (see recaptureMissingChatSession).
2131
+ chrome.runtime.onStartup.addListener(() => recaptureOnce().catch(() => {}));
2132
+ // A browser update (reason "chrome_update") isn't a reload: the sessions are still there.
2133
+ chrome.runtime.onInstalled.addListener((d) => (d?.reason === "install" || d?.reason === "update") && recaptureOnce().catch(() => {}));
2108
2134
  }
2109
2135
 
2110
2136
  // In the browser: listen and connect synchronously on load, as MV3 needs for its listeners
@@ -2,7 +2,7 @@
2
2
  "manifest_version": 3,
3
3
  "key": "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvoz9Wexl4ZqY9YtEyBZsu/Qi5Ft5EjNUNB8b30wgt3AR8TjXI5UumcPQFBIm7ZfvBsjgrh6tBJlygsgFbZ5cB1EiI+WSz/2Wcqwz4eowKMXXPvGuDGrO+2O2zbSpTG19/MwTljI+g0TLfn8Vkoqd8z9MskKk+vCZjjV0Jk8QjVEdHypgM7H8zTuUM06SO12IIZMdeE3IURzf35zbjlfPPkJiDWoo3wB9nxAvLd57xrQhPUB/lGtCJk9mS3SY+/VwOlG5kJ9WS/RCHXcs5Qs7huIlKIatmFz7YiducvTR3DKBbjqbMTyqHzXkmkUmJRqzsYtgtKcz0C0cjFOt6uNdhwIDAQAB",
4
4
  "name": "mcp-teams bridge",
5
- "version": "0.3.43",
5
+ "version": "0.3.45",
6
6
  "description": "Lets AI assistants (via the mcp-teams MCP server) read and search Microsoft Teams chats, channels and meeting transcripts and, with your explicit confirmation, post messages.",
7
7
  "minimum_chrome_version": "116",
8
8
  "icons": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-teams",
3
- "version": "0.3.43",
3
+ "version": "0.3.45",
4
4
  "description": "MCP server that lets AI assistants work with Microsoft Teams (web) through a Chrome/Edge extension bridge",
5
5
  "keywords": ["mcp", "model-context-protocol", "teams", "microsoft-teams", "microsoft-365", "chat", "claude", "chrome-extension"],
6
6
  "repository": {