@chrischall/microsoft-teams-mcp 0.9.0 → 0.11.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/dist/chatsvc.js CHANGED
@@ -109,6 +109,8 @@ function outcomeUnknown(method, e, hint) {
109
109
  const SEND_OUTCOME_HINT = 'The message may already have been posted — check the conversation (teams_list_messages) before retrying; do not resend blindly.';
110
110
  const REACTION_OUTCOME_HINT = 'The reaction change may already have been applied — check the message (teams_list_messages) before retrying.';
111
111
  const THREAD_OUTCOME_HINT = 'The change to the chat may already have been applied — check the chat (its name and members) before retrying.';
112
+ const CREATE_OUTCOME_HINT = 'A chat may already have been created — check teams_list_conversations before retrying; a blind retry ' +
113
+ 'would create a second chat (and a chat cannot be deleted).';
112
114
  const HORIZON_OUTCOME_HINT = 'The read marker may already have moved — check the conversation (teams_list_messages) before retrying; ' +
113
115
  'moving it again to the same message is harmless.';
114
116
  export class ChatServiceClient {
@@ -393,6 +395,53 @@ export class ChatServiceClient {
393
395
  async removeMember(id, mri) {
394
396
  await this.#writeThread('DELETE', `${this.#threadUrl(id)}/members/${encodeURIComponent(mri)}`);
395
397
  }
398
+ /**
399
+ * Start a group chat: `POST /threads` with every member as `Admin` (Teams
400
+ * makes every group-chat member Admin) and `{ threadType: "chat" }` plus the
401
+ * topic when there is one (verified live 2026-11-09: 201, `{}`, and the new
402
+ * id in `Location`). The signed-in user is always the first member.
403
+ *
404
+ * Not idempotent: an answer lost after sending (a timeout, a dropped
405
+ * connection, a 5xx) is a `WriteOutcomeUnknownError` — the chat may exist,
406
+ * and a retry would make a second one. A success without a readable
407
+ * `Location` is an error too: the chat was probably made, its id unknown.
408
+ */
409
+ async createGroupChat(memberMris, topic) {
410
+ this.#requireConfigured();
411
+ const me = await this.meMri();
412
+ const others = memberMris.filter((m) => m.toLowerCase() !== me.toLowerCase());
413
+ const body = {
414
+ members: [me, ...others].map((id) => ({ id, role: 'Admin' })),
415
+ properties: {
416
+ threadType: 'chat',
417
+ ...(topic ? { topic } : {}),
418
+ fixedRoster: false,
419
+ uniquerosterthread: false,
420
+ },
421
+ };
422
+ const { status, headers } = await this.#send(`${this.#baseUrl}/threads`, 'text', undefined, {
423
+ method: 'POST',
424
+ body,
425
+ hint: CREATE_OUTCOME_HINT,
426
+ });
427
+ this.#checkWriteStatus('POST', status, CREATE_OUTCOME_HINT);
428
+ const raw = /\/threads\/([^/?#]+)\/?(?:[?#].*)?$/.exec(headers.get('location') ?? '')?.[1];
429
+ let id;
430
+ try {
431
+ id = raw !== undefined ? decodeURIComponent(raw) : undefined;
432
+ }
433
+ catch {
434
+ id = undefined;
435
+ }
436
+ if (!id) {
437
+ throw new McpToolError(`Teams answered HTTP ${status} to creating the group chat, so it was probably created, but its id was not returned.`, {
438
+ status,
439
+ kind: 'http',
440
+ hint: 'Find the new chat in teams_list_conversations (it has no messages yet) before trying again — do not retry blindly.',
441
+ });
442
+ }
443
+ return { id };
444
+ }
396
445
  #threadUrl(id) {
397
446
  return `${this.#baseUrl}/threads/${encodeURIComponent(id)}`;
398
447
  }
package/dist/index.js CHANGED
@@ -4,6 +4,7 @@ import { VERSION } from './version.js';
4
4
  import { ChatServiceClient } from './chatsvc.js';
5
5
  import { SharePointClient } from './sharepoint.js';
6
6
  import { SubstrateClient } from './substrate.js';
7
+ import { RecapClient } from './recap.js';
7
8
  import { registerChatTools } from './tools/chat.js';
8
9
  import { registerChannelTools } from './tools/channels.js';
9
10
  import { registerConversationTools } from './tools/conversation.js';
@@ -19,6 +20,7 @@ import { registerSearchTools } from './tools/search.js';
19
20
  import { registerHealthcheckTool } from './tools/healthcheck.js';
20
21
  import { registerExportTools } from './tools/export.js';
21
22
  import { registerTranscriptTools } from './tools/transcript.js';
23
+ import { registerRecapTools } from './tools/recap.js';
22
24
  loadDotenvSafely();
23
25
  /**
24
26
  * Built HERE, in the caller, not inside a registrar — see office-outlook-mcp
@@ -27,12 +29,14 @@ loadDotenvSafely();
27
29
  * this MCP a second `ChatServiceClient` would mean a second token capture.
28
30
  * `SharePointClient` holds its own SharePoint token manager, so the same reason
29
31
  * applies — build it once, here, beside the chat-service client — and so does
30
- * `SubstrateClient`, which holds the search token.
32
+ * `SubstrateClient`, which holds the search token, and `RecapClient`, which
33
+ * holds the meeting-recap token.
31
34
  */
32
35
  const deps = {
33
36
  chatsvc: new ChatServiceClient(),
34
37
  sharepoint: new SharePointClient(),
35
38
  substrate: new SubstrateClient(),
39
+ recap: new RecapClient(),
36
40
  };
37
41
  await runMcp({
38
42
  name: 'microsoft-teams-mcp',
@@ -54,6 +58,7 @@ await runMcp({
54
58
  registerSearchTools,
55
59
  registerExportTools,
56
60
  registerTranscriptTools,
61
+ registerRecapTools,
57
62
  registerHealthcheckTool,
58
63
  ],
59
64
  });
@@ -0,0 +1,44 @@
1
+ /**
2
+ * Bootstrap-only fetchproxy auth for meeting recaps — the Meeting Collab
3
+ * Platform Service (`teams.cloud.microsoft/api/mcps/*`) that Teams' Recap tab
4
+ * reads (`teams_get_meeting_recap`).
5
+ *
6
+ * MCPS accepts neither the chat-service token (a 401) nor the Substrate one: it
7
+ * wants its own (audience `6bc3b958-689b-49f5-9006-36d165f30e00`, scopes
8
+ * `User.Read user_impersonation`, about an hour). So, as with the other
9
+ * three, we snapshot the `Authorization` header off a request the signed-in
10
+ * Teams tab already makes — here, the `readcollabobject` call its Recap tab
11
+ * issues on opening — and talk to MCPS with a plain Node `fetch` (`recap.ts`).
12
+ *
13
+ * Verified live 2026-11-10: opening a meeting chat's Recap tab during the
14
+ * capture window yielded that token, which `recap.ts` replayed from Node.
15
+ *
16
+ * Import LAZILY (`await import('./recap-auth.js')`), like the other captures,
17
+ * so boot never loads the bridge.
18
+ */
19
+ import { captureBearerHeader } from '@chrischall/mcp-utils/fetchproxy';
20
+ import { captureWindowMs } from './capture-window.js';
21
+ import { bridgeScopedTransport, getWsPort } from './auth-fetchproxy.js';
22
+ import { BRIDGE_TRUST_DOMAINS, RECAP_CAPTURE_DECL } from './bridge-scope.js';
23
+ import { PACKAGE_NAME, VERSION } from './version.js';
24
+ export { RECAP_CAPTURE_DECL } from './bridge-scope.js';
25
+ /**
26
+ * Capture a meeting-recap (MCPS) token from the user's signed-in Teams tab.
27
+ * Returns the bare token (no `Bearer ` prefix).
28
+ */
29
+ export async function captureRecapTokenViaFetchproxy(env = process.env) {
30
+ return captureBearerHeader({
31
+ // The one bridge scope every capture of this server declares (`bridge-scope.ts`).
32
+ captures: [{ ...RECAP_CAPTURE_DECL }],
33
+ domains: [...BRIDGE_TRUST_DOMAINS],
34
+ windowMs: captureWindowMs(env),
35
+ port: getWsPort(),
36
+ serverName: PACKAGE_NAME,
37
+ version: VERSION,
38
+ what: 'a Teams meeting-recap token',
39
+ guidance: "In a signed-in teams.cloud.microsoft tab, open any meeting chat and click its Recap tab — that is what " +
40
+ 'makes Teams call its meeting-recap service, where the token is read from — then retry. If the ContextMint ' +
41
+ 'Bridge asks to re-pair microsoft-teams-mcp, approve it once: the recap capture is new to its scope.',
42
+ createTransport: bridgeScopedTransport(env),
43
+ });
44
+ }
@@ -0,0 +1,50 @@
1
+ import { createFileStatePersistence, isBearerTokens, resolveStateFile, } from '@chrischall/mcp-utils/session';
2
+ import { parseBoolEnv } from '@chrischall/mcp-utils';
3
+ import { reportCacheWriteFailure } from './token-cache.js';
4
+ /**
5
+ * Where the captured meeting-recap (MCPS) token is cached between runs: its
6
+ * own file beside the other three, since it has its own audience and lifetime.
7
+ */
8
+ export function recapTokenCachePath(env = process.env) {
9
+ return resolveStateFile({
10
+ env,
11
+ envVar: 'TEAMS_RECAP_TOKEN_FILE',
12
+ subdir: '.microsoft-teams-mcp',
13
+ fileName: 'recap-token.json',
14
+ });
15
+ }
16
+ /**
17
+ * The recap token cache, or `null` when it is off (`TEAMS_TOKEN_CACHE=false`)
18
+ * or there is nothing to cache (`TEAMS_DISABLE_FETCHPROXY` — the bridge is
19
+ * its only source). A failed write is reported, never thrown.
20
+ */
21
+ export function createRecapTokenCache(env = process.env) {
22
+ if (!parseBoolEnv('TEAMS_TOKEN_CACHE', { env, default: true }))
23
+ return null;
24
+ if (parseBoolEnv('TEAMS_DISABLE_FETCHPROXY', { env }))
25
+ return null;
26
+ const file = createFileStatePersistence({
27
+ filePath: recapTokenCachePath(env),
28
+ boundTo: 'fetchproxy',
29
+ validate: (raw) => (isBearerTokens(raw) ? raw : null),
30
+ });
31
+ return {
32
+ load: () => file.load(),
33
+ save(tokens) {
34
+ try {
35
+ file.save(tokens);
36
+ }
37
+ catch (err) {
38
+ reportCacheWriteFailure(err);
39
+ }
40
+ },
41
+ clear() {
42
+ try {
43
+ file.clear();
44
+ }
45
+ catch (err) {
46
+ reportCacheWriteFailure(err);
47
+ }
48
+ },
49
+ };
50
+ }
package/dist/recap.js ADDED
@@ -0,0 +1,325 @@
1
+ /**
2
+ * Meeting recaps: the Meeting Collab Platform Service (MCPS) behind Teams'
3
+ * Recap tab.
4
+ *
5
+ * GET https://teams.cloud.microsoft/api/mcps/<region>/collab/readcollabobject/V2/
6
+ * <organizerOid>@<tenantId>/<occurrence id>/<meeting thread id>
7
+ * [Authorization: Bearer <MCPS token> — see `recap-auth.ts`]
8
+ * → { changeKey, id?, participants: [], resources: [{ id, type, location,
9
+ * metadata: { … }, subType, addedBy, additionDateTime }], … }
10
+ *
11
+ * Verified live 2026-11-10 against a real tenant (40 meeting chats sampled):
12
+ * - the organizer, tenant and series `iCalUid` come from the meeting thread's
13
+ * `meeting` property (`GET /threads/<id>`), as does `meetingType`
14
+ * (`Recurring` / `Scheduled`);
15
+ * - the occurrence id is the `iCalUid` (an Outlook GlobalObjectId, hex) with
16
+ * bytes 16-19 — hex characters 32-39 — set to the occurrence's year (2
17
+ * bytes), month and day; a one-off meeting, and a recurring series as a
18
+ * whole, use the `iCalUid` as it is (those bytes zero). The day was the
19
+ * same in UTC and the organizer's zone in every sample: which one MCPS
20
+ * means is not established;
21
+ * - an occurrence with nothing recorded answers 200 with `resources: []`;
22
+ * - resource types seen: `Recording` (location: the OneDrive/Stream play
23
+ * link; .NET-tick start/end), `TranscriptV2` (location: a SharePoint
24
+ * `/media/transcripts/<id>/content` API URL; `metadata.duration`),
25
+ * `transcript` (an older kind, ISO start), `notes` (the Loop meeting-notes
26
+ * page), `AttendanceReport`, `MeetingChat` (a file shared in the meeting
27
+ * chat), `MeetingStage` (shared on stage, e.g. a Whiteboard) and
28
+ * `AISummary` (the Intelligent Recap AI notes);
29
+ * - the AI notes themselves are a per-user file read through MCPS
30
+ * `groundingdata/drives/<d>/items/<i>/recapAISummary`: that answered 403
31
+ * ("Graph denied access") for anyone but the file's owner, and an
32
+ * unlicensed user sees no notes in Teams either. So this module reports
33
+ * that a summary exists, and never reads it;
34
+ * - the chat-service token is a 401 here: MCPS needs its own token.
35
+ *
36
+ * The bearer only ever goes to a URL this module BUILDS from vetted parts
37
+ * (GUIDs, a hex occurrence id, a `19:…@thread.v2` id) — never to a URL taken
38
+ * from a response.
39
+ */
40
+ import { fetchBounded, McpToolError, parseBoolEnv, readEnvVar } from '@chrischall/mcp-utils';
41
+ import { createCapturedTokenManager } from '@chrischall/mcp-utils/session';
42
+ import { describeTransportFailure } from './network-error.js';
43
+ import { createRecapTokenCache } from './recap-token-cache.js';
44
+ /** The MCPS region this tenant was verified on. */
45
+ export const DEFAULT_MCPS_REGION = 'us';
46
+ /** Per-request deadline, covering the body read. */
47
+ const REQUEST_TIMEOUT_MS = 30_000;
48
+ /** A collab object is a list of links; anything near this is not one. */
49
+ const MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
50
+ const GUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
51
+ /** An Outlook GlobalObjectId as hex: the 16-byte class id, the date, then the rest. */
52
+ const GOID = /^[0-9a-f]{40,256}$/i;
53
+ const THREAD_ID = /^19:[A-Za-z0-9_-]+@thread\.(?:v2|tacv2|skype)$/;
54
+ const DATE = /^(\d{4})-(\d{2})-(\d{2})$/;
55
+ /** .NET ticks at the Unix epoch. */
56
+ const EPOCH_TICKS = 621355968000000000n;
57
+ /** Capture lazily, so boot never loads the bridge. */
58
+ async function captureRecapTokenLazily() {
59
+ const mod = await import('./recap-auth.js');
60
+ return mod.captureRecapTokenViaFetchproxy();
61
+ }
62
+ function obj(v) {
63
+ return v !== null && typeof v === 'object' && !Array.isArray(v) ? v : undefined;
64
+ }
65
+ function str(v) {
66
+ return typeof v === 'string' && v.trim() !== '' ? v.trim() : undefined;
67
+ }
68
+ function isoOf(v) {
69
+ const s = str(v);
70
+ if (s === undefined)
71
+ return undefined;
72
+ const ms = Date.parse(s);
73
+ return Number.isFinite(ms) ? new Date(ms).toISOString() : undefined;
74
+ }
75
+ function httpsUrl(v) {
76
+ const s = str(v);
77
+ return s !== undefined && /^https:\/\//i.test(s) ? s : undefined;
78
+ }
79
+ /**
80
+ * The meeting a thread's `meeting` property describes (a JSON string, as
81
+ * Teams sends it, or an object), or `undefined` when there is none or its ids
82
+ * are not ids.
83
+ */
84
+ export function parseMeetingInfo(thread) {
85
+ const raw = thread.properties?.meeting;
86
+ let m;
87
+ if (typeof raw === 'string') {
88
+ try {
89
+ m = obj(JSON.parse(raw));
90
+ }
91
+ catch {
92
+ return undefined;
93
+ }
94
+ }
95
+ else {
96
+ m = obj(raw);
97
+ }
98
+ const iCalUid = str(m?.iCalUid);
99
+ const organizerId = str(m?.organizerId);
100
+ const tenantId = str(m?.tenantId);
101
+ if (m === undefined || iCalUid === undefined || organizerId === undefined || tenantId === undefined)
102
+ return undefined;
103
+ if (!GOID.test(iCalUid) || !GUID.test(organizerId) || !GUID.test(tenantId))
104
+ return undefined;
105
+ const subject = str(m.subject);
106
+ const seriesStart = isoOf(m.startTime);
107
+ const joinUrl = httpsUrl(m.meetingJoinUrl);
108
+ return {
109
+ ...(subject !== undefined ? { subject } : {}),
110
+ iCalUid,
111
+ organizerId,
112
+ tenantId,
113
+ recurring: m.meetingType === 'Recurring',
114
+ ...(seriesStart !== undefined ? { seriesStart } : {}),
115
+ ...(joinUrl !== undefined ? { joinUrl } : {}),
116
+ };
117
+ }
118
+ /** Whether `date` is a real `YYYY-MM-DD` day. */
119
+ export function isOccurrenceDate(date) {
120
+ const m = DATE.exec(date);
121
+ if (!m)
122
+ return false;
123
+ const d = new Date(Date.UTC(Number(m[1]), Number(m[2]) - 1, Number(m[3])));
124
+ return d.toISOString().slice(0, 10) === date;
125
+ }
126
+ /** The id of the occurrence of series `iCalUid` on `date` (`YYYY-MM-DD`) — see the module note. */
127
+ export function occurrenceUid(iCalUid, date) {
128
+ if (!GOID.test(iCalUid))
129
+ throw new Error(`not a meeting id: ${JSON.stringify(iCalUid)}`);
130
+ if (!isOccurrenceDate(date))
131
+ throw new Error(`not a YYYY-MM-DD date: ${JSON.stringify(date)}`);
132
+ const [y, mo, d] = date.split('-').map(Number);
133
+ const hex = [y >> 8, y & 0xff, mo, d].map((b) => b.toString(16).padStart(2, '0')).join('').toUpperCase();
134
+ return iCalUid.slice(0, 32) + hex + iCalUid.slice(40);
135
+ }
136
+ /** The MCPS base for `TEAMS_MCPS_REGION` (default `us`). */
137
+ export function mcpsBase(env = process.env) {
138
+ const region = readEnvVar('TEAMS_MCPS_REGION', { env }) ?? DEFAULT_MCPS_REGION;
139
+ return `https://teams.cloud.microsoft/api/mcps/${encodeURIComponent(region)}`;
140
+ }
141
+ /** The collab-object read URL, built only from vetted parts. */
142
+ export function collabObjectUrl(base, meeting, uid, threadId) {
143
+ if (!GUID.test(meeting.organizerId) || !GUID.test(meeting.tenantId))
144
+ throw new Error('not a meeting organizer');
145
+ if (!GOID.test(uid))
146
+ throw new Error(`not a meeting id: ${JSON.stringify(uid)}`);
147
+ if (!THREAD_ID.test(threadId))
148
+ throw new Error(`not a meeting thread id: ${JSON.stringify(threadId)}`);
149
+ return `${base}/collab/readcollabobject/V2/${meeting.organizerId}@${meeting.tenantId}/${uid}/${threadId}`;
150
+ }
151
+ /** .NET ticks (100 ns since 0001-01-01, as a decimal string) as UTC ISO. */
152
+ export function ticksToIso(ticks) {
153
+ const s = str(ticks);
154
+ if (s === undefined || !/^\d{15,20}$/.test(s))
155
+ return undefined;
156
+ const ms = Number((BigInt(s) - EPOCH_TICKS) / 10000n);
157
+ return Number.isFinite(ms) && ms > 0 ? new Date(ms).toISOString() : undefined;
158
+ }
159
+ function hms(totalSeconds) {
160
+ const s = Math.floor(totalSeconds);
161
+ return `${Math.floor(s / 3600)}:${String(Math.floor((s % 3600) / 60)).padStart(2, '0')}:${String(s % 60).padStart(2, '0')}`;
162
+ }
163
+ /** `00:06:17.5000000` → `0:06:17`. */
164
+ function timespan(v) {
165
+ const m = /^(\d+):(\d{2}):(\d{2})/.exec(str(v) ?? '');
166
+ return m ? hms(Number(m[1]) * 3600 + Number(m[2]) * 60 + Number(m[3])) : undefined;
167
+ }
168
+ /** The resources of a collab-object response, one per id. Never throws on shape. */
169
+ export function parseCollabObject(body) {
170
+ const list = obj(body)?.resources;
171
+ if (!Array.isArray(list))
172
+ return [];
173
+ const byId = new Map();
174
+ for (const raw of list) {
175
+ const r = obj(raw);
176
+ const id = str(r?.id);
177
+ const type = str(r?.type);
178
+ if (r === undefined || id === undefined || type === undefined || byId.has(id))
179
+ continue;
180
+ const location = str(r.location);
181
+ const added = isoOf(r.additionDateTime);
182
+ byId.set(id, {
183
+ id,
184
+ type,
185
+ ...(location !== undefined ? { location } : {}),
186
+ metadata: obj(r.metadata) ?? {},
187
+ ...(added !== undefined ? { added } : {}),
188
+ });
189
+ }
190
+ return [...byId.values()];
191
+ }
192
+ /** Drop the undefined fields of a flat record. */
193
+ function compact(o) {
194
+ return Object.fromEntries(Object.entries(o).filter(([, v]) => v !== undefined));
195
+ }
196
+ /** Group a collab object's resources into the recap's sections. Links are passed on only when https. */
197
+ export function summarizeRecap(resources) {
198
+ const out = {
199
+ recordings: [],
200
+ transcripts: [],
201
+ notes: [],
202
+ attendance_reports: [],
203
+ files: [],
204
+ other: [],
205
+ };
206
+ for (const r of resources) {
207
+ const md = r.metadata;
208
+ switch (r.type) {
209
+ case 'Recording': {
210
+ const started = ticksToIso(md.startTime);
211
+ const ended = ticksToIso(md.endTime);
212
+ const duration = started && ended ? hms((Date.parse(ended) - Date.parse(started)) / 1000) : undefined;
213
+ out.recordings.push(compact({ started, ended, duration, url: httpsUrl(r.location) }));
214
+ break;
215
+ }
216
+ case 'TranscriptV2':
217
+ // Its location is a SharePoint API URL, not something a person opens; webUrl is the recording.
218
+ out.transcripts.push(compact({ started: ticksToIso(md.startTime), duration: timespan(md.duration), url: httpsUrl(md.webUrl) }));
219
+ break;
220
+ case 'transcript':
221
+ out.transcripts.push(compact({ started: isoOf(md.startTime), state: str(md.state) }));
222
+ break;
223
+ case 'notes':
224
+ out.notes.push(compact({ url: httpsUrl(r.location), added: r.added }));
225
+ break;
226
+ case 'AttendanceReport':
227
+ out.attendance_reports.push(compact({ started: ticksToIso(md.startTime), url: httpsUrl(md.webUrl) ?? httpsUrl(r.location) }));
228
+ break;
229
+ case 'MeetingChat':
230
+ case 'MeetingStage':
231
+ out.files.push(compact({
232
+ name: str(md.fileTitle),
233
+ file_type: str(md.fileType),
234
+ app: str(md.appTitle),
235
+ shared_in: r.type === 'MeetingChat' ? 'chat' : 'meeting',
236
+ url: httpsUrl(md.shareUrl) ?? httpsUrl(r.location),
237
+ added: r.added,
238
+ }));
239
+ break;
240
+ case 'AISummary':
241
+ out.ai_summary = compact({ exists: true, generated: r.added });
242
+ break;
243
+ default:
244
+ out.other.push(compact({ type: r.type, url: httpsUrl(r.location), added: r.added }));
245
+ }
246
+ }
247
+ return Object.fromEntries(Object.entries(out).filter(([, v]) => v !== undefined && (!Array.isArray(v) || v.length > 0)));
248
+ }
249
+ export class RecapClient {
250
+ #fetchImpl;
251
+ #base;
252
+ #configError = null;
253
+ #manager;
254
+ constructor(opts = {}) {
255
+ const env = opts.env ?? process.env;
256
+ // A receiver-safe wrapper, never the bare global (see `sharepoint.ts`).
257
+ this.#fetchImpl = opts.fetchImpl ?? ((input, init) => fetch(input, init));
258
+ this.#base = mcpsBase(env);
259
+ this.#manager = createCapturedTokenManager({
260
+ capture: opts.captureToken ?? captureRecapTokenLazily,
261
+ persistence: createRecapTokenCache(env),
262
+ });
263
+ if (parseBoolEnv('TEAMS_DISABLE_FETCHPROXY', { env })) {
264
+ this.#configError = new McpToolError('Meeting recaps are disabled (no token source).', {
265
+ kind: 'no_credential',
266
+ hint: 'Unset TEAMS_DISABLE_FETCHPROXY so a recap token can be captured from a signed-in Teams tab.',
267
+ });
268
+ }
269
+ }
270
+ isConfigured() {
271
+ return this.#configError === null;
272
+ }
273
+ async readCollabObject(meeting, uid, threadId) {
274
+ if (this.#configError)
275
+ throw this.#configError;
276
+ const url = collabObjectUrl(this.#base, meeting, uid, threadId);
277
+ let text = '';
278
+ const res = await this.#manager.withAuth(async (token) => {
279
+ let r;
280
+ try {
281
+ r = await fetchBounded(url, { method: 'GET', headers: { authorization: `Bearer ${token}`, accept: 'application/json' }, redirect: 'error' }, { read: 'text', maxBytes: MAX_RESPONSE_BYTES, service: 'Teams meeting recap', timeoutMs: REQUEST_TIMEOUT_MS, fetchImpl: this.#fetchImpl });
282
+ }
283
+ catch (e) {
284
+ throw describeTransportFailure(e, url, 'Teams meeting recap') ?? e;
285
+ }
286
+ text = r.body;
287
+ return r.res;
288
+ });
289
+ checkStatus(res.status);
290
+ try {
291
+ return parseCollabObject(JSON.parse(text));
292
+ }
293
+ catch {
294
+ // Never echo the body: it holds links to other people's files.
295
+ throw new McpToolError('The Teams meeting-recap service returned a response that is not JSON.', { status: res.status, kind: 'http' });
296
+ }
297
+ }
298
+ }
299
+ /** Map a non-2xx to an `McpToolError` carrying its status. The body is never included. */
300
+ function checkStatus(status) {
301
+ if (status >= 200 && status < 300)
302
+ return;
303
+ if (status === 401) {
304
+ throw new McpToolError('The Teams meeting-recap service rejected the recap token (401) even after a fresh capture.', {
305
+ status,
306
+ kind: 'credential_rejected',
307
+ hint: "Open a meeting chat's Recap tab in a signed-in Teams tab to mint a fresh recap token, then retry.",
308
+ });
309
+ }
310
+ if (status === 403) {
311
+ throw new McpToolError("You are not allowed to read this meeting's recap (403).", { status, kind: 'http' });
312
+ }
313
+ if (status === 429) {
314
+ throw new McpToolError('The Teams meeting-recap service is rate-limiting requests (429).', {
315
+ status,
316
+ kind: 'http',
317
+ hint: 'Wait a minute before retrying.',
318
+ });
319
+ }
320
+ throw new McpToolError(`The Teams meeting-recap service returned HTTP ${status}.`, {
321
+ status,
322
+ kind: 'http',
323
+ ...(status >= 500 ? { hint: 'A Teams-side failure; retry shortly.' } : {}),
324
+ });
325
+ }
package/dist/substrate.js CHANGED
@@ -48,7 +48,8 @@
48
48
  * - A bad token is a 401.
49
49
  *
50
50
  * People lookup (`suggestPeople`, the directory fallback of
51
- * `teams_add_chat_members` / `teams_remove_chat_members`), verified live
51
+ * `teams_add_chat_members` / `teams_remove_chat_members` /
52
+ * `teams_create_group_chat`), verified live
52
53
  * 2026-11-09 with the SAME captured token — no new token or bridge scope:
53
54
  *
54
55
  * POST https://substrate.office.com/search/api/v1/suggestions?scenario=powerbar