@chrischall/microsoft-teams-mcp 0.10.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/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +55 -4
- package/dist/bridge-scope.js +13 -3
- package/dist/bundle.js +543 -109
- package/dist/index.js +6 -1
- package/dist/recap-auth.js +44 -0
- package/dist/recap-token-cache.js +50 -0
- package/dist/recap.js +325 -0
- package/dist/tools/recap.js +122 -0
- package/dist/version.js +1 -1
- package/mint.yaml +9 -0
- package/package.json +1 -1
- package/server.json +16 -2
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
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { McpToolError, toolAnnotations } from '@chrischall/mcp-utils';
|
|
3
|
+
import { isOccurrenceDate, occurrenceUid, parseMeetingInfo, summarizeRecap } from '../recap.js';
|
|
4
|
+
import { AmbiguousConversationError, ambiguousResult, resolveListed } from './conversation.js';
|
|
5
|
+
import { wrapApiError } from './errors.js';
|
|
6
|
+
import { workMeta } from './hints.js';
|
|
7
|
+
import { untrustedResult, UNTRUSTED_DESCRIPTION_SUFFIX } from './untrusted.js';
|
|
8
|
+
/** Messages read for the days a recurring meeting met (newest first). */
|
|
9
|
+
export const MAX_SCAN = 1000;
|
|
10
|
+
/** Occurrences tried, newest first, for one with a recap. */
|
|
11
|
+
export const MAX_PROBE = 5;
|
|
12
|
+
/** Other occurrence days listed beside the one returned. */
|
|
13
|
+
const MAX_OTHERS = 20;
|
|
14
|
+
/** Messages that mark a meeting having happened: a call starting or ending, or a recording. */
|
|
15
|
+
const CALL_TYPES = new Set(['Event/Call', 'RichText/Media_CallRecording', 'RichText/Media_CallTranscript']);
|
|
16
|
+
/** The UTC days of the calls in `messages`, newest first, one each. */
|
|
17
|
+
export function callDays(messages) {
|
|
18
|
+
const days = new Map();
|
|
19
|
+
for (const m of messages) {
|
|
20
|
+
if (!CALL_TYPES.has(m.messagetype ?? ''))
|
|
21
|
+
continue;
|
|
22
|
+
const ms = Date.parse(m.composetime ?? m.originalarrivaltime ?? '') || Number(m.id);
|
|
23
|
+
if (!Number.isFinite(ms) || ms <= 0)
|
|
24
|
+
continue;
|
|
25
|
+
const day = new Date(ms).toISOString().slice(0, 10);
|
|
26
|
+
days.set(day, Math.max(days.get(day) ?? 0, ms));
|
|
27
|
+
}
|
|
28
|
+
return [...days.entries()].sort((a, b) => b[1] - a[1]).map(([d]) => d);
|
|
29
|
+
}
|
|
30
|
+
const isEmpty = (r) => Object.keys(r).length === 0;
|
|
31
|
+
function hintFor(recap, occurrence, recurring, searched) {
|
|
32
|
+
const parts = [];
|
|
33
|
+
if (isEmpty(recap)) {
|
|
34
|
+
parts.push(recurring && occurrence === undefined && !searched
|
|
35
|
+
? 'No call was found in this chat to pick an occurrence from: pass date (YYYY-MM-DD) for the occurrence you want.'
|
|
36
|
+
: `Nothing was recorded or shared for ${occurrence !== undefined ? `the ${occurrence} occurrence` : 'this meeting'}: no recording, transcript, notes or files.`);
|
|
37
|
+
}
|
|
38
|
+
if (recap.transcripts !== undefined)
|
|
39
|
+
parts.push('teams_get_transcript reads a recording\'s transcript text from this same chat.');
|
|
40
|
+
if (recap.ai_summary !== undefined) {
|
|
41
|
+
parts.push("Teams made AI notes (Intelligent Recap) for this meeting; they are shown only in Teams, to licensed users, and are not read here.");
|
|
42
|
+
}
|
|
43
|
+
return parts.length > 0 ? parts.join(' ') : undefined;
|
|
44
|
+
}
|
|
45
|
+
export function registerRecapTools(server, { chatsvc, recap }) {
|
|
46
|
+
server.registerTool('teams_get_meeting_recap', {
|
|
47
|
+
title: 'Get a Teams meeting recap',
|
|
48
|
+
description: "Get what a Teams meeting's Recap tab shows, from its meeting chat (by id or by name, as teams_list_conversations " +
|
|
49
|
+
'lists it): recordings (start, end, duration, play link), transcripts, the meeting notes (Loop) link, attendance ' +
|
|
50
|
+
'reports, files shared in the meeting chat or on stage (e.g. a whiteboard), and whether Teams made AI notes ' +
|
|
51
|
+
'(their text is not read). A recurring meeting has one recap per occurrence: pass date (YYYY-MM-DD) for one, else ' +
|
|
52
|
+
`the newest day the chat shows a call on that has a recap is returned (up to ${MAX_PROBE} tried), with series ` +
|
|
53
|
+
'(what belongs to the whole series) and other_occurrences (other call days, newest first). For the transcript text ' +
|
|
54
|
+
'use teams_get_transcript. Uses its own token, captured when a Recap tab is opened in Teams. Does not mark anything read.' +
|
|
55
|
+
UNTRUSTED_DESCRIPTION_SUFFIX,
|
|
56
|
+
_meta: workMeta('lookup', {
|
|
57
|
+
aliases: ['recap', 'meeting recap', 'meeting notes', 'attendance report', 'attendance', 'recording link', 'intelligent recap', 'ai notes'],
|
|
58
|
+
}),
|
|
59
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
60
|
+
inputSchema: {
|
|
61
|
+
conversation: z.string().min(1).describe("The meeting chat's id, or a case-insensitive substring of its title."),
|
|
62
|
+
date: z
|
|
63
|
+
.string()
|
|
64
|
+
.refine(isOccurrenceDate, 'date must be a real day, YYYY-MM-DD')
|
|
65
|
+
.optional()
|
|
66
|
+
.describe('For a recurring meeting: the occurrence, YYYY-MM-DD (the UTC day it met). Default: the newest with a recap.'),
|
|
67
|
+
},
|
|
68
|
+
}, async ({ conversation, date }) => {
|
|
69
|
+
try {
|
|
70
|
+
const [raw, me] = await Promise.all([chatsvc.listConversations(), chatsvc.meMri()]);
|
|
71
|
+
const summary = await resolveListed(chatsvc, raw, me, conversation, 'read the recap of');
|
|
72
|
+
const meeting = parseMeetingInfo(await chatsvc.getThread(summary.id));
|
|
73
|
+
if (meeting === undefined) {
|
|
74
|
+
throw new McpToolError(`"${summary.title}" is not a meeting chat: it has no scheduled meeting to recap.`, {
|
|
75
|
+
hint: "Pass a meeting's own chat (teams_list_conversations lists them with type \"meeting\").",
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
const read = async (uid) => summarizeRecap(await recap.readCollabObject(meeting, uid, summary.id));
|
|
79
|
+
const base = {
|
|
80
|
+
conversation: summary.id,
|
|
81
|
+
title: summary.title,
|
|
82
|
+
meeting: {
|
|
83
|
+
...(meeting.subject !== undefined ? { subject: meeting.subject } : {}),
|
|
84
|
+
recurring: meeting.recurring,
|
|
85
|
+
...(meeting.joinUrl !== undefined ? { join_url: meeting.joinUrl } : {}),
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
if (!meeting.recurring) {
|
|
89
|
+
const r = await read(meeting.iCalUid);
|
|
90
|
+
const hint = hintFor(r, undefined, false, true);
|
|
91
|
+
return untrustedResult({ ...base, recap: r, ...(hint !== undefined ? { hint } : {}) });
|
|
92
|
+
}
|
|
93
|
+
const days = date !== undefined ? [date] : callDays(await chatsvc.getMessages(summary.id, { max: MAX_SCAN }));
|
|
94
|
+
const series = await read(meeting.iCalUid);
|
|
95
|
+
let chosen;
|
|
96
|
+
for (const day of days.slice(0, MAX_PROBE)) {
|
|
97
|
+
const r = await read(occurrenceUid(meeting.iCalUid, day));
|
|
98
|
+
chosen ??= { day, recap: r };
|
|
99
|
+
if (!isEmpty(r)) {
|
|
100
|
+
chosen = { day, recap: r };
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const r = chosen?.recap ?? {};
|
|
105
|
+
const others = days.filter((d) => d !== chosen?.day).slice(0, MAX_OTHERS);
|
|
106
|
+
const hint = hintFor(r, chosen?.day, true, days.length > 0);
|
|
107
|
+
return untrustedResult({
|
|
108
|
+
...base,
|
|
109
|
+
...(chosen !== undefined ? { occurrence: chosen.day } : {}),
|
|
110
|
+
recap: r,
|
|
111
|
+
...(!isEmpty(series) ? { series } : {}),
|
|
112
|
+
...(others.length > 0 ? { other_occurrences: others } : {}),
|
|
113
|
+
...(hint !== undefined ? { hint } : {}),
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
catch (err) {
|
|
117
|
+
if (err instanceof AmbiguousConversationError)
|
|
118
|
+
return untrustedResult(ambiguousResult(err));
|
|
119
|
+
throw wrapApiError(err, 'get the meeting recap');
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
package/dist/version.js
CHANGED
package/mint.yaml
CHANGED
|
@@ -82,6 +82,15 @@ env:
|
|
|
82
82
|
help: >-
|
|
83
83
|
Path to the cached Substrate search token file. Defaults to
|
|
84
84
|
~/.microsoft-teams-mcp/substrate-token.json.
|
|
85
|
+
- name: TEAMS_RECAP_TOKEN_FILE
|
|
86
|
+
required: false
|
|
87
|
+
help: >-
|
|
88
|
+
Path to the cached meeting-recap token file. Defaults to
|
|
89
|
+
~/.microsoft-teams-mcp/recap-token.json.
|
|
90
|
+
- name: TEAMS_MCPS_REGION
|
|
91
|
+
required: false
|
|
92
|
+
help: >-
|
|
93
|
+
Meeting-recap region in the API path. Defaults to us.
|
|
85
94
|
- name: TEAMS_SHAREPOINT_TOKEN_FILE
|
|
86
95
|
required: false
|
|
87
96
|
help: >-
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrischall/microsoft-teams-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.0",
|
|
4
4
|
"mcpName": "io.github.chrischall/microsoft-teams-mcp",
|
|
5
5
|
"description": "Microsoft Teams MCP server for Claude — developed and maintained by AI (Claude Code)",
|
|
6
6
|
"author": "Claude Code (AI) <https://www.anthropic.com/claude>",
|
package/server.json
CHANGED
|
@@ -6,12 +6,12 @@
|
|
|
6
6
|
"url": "https://github.com/chrischall/microsoft-teams-mcp",
|
|
7
7
|
"source": "github"
|
|
8
8
|
},
|
|
9
|
-
"version": "0.
|
|
9
|
+
"version": "0.11.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@chrischall/microsoft-teams-mcp",
|
|
14
|
-
"version": "0.
|
|
14
|
+
"version": "0.11.0",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|
|
@@ -93,6 +93,20 @@
|
|
|
93
93
|
"format": "string",
|
|
94
94
|
"isSecret": false
|
|
95
95
|
},
|
|
96
|
+
{
|
|
97
|
+
"name": "TEAMS_RECAP_TOKEN_FILE",
|
|
98
|
+
"description": "Where the captured meeting-recap token is cached. Defaults to ~/.microsoft-teams-mcp/recap-token.json.",
|
|
99
|
+
"isRequired": false,
|
|
100
|
+
"format": "string",
|
|
101
|
+
"isSecret": false
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
"name": "TEAMS_MCPS_REGION",
|
|
105
|
+
"description": "The region in the Teams meeting-recap API path (teams.cloud.microsoft/api/mcps/<region>). Defaults to us. Leave blank unless your tenant lives elsewhere.",
|
|
106
|
+
"isRequired": false,
|
|
107
|
+
"format": "string",
|
|
108
|
+
"isSecret": false
|
|
109
|
+
},
|
|
96
110
|
{
|
|
97
111
|
"name": "TEAMS_SHAREPOINT_TOKEN_FILE",
|
|
98
112
|
"description": "Where the captured SharePoint tokens are cached. Defaults to ~/.microsoft-teams-mcp/sharepoint-tokens.json.",
|