mcp-teams 0.3.42 → 0.3.44

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,13 +92,13 @@ 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
 
99
99
  Every AI session starts its own mcp-teams server, and they share the one extension connection. The first server owns the bridge port (`role: "hub"` in `get_version`), and later ones forward their calls through it (`role: "peer"`). When the hub's session ends, a peer takes over within a second. A newer server takes over from an older one. Servers of 0.2.0 and older can't do the newer handshake: after updating from them, restart AI sessions that are still open (in Claude Code: `/mcp`).
100
100
 
101
- A server that is already running keeps its code when the copy on disk changes (`git pull` and `npm run build`). It notices: `get_version` then shows `restartNeeded: true` with the build on disk, and every failed tool call ends with a line saying to reconnect it with `/mcp` and reload the extension.
101
+ A server that is already running keeps its code when the copy on disk changes (`git pull` and `npm run build`). It notices: `get_version` then shows `restartNeeded: true` with the build on disk, and every failed tool call ends with a line saying to reconnect it with `/mcp` and reload the extension. It compares its version and build id with those in `dist/build.json` on disk. The build id is a hash of the server code (`dist/**/*.js`) and of the extension it ships (`extension/`, without the `pairing.json` that only the installed copy has). So a release that changes only the extension counts as a new build too, and a rebuild that changes nothing doesn't. The same files give the same build id on Windows and Linux.
102
102
 
103
103
  ## Configuration
104
104
 
package/dist/build.json CHANGED
@@ -1,4 +1,4 @@
1
1
  {
2
- "version": "0.3.42",
3
- "buildId": "b80780726765"
2
+ "version": "0.3.44",
3
+ "buildId": "119d817ed263"
4
4
  }
package/dist/buildInfo.js CHANGED
@@ -27,7 +27,7 @@ export const BUILD_CHECK_CACHE_MS = 5_000;
27
27
  /**
28
28
  * Compares the running build with the one in `dir` on disk, read again when asked but at most once per
29
29
  * BUILD_CHECK_CACHE_MS (by `now`). A restart is needed when the two build ids differ (not "newer": any
30
- * other build), never when either has no id.
30
+ * other build) or their versions do (every release bumps it, #100), never when either has no id.
31
31
  */
32
32
  export function restartCheck(running, dir, now = Date.now) {
33
33
  let last;
@@ -41,7 +41,7 @@ export function restartCheck(running, dir, now = Date.now) {
41
41
  catch {
42
42
  return { restartNeeded: false };
43
43
  }
44
- return onDisk.buildId && onDisk.buildId !== running.buildId
44
+ return onDisk.buildId && (onDisk.buildId !== running.buildId || onDisk.version !== running.version)
45
45
  ? { restartNeeded: true, onDisk: { version: onDisk.version, build: onDisk.buildId } }
46
46
  : { restartNeeded: false };
47
47
  };
@@ -1 +1 @@
1
- {"version":3,"file":"buildInfo.js","sourceRoot":"","sources":["../src/buildInfo.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AASjC;;;GAGG;AACH,MAAM,UAAU,aAAa,CAAC,GAAW;IACvC,IAAI,CAAC;QACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;QACvE,IAAI,OAAO,IAAI,EAAE,OAAO,KAAK,QAAQ,IAAI,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ;YAAE,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,CAAC;IACrI,CAAC;IAAC,MAAM,CAAC;QACP,4CAA4C;IAC9C,CAAC;IACD,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,CAAwB,CAAC;IACrG,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AACjD,CAAC;AAKD,uFAAuF;AACvF,MAAM,UAAU,WAAW,CAAC,OAAkB,EAAE,KAAmB;IACjE,IAAI,CAAC,KAAK,CAAC,aAAa;QAAE,OAAO,IAAI,CAAC;IACtC,OAAO,0CAA0C,OAAO,CAAC,OAAO,IAAI,OAAO,CAAC,OAAO,aAAa,KAAK,CAAC,MAAM,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,uDAAuD,CAAC;AACpM,CAAC;AAED,sDAAsD;AACtD,MAAM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EAAE,KAAK,EAAE,CAAC;QACtD,IAAI,MAAiB,CAAC;QACtB,IAAI,CAAC;YACH,MAAM,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAC9B,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;QAClC,CAAC;QACD,OAAO,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC;YACjG,CAAC,CAAC,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,OAAO,EAAE,MAAM,CAAC,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,OAAO,EAAE,EAAE;YACrF,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,EAAE,CAAC;IAC/B,CAAC,CAAC;IACF,OAAO,GAAG,EAAE;QACV,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC;QACjB,IAAI,CAAC,IAAI,IAAI,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,oBAAoB;YAAE,IAAI,GAAG,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;QAChF,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC,CAAC;AACJ,CAAC"}
@@ -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
451
  function recaptureAfterReload() {
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, recaptureAfterReload (calls while it runs share that run). The flag is set
474
+ * 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 recaptureAfterReload, 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 recaptureAfterReload()) 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 recaptureAfterReload).
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.42",
5
+ "version": "0.3.44",
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.42",
3
+ "version": "0.3.44",
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": {