mcp-teams 0.3.19 → 0.3.22

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.
@@ -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.19",
5
+ "version": "0.3.22",
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": {
@@ -54,6 +54,31 @@ export function pickHeaders(requestHeaders) {
54
54
  return headers.authorization || headers.authentication || headers["x-skypetoken"] ? headers : null;
55
55
  }
56
56
 
57
+ const GUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
58
+
59
+ /**
60
+ * The object id (lowercase GUID) of the user a request's token was issued to, or null.
61
+ * Teams' tokens are JWTs: an AAD bearer token carries `oid`, a skype token
62
+ * `skypeid: "orgid:<oid>"`. An object id belongs to one tenant (a guest has its own in each),
63
+ * so it tells accounts and tenants apart. Only the payload is decoded, locally and without
64
+ * verifying; nothing else of the token is kept.
65
+ */
66
+ export function tokenOid(headers) {
67
+ for (const value of [headers?.authorization, headers?.authentication, headers?.["x-skypetoken"]]) {
68
+ const jwt = /([A-Za-z0-9_-]+)\.([A-Za-z0-9_-]+)\.[A-Za-z0-9_-]*$/.exec(String(value ?? ""));
69
+ if (!jwt) continue;
70
+ let claims;
71
+ try {
72
+ claims = JSON.parse(atob(jwt[2].replace(/-/g, "+").replace(/_/g, "/")));
73
+ } catch {
74
+ continue;
75
+ }
76
+ const oid = String(claims?.oid ?? /^orgid:(.+)$/i.exec(String(claims?.skypeid ?? ""))?.[1] ?? "").toLowerCase();
77
+ if (GUID.test(oid)) return oid;
78
+ }
79
+ return null;
80
+ }
81
+
57
82
  /** A paging link from chatsvc (often on its own host) on the base we send requests to. */
58
83
  export function rebase(link, base) {
59
84
  const i = link.indexOf("/v1/");
@@ -837,6 +862,57 @@ export function filterTraffic(list, { filter, limit = 100 } = {}) {
837
862
  .map(({ key, ...e }) => ({ ...e, lastAt: new Date(e.lastAt).toISOString() }));
838
863
  }
839
864
 
865
+ // ------------------------------------------------------------ caches
866
+
867
+ /**
868
+ * A least-recently-used cache bounded by bytes, not by entries: set() takes each value's size
869
+ * (the caller's measure, e.g. the length of the text it was parsed from) and evicts the least
870
+ * recently used entries until the total fits the cap. A value bigger than the cap isn't
871
+ * cached at all, and evicts nothing.
872
+ */
873
+ export class ByteCache {
874
+ #map = new Map(); // key -> { value, bytes }, least recently used first
875
+ #bytes = 0;
876
+ constructor(maxBytes) {
877
+ this.maxBytes = maxBytes;
878
+ }
879
+ get bytes() {
880
+ return this.#bytes;
881
+ }
882
+ get size() {
883
+ return this.#map.size;
884
+ }
885
+ get(key) {
886
+ const e = this.#map.get(key);
887
+ if (!e) return undefined;
888
+ this.#map.delete(key);
889
+ this.#map.set(key, e);
890
+ return e.value;
891
+ }
892
+ set(key, value, bytes) {
893
+ this.delete(key);
894
+ if (bytes > this.maxBytes) return;
895
+ for (const [k, e] of this.#map) {
896
+ if (this.#bytes + bytes <= this.maxBytes) break;
897
+ this.#map.delete(k);
898
+ this.#bytes -= e.bytes;
899
+ }
900
+ this.#map.set(key, { value, bytes });
901
+ this.#bytes += bytes;
902
+ }
903
+ delete(key) {
904
+ const e = this.#map.get(key);
905
+ if (!e) return false;
906
+ this.#map.delete(key);
907
+ this.#bytes -= e.bytes;
908
+ return true;
909
+ }
910
+ clear() {
911
+ this.#map.clear();
912
+ this.#bytes = 0;
913
+ }
914
+ }
915
+
840
916
  // ------------------------------------------------------------ meetings
841
917
 
842
918
  /** The tenant most of the user's non-meeting chats live in: their own organization's. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mcp-teams",
3
- "version": "0.3.19",
3
+ "version": "0.3.22",
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": {
@@ -28,6 +28,7 @@
28
28
  "test:system": "tsc -p tsconfig.json && vitest run test/system",
29
29
  "typecheck": "tsc -p tsconfig.json --noEmit",
30
30
  "probe": "node scripts/probe.mjs",
31
+ "measure-memory": "tsc -p tsconfig.json && node scripts/measure-memory.mjs",
31
32
  "update": "node scripts/update.mjs",
32
33
  "prepublishOnly": "npm test"
33
34
  },