@chrischall/microsoft-teams-mcp 0.6.1 → 0.7.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 +126 -66
- package/dist/auth-fetchproxy.js +25 -63
- package/dist/bundle.js +2185 -661
- package/dist/capture-window.js +4 -19
- package/dist/chatsvc.js +19 -81
- package/dist/index.js +2 -0
- package/dist/network-error.js +20 -149
- package/dist/sharepoint-auth.js +19 -64
- package/dist/sharepoint-token-cache.js +2 -12
- package/dist/sharepoint.js +7 -33
- package/dist/substrate-auth.js +14 -47
- package/dist/substrate-token-cache.js +2 -12
- package/dist/substrate.js +7 -23
- package/dist/token-cache.js +2 -11
- package/dist/tools/activity.js +34 -4
- package/dist/tools/attachment.js +24 -11
- package/dist/tools/changes.js +10 -9
- package/dist/tools/channels.js +2 -2
- package/dist/tools/chat-search.js +1 -1
- package/dist/tools/chat.js +3 -3
- package/dist/tools/conversation.js +17 -12
- package/dist/tools/cursor.js +6 -6
- package/dist/tools/export-attachments.js +114 -0
- package/dist/tools/export-format.js +101 -0
- package/dist/tools/export.js +550 -0
- package/dist/tools/format.js +3 -3
- package/dist/tools/from.js +1 -1
- package/dist/tools/limit.js +1 -1
- package/dist/tools/listing.js +9 -8
- package/dist/tools/markread.js +14 -9
- package/dist/tools/react.js +10 -11
- package/dist/tools/search.js +5 -4
- package/dist/tools/send.js +17 -34
- package/dist/tools/titles.js +103 -20
- package/dist/tools/unread.js +7 -6
- package/dist/version.js +1 -1
- package/mint.yaml +18 -0
- package/package.json +6 -2
- package/server.json +9 -2
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "MCP server for Microsoft Teams — read any chat or channel, your unread messages, and their attachments, and send messages and reactions (each confirmed first)",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.7.0"
|
|
11
11
|
},
|
|
12
12
|
"plugins": [
|
|
13
13
|
{
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"displayName": "Microsoft Teams",
|
|
16
16
|
"source": "./",
|
|
17
17
|
"description": "MCP server for Microsoft Teams — read any chat or channel, your unread messages, and their attachments, and send messages and reactions (each confirmed first), via your signed-in browser session",
|
|
18
|
-
"version": "0.
|
|
18
|
+
"version": "0.7.0",
|
|
19
19
|
"author": {
|
|
20
20
|
"name": "Chris Hall"
|
|
21
21
|
},
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "microsoft-teams-mcp",
|
|
3
3
|
"displayName": "Microsoft Teams",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.7.0",
|
|
5
5
|
"description": "Microsoft Teams for Claude — read any chat or channel, your unread messages, and their attachments, and send messages and reactions (each confirmed first), using your signed-in browser session",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Chris Hall",
|
package/README.md
CHANGED
|
@@ -27,15 +27,15 @@ ones the sidebar shows. To capture a token, an idle tab is not enough: click
|
|
|
27
27
|
into any chat so Teams calls its chat service.
|
|
28
28
|
|
|
29
29
|
**The Activity feed comes from the same API.** It is a chat-service
|
|
30
|
-
conversation of its own (`48:notifications`), so `
|
|
30
|
+
conversation of its own (`48:notifications`), so `teams_list_activity` reads
|
|
31
31
|
it like any chat — no Activity view (or any view) needs to be open, and
|
|
32
32
|
nothing reads the page. The bridge is used for one thing only: capturing the
|
|
33
33
|
token.
|
|
34
34
|
|
|
35
35
|
By default nothing here marks anything read. Reading a chat through this
|
|
36
36
|
server leaves your Teams unread badges exactly as they were — unless you ask
|
|
37
|
-
for it: `teams_mark_read`, or `mark_read: true` on `
|
|
38
|
-
/ `
|
|
37
|
+
for it: `teams_mark_read`, or `mark_read: true` on `teams_list_messages`
|
|
38
|
+
/ `teams_list_unread_messages`, moves your read marker forward. The writes —
|
|
39
39
|
`teams_send_message`, `teams_react` and marking read — go through the same
|
|
40
40
|
chat-service API and change nothing until you confirm (see
|
|
41
41
|
[Writes](#writes)).
|
|
@@ -169,14 +169,15 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
169
169
|
| `TEAMS_TOKEN_FILE` | Where the captured token is cached. Defaults to `~/.microsoft-teams-mcp/token.json`. |
|
|
170
170
|
| `TEAMS_SUBSTRATE_TOKEN_FILE` | Where the captured Substrate search token is cached. Defaults to `~/.microsoft-teams-mcp/substrate-token.json`. `TEAMS_TOKEN_CACHE=false` keeps it in memory too. |
|
|
171
171
|
| `TEAMS_SHAREPOINT_TOKEN_FILE` | Where the captured SharePoint tokens (one per host, used to download shared files) are cached. Defaults to `~/.microsoft-teams-mcp/sharepoint-tokens.json`. `TEAMS_TOKEN_CACHE=false` keeps them in memory too. |
|
|
172
|
-
| `TEAMS_TIME_ZONE` | Default IANA time zone (e.g. `America/New_York`) for the `tz` argument of `
|
|
172
|
+
| `TEAMS_TIME_ZONE` | Default IANA time zone (e.g. `America/New_York`) for the `tz` argument of `teams_list_messages` and `teams_list_unread_messages`: each message then carries `time_local` (ISO 8601 with offset) next to its UTC `time`. Unset means no `time_local` unless `tz` is passed; a name `Intl` does not know is reported as an error. |
|
|
173
|
+
| `TEAMS_OUTPUT_DIR` | Folder `teams_export_messages` writes exports into (each export gets its own timestamped subfolder). Defaults to `~/Downloads/microsoft-teams-mcp`. When set, a per-call `dest` must lie inside it; when unset, `dest` must be under `~/Downloads`, `~/Documents` or `~/Desktop`. |
|
|
173
174
|
| `TEAMS_WS_PORT` | fetchproxy concentrator port. Defaults to `37149`, the fleet-wide shared port. |
|
|
174
175
|
| `FETCHPROXY_WS_HOST` | Bind interface for the bridge (default `127.0.0.1`; a literal IP only, anything else is ignored). Keep on loopback — it exists for ONE topology: a hosted child in its own network namespace. |
|
|
175
176
|
| `FETCHPROXY_IDENTITY_DIR` | Where to store the long-term fetchproxy identity keypair (default `~/.fetchproxy/identity/`; an absolute path only, anything else is ignored). Exists for a host that runs a separate child per caller, so they can share one identity. |
|
|
176
177
|
|
|
177
178
|
## Tools
|
|
178
179
|
|
|
179
|
-
- `
|
|
180
|
+
- `teams_list_conversations` — every chat you are in (1:1, group and meeting chats,
|
|
180
181
|
not just the visible sidebar, plus your `48:notes` self-chat as kind
|
|
181
182
|
`self` when Teams lists it), favorites and pinned chats first, then most
|
|
182
183
|
recent activity first: id, kind,
|
|
@@ -193,13 +194,18 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
193
194
|
recent first, ignoring favorites and pinned) or `title` (alphabetical,
|
|
194
195
|
case-insensitive — this titles every untitled chat in the listing before
|
|
195
196
|
`limit` applies, so it reads more than the other orders). A group chat with no topic is titled after
|
|
196
|
-
who is in it — `Group chat: <
|
|
197
|
-
|
|
198
|
-
`participants` — rather than after whoever posted last,
|
|
199
|
-
share a last sender stay distinguishable
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
197
|
+
who is in it — `Group chat: <the first three recent senders other than
|
|
198
|
+
you, sorted by name>` plus `+N` for more, with every recent sender in
|
|
199
|
+
`participants` in the same order — rather than after whoever posted last,
|
|
200
|
+
so chats that share a last sender stay distinguishable, and a chat keeps
|
|
201
|
+
its title when someone different posts next. This server has no member-list
|
|
202
|
+
call, so this reads up to 30 recent messages (one small page) of each such
|
|
203
|
+
chat returned (four at a time, cached until a new message arrives) and
|
|
204
|
+
names the people who wrote in them; the title changes only when that set
|
|
205
|
+
of people does. If the read fails, the chat keeps its last-sender title.
|
|
206
|
+
Every other tool that returns a conversation names it the same way: the
|
|
207
|
+
Activity feed's `where`, an attachment's caption, search hits, read errors,
|
|
208
|
+
and the conversation a send, reaction or mark-read targets. A 1:1 is titled by the
|
|
203
209
|
other person (its id names them) and carries them as its one
|
|
204
210
|
`participants` entry — read from their recent messages when you sent the
|
|
205
211
|
last one, `(1:1 chat)` if they wrote nothing recently. `query` matches such
|
|
@@ -226,16 +232,16 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
226
232
|
not flagged (verified live 2026-10-10) — the flags mostly reflect favorited
|
|
227
233
|
channels and pinned conversations. A chat you muted in Teams carries
|
|
228
234
|
`muted: true`.
|
|
229
|
-
- `
|
|
235
|
+
- `teams_list_channels` — every channel you are in, by team then
|
|
230
236
|
title, with the same fields — favorite and pinned channels first, flagged
|
|
231
|
-
as in `
|
|
237
|
+
as in `teams_list_conversations`. Channels you have hidden in Teams are listed
|
|
232
238
|
after the rest with `hidden: true`, and left out of `unread_only` unless
|
|
233
239
|
`include_hidden` is set. `unread_only`, `include_hidden`, `since_days`
|
|
234
240
|
(with `unread_only`; default 14), `query` (channel or team name, or the
|
|
235
241
|
last-message preview; each match carries `match_reason`, as in
|
|
236
|
-
`
|
|
242
|
+
`teams_list_conversations`) and
|
|
237
243
|
`limit` (default 50, max 500).
|
|
238
|
-
- `
|
|
244
|
+
- `teams_list_messages` — read any chat or channel by id or name,
|
|
239
245
|
oldest first: sender, time (UTC, ISO 8601), text, subject, edited/deleted
|
|
240
246
|
flags and attachments. A channel comes back as threads (root post + replies).
|
|
241
247
|
A thread whose root post is older than the window (a reply came in after
|
|
@@ -269,7 +275,7 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
269
275
|
returned message's id, or the `after_message_id` you passed when nothing
|
|
270
276
|
is new — so passing it back as `after_message_id` reads only what arrived
|
|
271
277
|
since. `after_message_id` takes message ids only: to read what
|
|
272
|
-
`
|
|
278
|
+
`teams_list_changed_conversations` counted, pass that row's `after_message_id`, not its
|
|
273
279
|
`next_cursor`. See [Cursors](#cursors-only-what-is-new). `from` pages
|
|
274
280
|
oldest first from a UTC time instead — see
|
|
275
281
|
[Paging from a time](#paging-from-a-time).
|
|
@@ -287,7 +293,8 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
287
293
|
a time; an ambiguous name takes its place in `conversations` as the same
|
|
288
294
|
`{ambiguous: true, query, match_count, candidates, hint}` object a single
|
|
289
295
|
read returns, one that cannot be resolved or read is listed in `errors`
|
|
290
|
-
with its reason
|
|
296
|
+
with its reason (and, once it resolved, its `id`, `title`, `kind`, `team`
|
|
297
|
+
and `participants`), and the rest still come back. A single string returns
|
|
291
298
|
exactly the shape above.
|
|
292
299
|
By default it does not mark anything read; `mark_read: true` also moves
|
|
293
300
|
your read marker up to the newest message returned (never backwards;
|
|
@@ -301,13 +308,13 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
301
308
|
`marked_read: { skipped: "truncated" | "since", hint }` (a `limit` that cut
|
|
302
309
|
only messages you had already read still marks). An empty read, or an
|
|
303
310
|
`after_message_id` with nothing new, marks nothing (`marked_read: false`).
|
|
304
|
-
- `
|
|
311
|
+
- `teams_list_unread_messages` — every unread message across your chats and channels,
|
|
305
312
|
grouped by conversation, most recent first (or, with `from`, one
|
|
306
313
|
oldest-first list across them all — see
|
|
307
314
|
[Paging from a time](#paging-from-a-time)). Filter by `kinds` (`chat`,
|
|
308
315
|
`channel`, `meeting`, `oneOnOne`) or `query` (title, channel or team
|
|
309
316
|
name, an untitled chat's participant name, or the last-message preview —
|
|
310
|
-
each conversation then carries `match_reason`, as in `
|
|
317
|
+
each conversation then carries `match_reason`, as in `teams_list_conversations`);
|
|
311
318
|
`per_conversation_limit`
|
|
312
319
|
(default 50) and `max_conversations` (default 20 returned with their
|
|
313
320
|
messages — the rest are named, with their `unread_count`, in
|
|
@@ -317,7 +324,7 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
317
324
|
conversations with unread messages from the last `since_days` (default 14,
|
|
318
325
|
max 3650) are returned; older ones are counted in `older_unread_skipped`,
|
|
319
326
|
and `older_unread: true` also lists them (see below). An untitled group chat or 1:1 is titled after
|
|
320
|
-
its participants, as in `
|
|
327
|
+
its participants, as in `teams_list_conversations` — in `conversations`, in
|
|
321
328
|
`more_unread_conversations` and in `errors`. By default it does not mark
|
|
322
329
|
anything read; `mark_read: true` also moves the read marker of each
|
|
323
330
|
conversation returned with its messages (not `more_unread_conversations`)
|
|
@@ -329,10 +336,10 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
329
336
|
reports `marked_read: { skipped: "truncated", hint }`, and `outside_window`
|
|
330
337
|
roots never count. `tz` (default
|
|
331
338
|
`TEAMS_TIME_ZONE`) adds each message's `time_local`, as in
|
|
332
|
-
`
|
|
339
|
+
`teams_list_messages`. A channel's unread replies come grouped under
|
|
333
340
|
their root post; a root you had already read is fetched and marked
|
|
334
341
|
`outside_window: true` (not unread, not counted), up to 25 per call as in
|
|
335
|
-
`
|
|
342
|
+
`teams_list_messages`, else `{ id, missing: true }`. `cursors` — `{ "<conversation id>": "<message id>" }`
|
|
336
343
|
— returns, per conversation, only unread messages newer than its cursor
|
|
337
344
|
(each read stops at the later of the read marker and the cursor; a
|
|
338
345
|
conversation with nothing past its cursor is left out). Each returned
|
|
@@ -340,34 +347,34 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
340
347
|
the cursors you passed, updated with every returned conversation's
|
|
341
348
|
`next_cursor` — pass it back as `cursors` next time.
|
|
342
349
|
`format` (`full`, `compact` or `summary`) trims each conversation as in
|
|
343
|
-
`
|
|
350
|
+
`teams_list_messages`; every format keeps the conversation `id`,
|
|
344
351
|
`unread_count` and `next_cursor`.
|
|
345
|
-
- `
|
|
352
|
+
- `teams_list_changed_conversations` — which chats and channels got new messages since a
|
|
346
353
|
cursor: counts, not messages. Each changed conversation comes back with its
|
|
347
354
|
summary, `new_message_count` (real messages only — call recordings and other
|
|
348
355
|
system events, and deleted messages, are not counted),
|
|
349
356
|
`new_from_others_count`, `newest_time` and, for a channel, `threads`: one
|
|
350
357
|
`{ root_id, new_root, new_reply_count }` per thread the new messages landed
|
|
351
358
|
in, including a thread whose root post is older than the cursor, and
|
|
352
|
-
`after_message_id` — the value to pass to `
|
|
359
|
+
`after_message_id` — the value to pass to `teams_list_messages` as
|
|
353
360
|
`after_message_id` to read exactly the messages counted (a message id is
|
|
354
361
|
its arrival ms, so this is the cursor time written as an id). Without
|
|
355
362
|
`cursor` it looks back 24 hours. `next_cursor` is an opaque token (base64url
|
|
356
363
|
of `{"t": <epoch ms>}`; `cursor` also takes a plain ISO 8601 time) — pass it
|
|
357
364
|
back to see only what arrived since. It is at-least-once: a conversation can
|
|
358
365
|
come back twice, but none is skipped, and it stays put when a read failed
|
|
359
|
-
(`errors`). `kinds` and `include_hidden` filter as in `
|
|
366
|
+
(`errors`). `kinds` and `include_hidden` filter as in `teams_list_unread_messages` —
|
|
360
367
|
use the same ones with a cursor as the call that returned it; `limit`
|
|
361
368
|
(default 50, max 200) caps the conversations returned, the rest are named in
|
|
362
369
|
`more_conversations` (each with its `after_message_id` too). Then read what
|
|
363
|
-
changed with `
|
|
370
|
+
changed with `teams_list_messages`, handing on the row's
|
|
364
371
|
`after_message_id` — **not** `next_cursor`, which is a time token that only
|
|
365
|
-
`
|
|
366
|
-
`
|
|
372
|
+
`teams_list_changed_conversations` accepts (`teams_list_messages` rejects it, and
|
|
373
|
+
`teams_list_changed_conversations` rejects a message id):
|
|
367
374
|
|
|
368
375
|
```jsonc
|
|
369
376
|
// first call: the last 24 hours
|
|
370
|
-
|
|
377
|
+
teams_list_changed_conversations({})
|
|
371
378
|
// → { since, total_new_messages: 5, conversations: [
|
|
372
379
|
// { conversation: { id: "19:…@thread.tacv2", kind: "channel", title: "Design", … },
|
|
373
380
|
// new_message_count: 3, new_from_others_count: 3, newest_time: "…",
|
|
@@ -375,9 +382,9 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
375
382
|
// threads: [{ root_id: "1791803726629", new_root: false, new_reply_count: 2 }, …] }, … ],
|
|
376
383
|
// next_cursor: "eyJ0IjoxNzkxODE1MjAxMzYxfQ", next_cursor_time: "…", fetched_at }
|
|
377
384
|
// read the messages it counted in one conversation: hand on the row's after_message_id
|
|
378
|
-
|
|
379
|
-
// later: only what arrived since — next_cursor goes back to
|
|
380
|
-
|
|
385
|
+
teams_list_messages({ conversation: "19:…@thread.tacv2", after_message_id: "1791728801361" })
|
|
386
|
+
// later: only what arrived since — next_cursor goes back to teams_list_changed_conversations only
|
|
387
|
+
teams_list_changed_conversations({ cursor: "eyJ0IjoxNzkxODE1MjAxMzYxfQ" })
|
|
381
388
|
```
|
|
382
389
|
|
|
383
390
|
A channel reply moves only the listing's `lastUpdatedMessageId` (its
|
|
@@ -390,8 +397,8 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
390
397
|
channels, newest first: each hit names its conversation (id, title, kind,
|
|
391
398
|
team) and carries the message's id, ISO-8601 time, sender, `fromMe` (scan
|
|
392
399
|
only), plain text, subject and `replyTo` (a channel reply's root) — read it in context
|
|
393
|
-
with `
|
|
394
|
-
channel (id or name, as in `
|
|
400
|
+
with `teams_list_messages`. `conversation` narrows to one chat or
|
|
401
|
+
channel (id or name, as in `teams_list_messages`), `from` to senders
|
|
395
402
|
whose display name contains it, `since` (ISO 8601; default the last 30 days)
|
|
396
403
|
sets how far back to look, `limit` caps the hits (default 25, max 200;
|
|
397
404
|
`total_hits` and `truncated` say when there were more). `source` says which
|
|
@@ -426,19 +433,72 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
426
433
|
SharePoint token captured per SharePoint host, so the first file from a given
|
|
427
434
|
host may need [opening once in Teams](#sharepoint-file-download) to mint it; a
|
|
428
435
|
file your account cannot open, or one that could not be fetched, comes back as
|
|
429
|
-
metadata and its open link instead of failing.
|
|
430
|
-
|
|
436
|
+
metadata and its open link instead of failing. The caption names the
|
|
437
|
+
conversation beside its id (`title`, plus `participants` for an untitled
|
|
438
|
+
chat), titled as `teams_list_conversations` titles it.
|
|
439
|
+
- `teams_list_activity` — the Activity feed (the bell icon), newest first:
|
|
431
440
|
mentions (including @team / @everyone), reactions, replies, meeting
|
|
432
441
|
notices and missed calls across every chat and channel. Each row has its
|
|
433
442
|
time (ISO 8601), `kind` (`mention`, `reaction`, `reply`, `meeting`, `call`
|
|
434
443
|
or `other`) with Teams' raw type/subtype, whether you have seen it, who
|
|
435
|
-
did it, where (`conversation_id`, title
|
|
436
|
-
|
|
437
|
-
|
|
444
|
+
did it, where (`conversation_id`, `title`, `type`, and `team` /
|
|
445
|
+
`participants` when known), the `message_id` and a plain-text preview. The
|
|
446
|
+
feed carries no name for an untitled group chat or 1:1, so `title` is
|
|
447
|
+
taken from the conversations listing and titled as `teams_list_conversations` titles
|
|
448
|
+
it (one listing read plus cached title reads for the rows returned; if that
|
|
449
|
+
fails the feed's own topic stands in) — pass `where.conversation_id` to
|
|
450
|
+
`teams_list_messages` to read it in context. Filter with
|
|
438
451
|
`unread_only`, `kinds` and `since_days` (default 14, max 3650); `limit`
|
|
439
452
|
(default 50, max 200). Read from the chat service, so the Activity view
|
|
440
453
|
does not need to be open; it never marks anything read (`teams_mark_read`
|
|
441
454
|
marks chats and channels read, not the Activity feed).
|
|
455
|
+
- `teams_export_messages` — bulk-export chats and channels to files, so thousands of
|
|
456
|
+
messages can be archived or searched with shell tools without any of them
|
|
457
|
+
entering the conversation: the result is only a manifest (where the files
|
|
458
|
+
are, each file's size and record count, counts, the time span, errors,
|
|
459
|
+
`has_more` / `cursor`), never a message. One file per conversation, named
|
|
460
|
+
after it (`<title>-<8-char id hash>.jsonl`; an untitled group chat is named
|
|
461
|
+
after its participants), plus `manifest.json`. JSONL by default — a header
|
|
462
|
+
record (`{"_export": {...}}`: source, account, time, arguments, the
|
|
463
|
+
conversation, and a note that the content is untrusted third-party text),
|
|
464
|
+
then one record per message, oldest first, each carrying its conversation's
|
|
465
|
+
`id`, `kind`, `title`, `team` (channels) and `participants` (chats: the
|
|
466
|
+
people seen writing, other than you) — or `format: "markdown"` for readable
|
|
467
|
+
transcripts, channels threaded under their root posts. `conversations`
|
|
468
|
+
(ids or names, one or an array; omit for every conversation), `kinds`
|
|
469
|
+
(`chat`, `channel`, `meeting`), `since` / `until` (by arrival; default all
|
|
470
|
+
history), `tz`. Each call stops at `max_items` messages (default 5000, max
|
|
471
|
+
50000) or `budget_seconds` (default 90, max 600); with `has_more: true`, pass
|
|
472
|
+
the `cursor` back (alone, or with `max_items` / `budget_seconds`) to continue
|
|
473
|
+
the SAME export — on disk into the same folder, a conversation split across
|
|
474
|
+
calls continuing in `<name>.part-0002.jsonl` beside its first file (and
|
|
475
|
+
`manifest.part-0002.json`). The budget is checked between conversations
|
|
476
|
+
and between pages of a read: a long read past it is dropped and redone by
|
|
477
|
+
the next call (except the first conversation of a call, which always
|
|
478
|
+
finishes, so every call makes progress). Conversations are exported in id
|
|
479
|
+
order; the cursor normally lists the ones still to do, but when that list is
|
|
480
|
+
too long for a cursor it holds only the id to go on from, and the next call
|
|
481
|
+
re-lists conversations from there — so a conversation that first appears
|
|
482
|
+
between calls with an id before that point is not in this export. A
|
|
483
|
+
rejected credential, rate limiting that
|
|
484
|
+
outlasts three backed-off retries, or a Teams-side failure stops the call
|
|
485
|
+
early with a cursor, keeping what was written (re-authenticate and resume);
|
|
486
|
+
a conversation that cannot be read (403/404) is listed in `errors` and
|
|
487
|
+
skipped. Where the files go depends on the install: a local (stdio) install
|
|
488
|
+
writes a fresh folder under `dest` → `TEAMS_OUTPUT_DIR` →
|
|
489
|
+
`~/Downloads/microsoft-teams-mcp` and returns **absolute local paths**; a
|
|
490
|
+
hosted install (mcp-host sets `MCP_BLOB_BASE_URL` and
|
|
491
|
+
`MCP_BLOB_SIGNING_KEY`) uploads one zip per call and returns a signed
|
|
492
|
+
download link that expires after an hour (`url_expires_at`). With
|
|
493
|
+
`attachments: true` it also saves each message's inline images and shared
|
|
494
|
+
files (SharePoint, up to 25 MB each; four downloads at a time) under
|
|
495
|
+
`attachments/<8-char conversation hash>/<message id>-<name>` in the same
|
|
496
|
+
folder or zip, and each message's record lists them by that relative path
|
|
497
|
+
(Markdown transcripts link them); an attachment that cannot be fetched — a
|
|
498
|
+
file your account cannot open, a SharePoint host with no token yet, one too
|
|
499
|
+
large — is listed with `skipped` and the reason instead, and never fails the
|
|
500
|
+
export (`counts.attachments` / `counts.attachments_skipped`). Never marks
|
|
501
|
+
anything read.
|
|
442
502
|
- `teams_healthcheck` — resolves the token the way every tool does
|
|
443
503
|
(capturing one on a cold start) and probes the chat service with one
|
|
444
504
|
conversations listing. Reports where the token came from and when it
|
|
@@ -471,7 +531,7 @@ Everything is optional — by default the token is captured from your browser.
|
|
|
471
531
|
already at or past the target, nothing is written (no confirmation is
|
|
472
532
|
asked) and `status` is `already_read`. Only you see your read marker.
|
|
473
533
|
|
|
474
|
-
`
|
|
534
|
+
`teams_list_messages` and `teams_list_unread_messages` also write when — and only
|
|
475
535
|
when — you pass `mark_read: true` (see above). Every other tool is
|
|
476
536
|
read-only, and nothing marks anything read unless you ask it to.
|
|
477
537
|
|
|
@@ -486,7 +546,7 @@ mentions, the quoted message, the reaction, or the message your read marker
|
|
|
486
546
|
moves to and where it was, with everything other people wrote (titles,
|
|
487
547
|
names, quoted text) fenced as untrusted — plus a `confirmToken`; only a
|
|
488
548
|
repeat call with that token writes. With `mark_read` on
|
|
489
|
-
`
|
|
549
|
+
`teams_list_messages` / `teams_list_unread_messages`, that first call returns just
|
|
490
550
|
the preview (no messages); the repeat call reads and marks. The token is single-use, expires, and is
|
|
491
551
|
bound to the exact arguments: change anything between the two calls and it
|
|
492
552
|
is refused with a fresh preview.
|
|
@@ -504,7 +564,7 @@ as the real guard on what gets posted.
|
|
|
504
564
|
|
|
505
565
|
**Try it in your own notes first.** The conversation `48:notes` (also by the
|
|
506
566
|
name `notes` or `self`) is your Teams self-chat ("notes to self"): every write
|
|
507
|
-
accepts it, `
|
|
567
|
+
accepts it, `teams_list_messages` reads it, nobody else sees it, and
|
|
508
568
|
it is the safe place to see what a message or reaction will look like. Every
|
|
509
569
|
other `48:` system conversation (calendar and the like) is refused.
|
|
510
570
|
|
|
@@ -547,23 +607,23 @@ instead.
|
|
|
547
607
|
message id is its arrival time in epoch milliseconds, so "newer than the
|
|
548
608
|
last message I saw" is a numeric comparison and a cursor is just that
|
|
549
609
|
message's id — `next_cursor` is a plain id string, passed back unchanged as
|
|
550
|
-
`after_message_id` (`
|
|
551
|
-
(`
|
|
610
|
+
`after_message_id` (`teams_list_messages`) or inside `cursors`
|
|
611
|
+
(`teams_list_unread_messages`). The server keeps no state and **no cache**: every
|
|
552
612
|
call reads Teams live, and `fetched_at` (ISO 8601, UTC) says when. There is
|
|
553
613
|
no refresh flag because there is nothing to refresh. A cursor never moves
|
|
554
614
|
the read marker; with `limit` / `per_conversation_limit` the newest
|
|
555
615
|
messages are kept and `next_cursor` jumps to the newest, so check
|
|
556
616
|
`truncated` before assuming nothing was skipped. **Two cursor kinds:**
|
|
557
|
-
`
|
|
558
|
-
8601 time) that goes back only to `
|
|
617
|
+
`teams_list_changed_conversations` has its own *time* cursor (an opaque token, or an ISO
|
|
618
|
+
8601 time) that goes back only to `teams_list_changed_conversations`; it is not a message
|
|
559
619
|
id. Each of its conversation rows carries the message-id cursor to hand on,
|
|
560
|
-
`after_message_id`, for `
|
|
620
|
+
`after_message_id`, for `teams_list_messages` (or `teams_list_unread_messages`'s
|
|
561
621
|
`cursors`). Each tool rejects the other kind.
|
|
562
622
|
- <a id="paging-from-a-time"></a>**Paging from a time (ingestion and
|
|
563
|
-
backfill).** `
|
|
623
|
+
backfill).** `teams_list_messages` and `teams_list_unread_messages` take `from`:
|
|
564
624
|
a UTC time (ISO 8601; one with no zone is read as UTC) or a previous
|
|
565
625
|
result's `next_from`. They return what arrived at or after it **oldest
|
|
566
|
-
first**, at most `limit` (default 50; `
|
|
626
|
+
first**, at most `limit` (default 50; `teams_list_unread_messages` pools every
|
|
567
627
|
conversation into one `messages` list, each message carrying its
|
|
568
628
|
`conversation_id`), plus `has_more`, `next_from` and `next_from_time`.
|
|
569
629
|
Pass `next_from` back as `from` until `has_more` is false; it is returned
|
|
@@ -575,13 +635,13 @@ instead.
|
|
|
575
635
|
messages newest first with no way to seek, so each call reads everything
|
|
576
636
|
that changed since its `from` — a deep backfill gets faster as it catches
|
|
577
637
|
up — and a conversation with more than 20,000 messages since `from`
|
|
578
|
-
cannot be paged oldest first: `
|
|
579
|
-
rather than skip any, and `
|
|
638
|
+
cannot be paged oldest first: `teams_list_messages` reports an error
|
|
639
|
+
rather than skip any, and `teams_list_unread_messages` returns what arrived after the
|
|
580
640
|
oldest point it reached, names the stretch it could not read in
|
|
581
641
|
`incomplete` (`unread_not_read_from` / `unread_not_read_until`), and keeps
|
|
582
642
|
`next_from` moving — so one oversized conversation never stalls the stream.
|
|
583
643
|
`from` replaces `since` /
|
|
584
|
-
`after_message_id` / `mark_read` (and, for `
|
|
644
|
+
`after_message_id` / `mark_read` (and, for `teams_list_unread_messages`, `since_days`,
|
|
585
645
|
`cursors`, the per-conversation limits, `older_unread` and
|
|
586
646
|
`format: "summary"`).
|
|
587
647
|
|
|
@@ -600,7 +660,7 @@ instead.
|
|
|
600
660
|
tell on its own: `lastimreceivedtime` moves for a call recording too,
|
|
601
661
|
`lastMessage` can be stale, and a chat you never opened has no marker at
|
|
602
662
|
all. So the listing only nominates candidates (anything past the marker,
|
|
603
|
-
or no marker), and `unread_only` and `
|
|
663
|
+
or no marker), and `unread_only` and `teams_list_unread_messages` read each
|
|
604
664
|
candidate's messages past its marker (four at a time) and keep only those
|
|
605
665
|
holding a real unread message, with its `unread_count`. Without
|
|
606
666
|
`unread_only` the list tools' `unread` is just that cheap hint, marked
|
|
@@ -615,8 +675,8 @@ instead.
|
|
|
615
675
|
you never open. A candidate with no activity at all inside the window is
|
|
616
676
|
not even read. Whatever the window leaves out is counted in
|
|
617
677
|
`older_unread_skipped` (with a hint to widen `since_days`), never dropped
|
|
618
|
-
silently. `older_unread: true` (on `
|
|
619
|
-
`
|
|
678
|
+
silently. `older_unread: true` (on `teams_list_unread_messages`, and on
|
|
679
|
+
`teams_list_conversations` with `unread_only`) also lists them in
|
|
620
680
|
`older_unread_conversations` — `id`, `kind`, `title`, `team` (a channel's),
|
|
621
681
|
`lastActivity`, most recent first — with an `unread_count` for each one
|
|
622
682
|
whose messages were already read to place it outside the window; one with
|
|
@@ -625,9 +685,9 @@ instead.
|
|
|
625
685
|
be only system events). Muted chats: the conversation listing marks a chat
|
|
626
686
|
you muted with `properties.alerts: "false"` (verified live 2026-10-12: 8 of
|
|
627
687
|
1,435 conversations, every other one `"true"` or absent), surfaced as
|
|
628
|
-
`muted: true`. `
|
|
688
|
+
`muted: true`. `teams_list_unread_messages` leaves them out without reading them and
|
|
629
689
|
counts them in `muted_skipped`; `include_muted` adds them back. The list
|
|
630
|
-
tools' `unread_only` still includes them. `
|
|
690
|
+
tools' `unread_only` still includes them. `teams_list_messages` is not windowed: it takes an explicit
|
|
631
691
|
`since` and `limit`. This server only reads the marker; it never moves it.
|
|
632
692
|
- **The token only goes to Teams.** The chat-service token is sent to the
|
|
633
693
|
chat-service base and, for inline images, only to https hosts under
|
|
@@ -649,16 +709,16 @@ instead.
|
|
|
649
709
|
|
|
650
710
|
0.5 only adds arguments and fields, except for these changes in behaviour:
|
|
651
711
|
|
|
652
|
-
- **Ambiguous names in `
|
|
712
|
+
- **Ambiguous names in `teams_list_messages`:** a name that matches
|
|
653
713
|
several conversations used to fail with an error listing the candidates. It
|
|
654
714
|
now succeeds with `{ ambiguous: true, query, match_count, candidates, hint }`
|
|
655
715
|
and no messages. Check for `ambiguous` before reading `messages` or
|
|
656
716
|
`threads`. Send, react and attachment still fail on an ambiguous name.
|
|
657
|
-
- **Muted chats in `
|
|
717
|
+
- **Muted chats in `teams_list_unread_messages`:** chats you muted in Teams are left out
|
|
658
718
|
and counted in `muted_skipped`. Pass `include_muted: true` for the old
|
|
659
719
|
behaviour.
|
|
660
|
-
- **Read tools are no longer annotated read-only:** `
|
|
661
|
-
and `
|
|
720
|
+
- **Read tools are no longer annotated read-only:** `teams_list_messages`
|
|
721
|
+
and `teams_list_unread_messages` take an opt-in `mark_read` flag, so they are published
|
|
662
722
|
with `readOnly: false`. A client that auto-approves only read-only tools may
|
|
663
723
|
now ask before each read. Without `mark_read` they still never write.
|
|
664
724
|
|
|
@@ -668,9 +728,9 @@ instead.
|
|
|
668
728
|
changed shape. If you script against them:
|
|
669
729
|
|
|
670
730
|
- **Removed tools:** `teams_get_open_chat_messages` and
|
|
671
|
-
`teams_get_open_channel_posts` — use `
|
|
731
|
+
`teams_get_open_channel_posts` — use `teams_list_messages`, which reads
|
|
672
732
|
any chat or channel by id or name without it being open.
|
|
673
|
-
- **`
|
|
733
|
+
- **`teams_list_activity`:** rows now come from the Activity feed itself.
|
|
674
734
|
`title` and `location` are replaced by `type`/`subtype`/`kind`, `from`,
|
|
675
735
|
`where: { conversation_id, title, type }`, `message_id`, `reply_chain_id`
|
|
676
736
|
and `preview`; `time` is ISO 8601 (it was prose like "1:19 PM"); `read` is
|
|
@@ -688,7 +748,7 @@ changed shape. If you script against them:
|
|
|
688
748
|
- **Chat titles:** untitled chats are titled `(1:1 chat)` (or the other
|
|
689
749
|
person's name), `Group chat: A; B; C +N` (with a `participants` array), or
|
|
690
750
|
`(untitled group chat)` — no longer the last sender's name or
|
|
691
|
-
`(untitled chat)`. Plain `
|
|
751
|
+
`(untitled chat)`. Plain `teams_list_conversations` / `teams_list_channels`
|
|
692
752
|
listings put `favorite` and then `pinned` conversations first.
|
|
693
753
|
- **Unread:** confirmed by reading messages after your read point (call
|
|
694
754
|
recordings and other system events never count), hidden channels are left
|
package/dist/auth-fetchproxy.js
CHANGED
|
@@ -26,10 +26,11 @@
|
|
|
26
26
|
* code that needs a token, as Outlook's client does, so a server run with
|
|
27
27
|
* `TEAMS_ACCESS_TOKEN` never has to load the bridge to boot.
|
|
28
28
|
*/
|
|
29
|
-
import {
|
|
29
|
+
import { captureBearerHeader, createFetchproxyTransport } from '@chrischall/mcp-utils/fetchproxy';
|
|
30
30
|
import { readPortEnv } from '@chrischall/mcp-utils';
|
|
31
|
-
import {
|
|
31
|
+
import { captureWindowMs } from './capture-window.js';
|
|
32
32
|
import { PACKAGE_NAME, VERSION } from './version.js';
|
|
33
|
+
export { stripBearer } from '@chrischall/mcp-utils/fetchproxy';
|
|
33
34
|
/**
|
|
34
35
|
* fetchproxy concentrator port — one for the whole fleet. `TEAMS_WS_PORT`
|
|
35
36
|
* overrides it for local development and for a hosted bridged registration
|
|
@@ -64,75 +65,36 @@ export const CAPTURE_DECL = {
|
|
|
64
65
|
*/
|
|
65
66
|
export const TRUST_DOMAINS = [CAPTURE_DECL.host];
|
|
66
67
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
68
|
+
* Build the capture transport through this module's import binding, so a
|
|
69
|
+
* test's `vi.mock('@chrischall/mcp-utils/fetchproxy')` stub is the one used.
|
|
70
|
+
* Shared by the SharePoint and Substrate captures.
|
|
69
71
|
*/
|
|
70
|
-
const
|
|
71
|
-
/** Normalise a captured header to a bare token, dropping any `Bearer ` prefix. */
|
|
72
|
-
export function stripBearer(raw) {
|
|
73
|
-
const m = /^\s*Bearer\s+(.+)$/i.exec(raw);
|
|
74
|
-
return (m ? m[1] : raw).trim();
|
|
75
|
-
}
|
|
72
|
+
export const createCaptureTransport = (opts) => createFetchproxyTransport(opts);
|
|
76
73
|
/**
|
|
77
74
|
* Capture a chat-service access token from the user's signed-in Teams tab.
|
|
78
75
|
* Returns the bare token (no `Bearer ` prefix).
|
|
76
|
+
*
|
|
77
|
+
* `captureBearerHeader` declares only `capture_request_header` (beside the
|
|
78
|
+
* `fetch` base verb mcp-utils always keeps) — the same set as before the
|
|
79
|
+
* Activity feed left the page, so an existing pairing needs no re-approval —
|
|
80
|
+
* sets the bridge deadline to the capture window + 15 s, starts the transport
|
|
81
|
+
* (skipping `start()` makes the first verb throw "ensureConnected called before
|
|
82
|
+
* listen()", which reads exactly like a pairing problem), guards against a
|
|
83
|
+
* header too short to be a token, and closes the transport whatever happened.
|
|
79
84
|
*/
|
|
80
85
|
export async function captureTokenViaFetchproxy(env = process.env) {
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
// base verb mcp-utils always keeps (the field replaces the server default).
|
|
87
|
-
// This is the same set as before the Activity feed left the page, so an
|
|
88
|
-
// existing pairing needs no re-approval.
|
|
89
|
-
...createBootstrapOpts({
|
|
90
|
-
domains: [...TRUST_DOMAINS],
|
|
91
|
-
bootstrap: { captureHeaders: [{ ...CAPTURE_DECL }] },
|
|
92
|
-
}),
|
|
86
|
+
return captureBearerHeader({
|
|
87
|
+
captures: [CAPTURE_DECL],
|
|
88
|
+
domains: TRUST_DOMAINS,
|
|
89
|
+
// Read per capture, not at import: see `capture-window.ts`.
|
|
90
|
+
windowMs: captureWindowMs(env),
|
|
93
91
|
port: getWsPort(),
|
|
94
|
-
// Both: the explicit deadline for every bridge version, and the declared
|
|
95
|
-
// window so mcp-utils' own derivation agrees with it.
|
|
96
|
-
fetchTimeoutMs: bridgeDeadlineMs(windowMs),
|
|
97
|
-
captureWindowMs: windowMs,
|
|
98
92
|
serverName: PACKAGE_NAME,
|
|
99
93
|
version: VERSION,
|
|
94
|
+
what: 'a Teams token',
|
|
95
|
+
guidance: 'Open a signed-in teams.cloud.microsoft tab and click into any chat — ' +
|
|
96
|
+
'that is what makes the page call the chat service; an idle tab never ' +
|
|
97
|
+
'does — then retry.',
|
|
98
|
+
createTransport: createCaptureTransport,
|
|
100
99
|
});
|
|
101
|
-
try {
|
|
102
|
-
// `start()` loads the identity keypair. It does not bind the port or dial —
|
|
103
|
-
// that stays lazy until the first verb — but skipping it makes the first
|
|
104
|
-
// verb throw "ensureConnected called before listen()", which reads exactly
|
|
105
|
-
// like a pairing problem and is not one.
|
|
106
|
-
await transport.start();
|
|
107
|
-
try {
|
|
108
|
-
const raw = await transport.server.captureRequestHeader({
|
|
109
|
-
...CAPTURE_DECL,
|
|
110
|
-
timeoutMs: windowMs,
|
|
111
|
-
});
|
|
112
|
-
if (typeof raw !== 'string') {
|
|
113
|
-
throw new Error(`${CAPTURE_DECL.host}: capture returned no header`);
|
|
114
|
-
}
|
|
115
|
-
const token = stripBearer(raw);
|
|
116
|
-
if (token.length < MIN_TOKEN_LENGTH) {
|
|
117
|
-
throw new Error(`${CAPTURE_DECL.host}: authorization header was present but too short to be a ` +
|
|
118
|
-
`token (${token.length} chars)`);
|
|
119
|
-
}
|
|
120
|
-
return token;
|
|
121
|
-
}
|
|
122
|
-
catch (e) {
|
|
123
|
-
const detail = e.message;
|
|
124
|
-
throw new Error(`could not capture a Teams token from the browser (${detail}). ` +
|
|
125
|
-
'Open a signed-in teams.cloud.microsoft tab and click into any chat — ' +
|
|
126
|
-
'that is what makes the page call the chat service; an idle tab never ' +
|
|
127
|
-
'does — then retry.');
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
finally {
|
|
131
|
-
try {
|
|
132
|
-
await transport.close();
|
|
133
|
-
}
|
|
134
|
-
catch {
|
|
135
|
-
/* the token, or the original failure, is what matters */
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
100
|
}
|