@chrischall/microsoft-teams-mcp 0.2.7 → 0.3.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 +2 -2
- package/README.md +9 -1
- package/dist/bundle.js +126 -45
- package/dist/client.js +21 -12
- package/dist/tools/activity.js +11 -4
- package/dist/tools/channels.js +17 -9
- package/dist/tools/chat.js +17 -9
- package/dist/tools/conversation.js +7 -1
- package/dist/tools/healthcheck.js +15 -0
- package/dist/tools/limit.js +52 -0
- package/dist/version.js +1 -1
- package/package.json +3 -3
- package/server.json +18 -3
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
},
|
|
8
8
|
"metadata": {
|
|
9
9
|
"description": "MCP server for Microsoft Teams — read your chats, teams, channels, and their currently open messages",
|
|
10
|
-
"version": "0.
|
|
10
|
+
"version": "0.3.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 your chats, teams, channels, and their currently open messages, via your signed-in browser session",
|
|
18
|
-
"version": "0.
|
|
18
|
+
"version": "0.3.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.3.0",
|
|
5
5
|
"description": "Microsoft Teams for Claude — read your chats, teams, channels, and their currently open messages, using your signed-in browser session",
|
|
6
6
|
"author": {
|
|
7
7
|
"name": "Chris Hall",
|
|
@@ -19,5 +19,5 @@
|
|
|
19
19
|
"mcp"
|
|
20
20
|
],
|
|
21
21
|
"skills": "./skills/",
|
|
22
|
-
"
|
|
22
|
+
"mcpServers": "./.claude-plugin/mcp.json"
|
|
23
23
|
}
|
package/README.md
CHANGED
|
@@ -83,6 +83,8 @@ Everything is optional — this server needs no credentials of its own.
|
|
|
83
83
|
| variable | purpose |
|
|
84
84
|
| --- | --- |
|
|
85
85
|
| `TEAMS_WS_PORT` | fetchproxy concentrator port. Defaults to `37149`, the fleet-wide shared port. |
|
|
86
|
+
| `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. |
|
|
87
|
+
| `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. |
|
|
86
88
|
|
|
87
89
|
## Tools
|
|
88
90
|
|
|
@@ -106,7 +108,13 @@ Everything is optional — this server needs no credentials of its own.
|
|
|
106
108
|
team/channel or chat it happened in). Requires the Activity view open.
|
|
107
109
|
- `teams_healthcheck` — verifies the bridge can reach a signed-in tab.
|
|
108
110
|
|
|
109
|
-
All five data tools are read-only
|
|
111
|
+
All five data tools are read-only. Each takes an optional `limit` (default
|
|
112
|
+
50; max 200, or 300 for `teams_list_teams_and_channels`) and keeps the newest
|
|
113
|
+
rows, adding a `truncated` field with the total when it left some out.
|
|
114
|
+
`teams_get_open_chat_messages` also takes `since` (an ISO 8601 date-time) to
|
|
115
|
+
drop older messages. When a list tool reads nothing, its result carries an
|
|
116
|
+
`empty_hint` naming the Teams view to open, and `teams_healthcheck` reports
|
|
117
|
+
`chat_view_not_open` rather than a healthy bridge if the Chat view isn't open.
|
|
110
118
|
|
|
111
119
|
**No Calendar tool here.** Teams Web's Calendar renders inside an embedded
|
|
112
120
|
`outlook.office.com` iframe, which the ContextMint Bridge (DOM reads only
|
package/dist/bundle.js
CHANGED
|
@@ -121,9 +121,9 @@ var require_buffer_util = __commonJS({
|
|
|
121
121
|
toBuffer,
|
|
122
122
|
unmask: _unmask
|
|
123
123
|
};
|
|
124
|
-
if (
|
|
124
|
+
if (false) {
|
|
125
125
|
try {
|
|
126
|
-
const bufferUtil =
|
|
126
|
+
const bufferUtil = null;
|
|
127
127
|
module.exports.mask = function(source, mask, output2, offset, length) {
|
|
128
128
|
if (length < 48) _mask(source, mask, output2, offset, length);
|
|
129
129
|
else bufferUtil.mask(source, mask, output2, offset, length);
|
|
@@ -760,9 +760,9 @@ var require_validation2 = __commonJS({
|
|
|
760
760
|
module.exports.isValidUTF8 = function(buf) {
|
|
761
761
|
return buf.length < 24 ? _isValidUTF8(buf) : isUtf8(buf);
|
|
762
762
|
};
|
|
763
|
-
} else if (
|
|
763
|
+
} else if (false) {
|
|
764
764
|
try {
|
|
765
|
-
const isValidUTF8 =
|
|
765
|
+
const isValidUTF8 = null;
|
|
766
766
|
module.exports.isValidUTF8 = function(buf) {
|
|
767
767
|
return buf.length < 32 ? _isValidUTF8(buf) : isValidUTF8(buf);
|
|
768
768
|
};
|
|
@@ -38179,11 +38179,19 @@ var DEFAULT_ERROR_MESSAGE_MAX = 500;
|
|
|
38179
38179
|
var McpToolError = class extends Error {
|
|
38180
38180
|
/** Actionable remediation text, when one applies. */
|
|
38181
38181
|
hint;
|
|
38182
|
+
/** The upstream HTTP status this failure came from, when known. */
|
|
38183
|
+
status;
|
|
38184
|
+
/** What kind of failure this is, when the thrower knows. */
|
|
38185
|
+
kind;
|
|
38182
38186
|
constructor(message, opts) {
|
|
38183
38187
|
super(message, opts?.cause !== void 0 ? { cause: opts.cause } : void 0);
|
|
38184
38188
|
this.name = "McpToolError";
|
|
38185
38189
|
if (opts?.hint !== void 0)
|
|
38186
38190
|
this.hint = opts.hint;
|
|
38191
|
+
if (opts?.status !== void 0)
|
|
38192
|
+
this.status = opts.status;
|
|
38193
|
+
if (opts?.kind !== void 0)
|
|
38194
|
+
this.kind = opts.kind;
|
|
38187
38195
|
Object.setPrototypeOf(this, new.target.prototype);
|
|
38188
38196
|
}
|
|
38189
38197
|
};
|
|
@@ -38208,7 +38216,7 @@ var API_KEY_RE = new RegExp([
|
|
|
38208
38216
|
// webhook signing secret (Stripe-style)
|
|
38209
38217
|
].map((p) => `\\b${p}`).join("|"), "g");
|
|
38210
38218
|
var GOOGLE_OAUTH_TOKEN_RE = /(?<![A-Za-z0-9+/])(?:ya29\.|1\/\/)[A-Za-z0-9._-]{8,}/g;
|
|
38211
|
-
var QUERY_SECRET_RE = new RegExp(`([?&](?:(?:access|refresh|id|auth|session|csrf|xsrf)[_-]?token|client[_-]?secret|api[_-]?secret|api[_-]?key|password|passwd|signature|token|key|sig|(?:php|j)?sess(?:ion)?[_-]?id|sid|x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN})=)[^&#\\s"'<>\`]+`, "gi");
|
|
38219
|
+
var QUERY_SECRET_RE = new RegExp(`([?&](?:(?:access|refresh|id|auth|session|csrf|xsrf)[_-]?token|client[_-]?secret|api[_-]?secret|api[_-]?key|password|passwd|signature|token|key|sig|(?:code[_-]?)?verifier|(?:php|j)?sess(?:ion)?[_-]?id|sid|x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN})=)[^&#\\s"'<>\`]+`, "gi");
|
|
38212
38220
|
var OAUTH_CODE_RE = /([?&]code=)(?=[^&#\s"'<>`]{16,})[^&#\s"'<>`]+/gi;
|
|
38213
38221
|
var FORM_PASSWORD_RE = /((?:^|[\s,;:"'(\[{])(?:password|passwd)=)[^&#\s"'<>`]+/gim;
|
|
38214
38222
|
var HEADER_SECRET_RE = new RegExp(`(\\b(?:x[-_]${HEADER_NAME_RUN}?(?:api[-_]?key|token|secret|auth)${HEADER_NAME_RUN}|api[-_]?key)\\s*:\\s*)[^\\s,;"'<>\`]+`, "gi");
|
|
@@ -38219,6 +38227,8 @@ var JSON_SECRET_KEYS = [
|
|
|
38219
38227
|
"api[_-]?secret",
|
|
38220
38228
|
"(?:x[_-])?api[_-]?key",
|
|
38221
38229
|
"private[_-]?key",
|
|
38230
|
+
"code[_-]?verifier",
|
|
38231
|
+
// PKCE; a bare `verifier` key is too generic for JSON
|
|
38222
38232
|
`x[_-]${HEADER_NAME_RUN}?(?:api[_-]?key|token|secret|auth)${HEADER_NAME_RUN}`,
|
|
38223
38233
|
// bounded like HEADER_SECRET_RE
|
|
38224
38234
|
"(?:proxy-)?authorization",
|
|
@@ -38335,7 +38345,7 @@ function readEnvVar(key, opts = {}) {
|
|
|
38335
38345
|
if (typeof raw === "string") {
|
|
38336
38346
|
const trimmed = raw.trim();
|
|
38337
38347
|
if (trimmed.length > 0 && trimmed !== "undefined" && trimmed !== "null" && !PLACEHOLDER_RE.test(trimmed)) {
|
|
38338
|
-
return trimmed;
|
|
38348
|
+
return opts.trim === false ? raw : trimmed;
|
|
38339
38349
|
}
|
|
38340
38350
|
}
|
|
38341
38351
|
return opts.default;
|
|
@@ -38377,12 +38387,14 @@ var SERVER_PROTOCOL_VERSIONS = Object.freeze([
|
|
|
38377
38387
|
...SUPPORTED_PROTOCOL_VERSIONS
|
|
38378
38388
|
]);
|
|
38379
38389
|
function hintResultOrRethrow(err) {
|
|
38390
|
+
if (err instanceof ProtocolError && err.code === ProtocolErrorCode.UrlElicitationRequired)
|
|
38391
|
+
throw err;
|
|
38380
38392
|
if (err instanceof McpToolError && err.hint) {
|
|
38381
38393
|
return errorResult(`${err.message}
|
|
38382
38394
|
|
|
38383
38395
|
Hint: ${err.hint}`);
|
|
38384
38396
|
}
|
|
38385
|
-
|
|
38397
|
+
return errorResult(messageOf(err));
|
|
38386
38398
|
}
|
|
38387
38399
|
function mcpRequestFrom(args) {
|
|
38388
38400
|
const ctx = args.at(-1);
|
|
@@ -38585,6 +38597,8 @@ var ApiError = class extends Error {
|
|
|
38585
38597
|
var EdgeBlockedError = class extends ApiError {
|
|
38586
38598
|
/** Which edge refused the request, e.g. `'CloudFront'` or `'Cloudflare'`. */
|
|
38587
38599
|
vendor;
|
|
38600
|
+
/** Always `'edge_blocked'`: the credential was never judged. */
|
|
38601
|
+
kind = "edge_blocked";
|
|
38588
38602
|
/**
|
|
38589
38603
|
* @param where The service the request was for, and — when the thrower knows
|
|
38590
38604
|
* it — the method and path, which the message names.
|
|
@@ -38652,7 +38666,7 @@ var PositiveInt = external_exports.number().int().positive();
|
|
|
38652
38666
|
var NonNegInt = external_exports.number().int().nonnegative();
|
|
38653
38667
|
var NonEmptyString = external_exports.string().min(1);
|
|
38654
38668
|
var IsoDate = external_exports.iso.date();
|
|
38655
|
-
var IsoTime = external_exports.string().regex(/^([01]?\d|2[0-3]):[0-5]\d$/, "must be HH:MM (24h), e.g. 19:30");
|
|
38669
|
+
var IsoTime = external_exports.string().regex(/^([01]?\d|2[0-3]):[0-5]\d$/, "must be HH:MM (24h), e.g. 19:30").overwrite((v) => v.padStart(5, "0"));
|
|
38656
38670
|
var NumericIdString = external_exports.string().regex(/^\d+$/, "must be a numeric id (digits only)").describe("A numeric id string (digits only), safe to interpolate into a URL path.");
|
|
38657
38671
|
var SafePathSegment = external_exports.string().min(1).regex(/^[^/?#\s]+$/, 'must not contain "/", "?", "#", or whitespace').refine((v) => !v.includes(".."), 'must not contain ".."').describe('A single URL path segment, safe to interpolate: no "/", "..", "?", "#", or whitespace.');
|
|
38658
38672
|
var schemaOrigin = external_exports.string().optional().describe("Portal origin (e.g. https://<vendor>.example.co) selecting which active session to use. Optional when only one session is active.");
|
|
@@ -38680,7 +38694,7 @@ function toolAnnotations(opts = {}) {
|
|
|
38680
38694
|
|
|
38681
38695
|
// src/version.ts
|
|
38682
38696
|
var PACKAGE_NAME = "microsoft-teams-mcp";
|
|
38683
|
-
var VERSION = "0.
|
|
38697
|
+
var VERSION = "0.3.0";
|
|
38684
38698
|
|
|
38685
38699
|
// node_modules/@fetchproxy/protocol/dist/crypto.js
|
|
38686
38700
|
var subtle = globalThis.crypto.subtle;
|
|
@@ -42380,7 +42394,7 @@ function classifyBridgeError(err) {
|
|
|
42380
42394
|
// node_modules/@fetchproxy/server/dist/ws-server.js
|
|
42381
42395
|
import { isIP } from "node:net";
|
|
42382
42396
|
function envWsPort() {
|
|
42383
|
-
const raw =
|
|
42397
|
+
const raw = void 0;
|
|
42384
42398
|
if (raw === void 0 || raw.trim() === "")
|
|
42385
42399
|
return void 0;
|
|
42386
42400
|
if (!/^\d+$/.test(raw.trim()))
|
|
@@ -45176,7 +45190,13 @@ var DOM_LIST_SELECTORS = [
|
|
|
45176
45190
|
];
|
|
45177
45191
|
var TeamsClient = class {
|
|
45178
45192
|
#transport;
|
|
45179
|
-
|
|
45193
|
+
/**
|
|
45194
|
+
* The in-flight (or settled) start, memoized so parallel first calls share
|
|
45195
|
+
* ONE `transport.start()` — two concurrent starts would each create and
|
|
45196
|
+
* persist a fresh fetchproxy identity keypair, leaving the paired key and
|
|
45197
|
+
* the on-disk key out of step. Cleared on failure so the next call retries.
|
|
45198
|
+
*/
|
|
45199
|
+
#starting;
|
|
45180
45200
|
constructor(opts = {}) {
|
|
45181
45201
|
this.#transport = opts.transport ?? createFetchproxyTransport({
|
|
45182
45202
|
serverName: PACKAGE_NAME,
|
|
@@ -45202,10 +45222,12 @@ var TeamsClient = class {
|
|
|
45202
45222
|
* lazily, so a server that never gets a tool call never touches the
|
|
45203
45223
|
* bridge at all.
|
|
45204
45224
|
*/
|
|
45205
|
-
|
|
45206
|
-
|
|
45207
|
-
|
|
45208
|
-
|
|
45225
|
+
#ensureStarted() {
|
|
45226
|
+
this.#starting ??= this.#transport.start().catch((e) => {
|
|
45227
|
+
this.#starting = void 0;
|
|
45228
|
+
throw e;
|
|
45229
|
+
});
|
|
45230
|
+
return this.#starting;
|
|
45209
45231
|
}
|
|
45210
45232
|
/** Reads a declared selector off the single supported domain's live tab. */
|
|
45211
45233
|
async #readDomList(name) {
|
|
@@ -45248,12 +45270,14 @@ var TeamsClient = class {
|
|
|
45248
45270
|
return await this.#readDomList("channelPosts");
|
|
45249
45271
|
}
|
|
45250
45272
|
/**
|
|
45251
|
-
*
|
|
45252
|
-
*
|
|
45273
|
+
* Every sidebar row Teams marks as selected (up to 5). Usually one, but the
|
|
45274
|
+
* selector spans BOTH the Chat and the Teams-and-Channels sidebars, so a
|
|
45275
|
+
* channel row can stay selected while a chat is open (and vice versa) —
|
|
45276
|
+
* callers must pick by `itemType` (see `tools/conversation.ts`), never
|
|
45277
|
+
* just take the first row.
|
|
45253
45278
|
*/
|
|
45254
|
-
async
|
|
45255
|
-
|
|
45256
|
-
return rows[0] ?? null;
|
|
45279
|
+
async getSelectedConversations() {
|
|
45280
|
+
return await this.#readDomList("openConversation");
|
|
45257
45281
|
}
|
|
45258
45282
|
/** The Activity feed (the bell icon in the left nav), regardless of which item is selected. */
|
|
45259
45283
|
async getActivity() {
|
|
@@ -45261,7 +45285,7 @@ var TeamsClient = class {
|
|
|
45261
45285
|
}
|
|
45262
45286
|
async close() {
|
|
45263
45287
|
await this.#transport.close();
|
|
45264
|
-
this.#
|
|
45288
|
+
this.#starting = void 0;
|
|
45265
45289
|
}
|
|
45266
45290
|
/** Non-secret bridge status for the healthcheck tool. */
|
|
45267
45291
|
status() {
|
|
@@ -45311,7 +45335,8 @@ var OPEN_CONVERSATION_DESCRIPTION = " The result names the open conversation (`c
|
|
|
45311
45335
|
async function readOpenConversation(client2, kind) {
|
|
45312
45336
|
let conversation = null;
|
|
45313
45337
|
try {
|
|
45314
|
-
|
|
45338
|
+
const matches = (await client2.getSelectedConversations()).filter((row) => row.itemType === kind);
|
|
45339
|
+
conversation = matches.length === 1 ? matches[0] : null;
|
|
45315
45340
|
} catch {
|
|
45316
45341
|
conversation = null;
|
|
45317
45342
|
}
|
|
@@ -45327,6 +45352,36 @@ async function readOpenConversation(client2, kind) {
|
|
|
45327
45352
|
};
|
|
45328
45353
|
}
|
|
45329
45354
|
|
|
45355
|
+
// src/tools/limit.ts
|
|
45356
|
+
var DEFAULT_LIMIT = 50;
|
|
45357
|
+
function limitArg(max, what) {
|
|
45358
|
+
return external_exports.number().int().min(1).max(max).optional().describe(`Maximum ${what} to return, newest first kept (default ${DEFAULT_LIMIT}, max ${max}).`);
|
|
45359
|
+
}
|
|
45360
|
+
function trimRows(rows, limit, newestAt, max) {
|
|
45361
|
+
const n = limit ?? DEFAULT_LIMIT;
|
|
45362
|
+
if (rows.length <= n) return { rows };
|
|
45363
|
+
const kept = newestAt === "end" ? rows.slice(rows.length - n) : rows.slice(0, n);
|
|
45364
|
+
return {
|
|
45365
|
+
rows: kept,
|
|
45366
|
+
truncated: {
|
|
45367
|
+
total: rows.length,
|
|
45368
|
+
returned: kept.length,
|
|
45369
|
+
hint: `Only the newest ${kept.length} of ${rows.length} were returned; pass a larger limit (max ${max}) to read more.`
|
|
45370
|
+
}
|
|
45371
|
+
};
|
|
45372
|
+
}
|
|
45373
|
+
var sinceArg = external_exports.string().refine((s) => !Number.isNaN(Date.parse(s)), { message: "since must be an ISO 8601 date-time" }).optional().describe(
|
|
45374
|
+
"Only return messages at or after this ISO 8601 date-time (e.g. 2026-09-21T09:00:00Z). Messages whose time cannot be read are kept."
|
|
45375
|
+
);
|
|
45376
|
+
function filterSince(rows, since) {
|
|
45377
|
+
if (since === void 0) return rows;
|
|
45378
|
+
const cutoff = Date.parse(since);
|
|
45379
|
+
return rows.filter((row) => {
|
|
45380
|
+
const t = row.time === void 0 ? Number.NaN : Date.parse(row.time);
|
|
45381
|
+
return Number.isNaN(t) || t >= cutoff;
|
|
45382
|
+
});
|
|
45383
|
+
}
|
|
45384
|
+
|
|
45330
45385
|
// src/tools/chat.ts
|
|
45331
45386
|
function registerChatTools(server, client2) {
|
|
45332
45387
|
server.registerTool(
|
|
@@ -45334,13 +45389,18 @@ function registerChatTools(server, client2) {
|
|
|
45334
45389
|
{
|
|
45335
45390
|
title: "List Teams chats",
|
|
45336
45391
|
description: "List the chats in the signed-in user's Teams chat sidebar (1:1s, group chats, meeting chats), each with its title, last-message preview, last-activity time, and a conversationKey (Teams' internal thread id \u2014 not usable to open the chat, there is no navigate capability). Reads the currently-rendered list from the user's live browser tab." + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45337
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45338
|
-
inputSchema: {}
|
|
45392
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45393
|
+
inputSchema: { limit: limitArg(200, "chats") }
|
|
45339
45394
|
},
|
|
45340
|
-
async () => {
|
|
45395
|
+
async ({ limit }) => {
|
|
45341
45396
|
try {
|
|
45342
45397
|
const rows = await client2.listChats();
|
|
45343
|
-
return untrustedResult2(
|
|
45398
|
+
return untrustedResult2(
|
|
45399
|
+
rows.length > 0 ? trimRows(rows, limit, "start", 200) : {
|
|
45400
|
+
rows,
|
|
45401
|
+
empty_hint: "No chat list is rendered. The Teams tab is probably not on the Chat view \u2014 ask the user to click Chat in the left nav, then retry."
|
|
45402
|
+
}
|
|
45403
|
+
);
|
|
45344
45404
|
} catch (err) {
|
|
45345
45405
|
throw wrapBridgeError(err, "list chats");
|
|
45346
45406
|
}
|
|
@@ -45351,14 +45411,15 @@ function registerChatTools(server, client2) {
|
|
|
45351
45411
|
{
|
|
45352
45412
|
title: "Read the currently open Teams chat",
|
|
45353
45413
|
description: "Read the message thread of whichever Teams chat is CURRENTLY OPEN in the user's signed-in browser tab \u2014 sender, ISO-8601 time, message id, and text for each message. There is no way to choose a different chat from here (the bridge can only read the DOM, not navigate it): ask the user to open the chat they mean first, or use teams_list_chats to show them what is available. A quoted-reply message's text may include the quoted preview concatenated in." + OPEN_CONVERSATION_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45354
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45355
|
-
inputSchema: {}
|
|
45414
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45415
|
+
inputSchema: { limit: limitArg(200, "messages"), since: sinceArg }
|
|
45356
45416
|
},
|
|
45357
|
-
async () => {
|
|
45417
|
+
async ({ limit, since }) => {
|
|
45358
45418
|
try {
|
|
45359
|
-
const
|
|
45419
|
+
const all = await client2.getOpenChatMessages();
|
|
45360
45420
|
const identity = await readOpenConversation(client2, "chat");
|
|
45361
|
-
|
|
45421
|
+
const { rows: messages, truncated } = trimRows(filterSince(all, since), limit, "end", 200);
|
|
45422
|
+
return untrustedResult2({ ...identity, messages, ...truncated ? { truncated } : {} });
|
|
45362
45423
|
} catch (err) {
|
|
45363
45424
|
throw wrapBridgeError(err, "read the open chat");
|
|
45364
45425
|
}
|
|
@@ -45373,13 +45434,18 @@ function registerChannelTools(server, client2) {
|
|
|
45373
45434
|
{
|
|
45374
45435
|
title: "List Teams and their channels",
|
|
45375
45436
|
description: `List the Teams the signed-in user belongs to and their channels, from the "Teams" nav section's sidebar (a DIFFERENT view from Chat). Each row is a team or a channel \u2014 itemType distinguishes them; a channel row's teamName names its parent team. Requires the user's browser to have the Teams-and-Channels view open (not Chat) \u2014 if it returns nothing, ask them to click "Teams" in the left nav.` + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45376
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45377
|
-
inputSchema: {}
|
|
45437
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45438
|
+
inputSchema: { limit: limitArg(300, "team and channel rows") }
|
|
45378
45439
|
},
|
|
45379
|
-
async () => {
|
|
45440
|
+
async ({ limit }) => {
|
|
45380
45441
|
try {
|
|
45381
45442
|
const rows = await client2.listTeamsAndChannels();
|
|
45382
|
-
return untrustedResult2(
|
|
45443
|
+
return untrustedResult2(
|
|
45444
|
+
rows.length > 0 ? trimRows(rows, limit, "start", 300) : {
|
|
45445
|
+
rows,
|
|
45446
|
+
empty_hint: "No teams or channels are rendered. The Teams tab is probably not on the Teams view \u2014 ask the user to click Teams in the left nav, then retry."
|
|
45447
|
+
}
|
|
45448
|
+
);
|
|
45383
45449
|
} catch (err) {
|
|
45384
45450
|
throw wrapBridgeError(err, "list teams and channels");
|
|
45385
45451
|
}
|
|
@@ -45390,14 +45456,15 @@ function registerChannelTools(server, client2) {
|
|
|
45390
45456
|
{
|
|
45391
45457
|
title: "Read the currently open channel",
|
|
45392
45458
|
description: `Read the top-level posts in whichever Teams CHANNEL is CURRENTLY OPEN in the user's signed-in browser tab \u2014 sender, time (prose, e.g. "Tuesday, August 4, 2026 7:50 AM" \u2014 not ISO 8601), subject (when the post has a title), and text. Threaded replies under a post are not included, only the top-level posts. There is no way to choose a different channel from here: ask the user to open the channel they mean first (the Teams-and-Channels view, not Chat), or use teams_list_teams_and_channels to show them what is available.` + OPEN_CONVERSATION_DESCRIPTION + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45393
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45394
|
-
inputSchema: {}
|
|
45459
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45460
|
+
inputSchema: { limit: limitArg(200, "posts") }
|
|
45395
45461
|
},
|
|
45396
|
-
async () => {
|
|
45462
|
+
async ({ limit }) => {
|
|
45397
45463
|
try {
|
|
45398
|
-
const
|
|
45464
|
+
const all = await client2.getOpenChannelPosts();
|
|
45399
45465
|
const identity = await readOpenConversation(client2, "channel");
|
|
45400
|
-
|
|
45466
|
+
const { rows: posts, truncated } = trimRows(all, limit, "end", 200);
|
|
45467
|
+
return untrustedResult2({ ...identity, posts, ...truncated ? { truncated } : {} });
|
|
45401
45468
|
} catch (err) {
|
|
45402
45469
|
throw wrapBridgeError(err, "read the open channel");
|
|
45403
45470
|
}
|
|
@@ -45412,13 +45479,18 @@ function registerActivityTools(server, client2) {
|
|
|
45412
45479
|
{
|
|
45413
45480
|
title: "Read the Activity feed",
|
|
45414
45481
|
description: "List the rows in the Activity feed (the bell icon in the left nav) \u2014 mentions, replies, reactions, and the like across every chat and channel \u2014 each with its title, message preview, prose time (not ISO 8601), and location (the team/channel or chat it happened in). Requires the user's browser to have the Activity view open \u2014 if it returns nothing, ask them to click the bell icon in the left nav." + UNTRUSTED_DESCRIPTION_SUFFIX2,
|
|
45415
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
45416
|
-
inputSchema: {}
|
|
45482
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
45483
|
+
inputSchema: { limit: limitArg(200, "activity rows") }
|
|
45417
45484
|
},
|
|
45418
|
-
async () => {
|
|
45485
|
+
async ({ limit }) => {
|
|
45419
45486
|
try {
|
|
45420
45487
|
const rows = await client2.getActivity();
|
|
45421
|
-
return untrustedResult2(
|
|
45488
|
+
return untrustedResult2(
|
|
45489
|
+
rows.length > 0 ? trimRows(rows, limit, "start", 200) : {
|
|
45490
|
+
rows,
|
|
45491
|
+
empty_hint: "No Activity feed is rendered. The Teams tab is probably not on the Activity view \u2014 ask the user to click the bell icon (Activity) in the left nav, then retry."
|
|
45492
|
+
}
|
|
45493
|
+
);
|
|
45422
45494
|
} catch (err) {
|
|
45423
45495
|
throw wrapBridgeError(err, "read the Activity feed");
|
|
45424
45496
|
}
|
|
@@ -45436,10 +45508,19 @@ function registerHealthcheckTool(server, client2) {
|
|
|
45436
45508
|
probePath: "chat list (read_dom_list against the currently open Teams tab)",
|
|
45437
45509
|
probeFn: async () => {
|
|
45438
45510
|
const rows = await client2.listChats();
|
|
45511
|
+
if (rows.length === 0) throw new ChatViewNotOpenError();
|
|
45439
45512
|
return `${rows.length} chat(s) visible in the sidebar`;
|
|
45440
|
-
}
|
|
45513
|
+
},
|
|
45514
|
+
classifyThrown: (err) => err instanceof ChatViewNotOpenError ? { kind: "chat_view_not_open", hint: CHAT_VIEW_NOT_OPEN_HINT } : void 0
|
|
45441
45515
|
});
|
|
45442
45516
|
}
|
|
45517
|
+
var CHAT_VIEW_NOT_OPEN_HINT = "The bridge reached the teams.cloud.microsoft tab, but no chat list is rendered: the Chat view is not open (the tab is probably on Teams, Activity or Calendar). Ask the user to click Chat in the left nav, then retry.";
|
|
45518
|
+
var ChatViewNotOpenError = class extends Error {
|
|
45519
|
+
constructor() {
|
|
45520
|
+
super("bridge OK but no chat list rendered \u2014 is the Chat view open?");
|
|
45521
|
+
this.name = "ChatViewNotOpenError";
|
|
45522
|
+
}
|
|
45523
|
+
};
|
|
45443
45524
|
|
|
45444
45525
|
// src/index.ts
|
|
45445
45526
|
loadDotenvSafely();
|
package/dist/client.js
CHANGED
|
@@ -182,7 +182,13 @@ export const DOM_LIST_SELECTORS = [
|
|
|
182
182
|
];
|
|
183
183
|
export class TeamsClient {
|
|
184
184
|
#transport;
|
|
185
|
-
|
|
185
|
+
/**
|
|
186
|
+
* The in-flight (or settled) start, memoized so parallel first calls share
|
|
187
|
+
* ONE `transport.start()` — two concurrent starts would each create and
|
|
188
|
+
* persist a fresh fetchproxy identity keypair, leaving the paired key and
|
|
189
|
+
* the on-disk key out of step. Cleared on failure so the next call retries.
|
|
190
|
+
*/
|
|
191
|
+
#starting;
|
|
186
192
|
constructor(opts = {}) {
|
|
187
193
|
this.#transport =
|
|
188
194
|
opts.transport ??
|
|
@@ -208,11 +214,12 @@ export class TeamsClient {
|
|
|
208
214
|
* lazily, so a server that never gets a tool call never touches the
|
|
209
215
|
* bridge at all.
|
|
210
216
|
*/
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
217
|
+
#ensureStarted() {
|
|
218
|
+
this.#starting ??= this.#transport.start().catch((e) => {
|
|
219
|
+
this.#starting = undefined;
|
|
220
|
+
throw e;
|
|
221
|
+
});
|
|
222
|
+
return this.#starting;
|
|
216
223
|
}
|
|
217
224
|
/** Reads a declared selector off the single supported domain's live tab. */
|
|
218
225
|
async #readDomList(name) {
|
|
@@ -255,12 +262,14 @@ export class TeamsClient {
|
|
|
255
262
|
return (await this.#readDomList('channelPosts'));
|
|
256
263
|
}
|
|
257
264
|
/**
|
|
258
|
-
*
|
|
259
|
-
*
|
|
265
|
+
* Every sidebar row Teams marks as selected (up to 5). Usually one, but the
|
|
266
|
+
* selector spans BOTH the Chat and the Teams-and-Channels sidebars, so a
|
|
267
|
+
* channel row can stay selected while a chat is open (and vice versa) —
|
|
268
|
+
* callers must pick by `itemType` (see `tools/conversation.ts`), never
|
|
269
|
+
* just take the first row.
|
|
260
270
|
*/
|
|
261
|
-
async
|
|
262
|
-
|
|
263
|
-
return rows[0] ?? null;
|
|
271
|
+
async getSelectedConversations() {
|
|
272
|
+
return (await this.#readDomList('openConversation'));
|
|
264
273
|
}
|
|
265
274
|
/** The Activity feed (the bell icon in the left nav), regardless of which item is selected. */
|
|
266
275
|
async getActivity() {
|
|
@@ -268,7 +277,7 @@ export class TeamsClient {
|
|
|
268
277
|
}
|
|
269
278
|
async close() {
|
|
270
279
|
await this.#transport.close();
|
|
271
|
-
this.#
|
|
280
|
+
this.#starting = undefined;
|
|
272
281
|
}
|
|
273
282
|
/** Non-secret bridge status for the healthcheck tool. */
|
|
274
283
|
status() {
|
package/dist/tools/activity.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { toolAnnotations } from '@chrischall/mcp-utils';
|
|
2
2
|
import { wrapBridgeError } from './errors.js';
|
|
3
3
|
import { untrustedResult, UNTRUSTED_DESCRIPTION_SUFFIX } from './untrusted.js';
|
|
4
|
+
import { limitArg, trimRows } from './limit.js';
|
|
4
5
|
export function registerActivityTools(server, client) {
|
|
5
6
|
server.registerTool('teams_get_activity', {
|
|
6
7
|
title: 'Read the Activity feed',
|
|
@@ -10,12 +11,18 @@ export function registerActivityTools(server, client) {
|
|
|
10
11
|
'or chat it happened in). Requires the user\'s browser to have the Activity view ' +
|
|
11
12
|
'open — if it returns nothing, ask them to click the bell icon in the left nav.' +
|
|
12
13
|
UNTRUSTED_DESCRIPTION_SUFFIX,
|
|
13
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
14
|
-
inputSchema: {},
|
|
15
|
-
}, async () => {
|
|
14
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
15
|
+
inputSchema: { limit: limitArg(200, 'activity rows') },
|
|
16
|
+
}, async ({ limit }) => {
|
|
16
17
|
try {
|
|
17
18
|
const rows = await client.getActivity();
|
|
18
|
-
return untrustedResult(
|
|
19
|
+
return untrustedResult(rows.length > 0
|
|
20
|
+
? trimRows(rows, limit, 'start', 200)
|
|
21
|
+
: {
|
|
22
|
+
rows,
|
|
23
|
+
empty_hint: 'No Activity feed is rendered. The Teams tab is probably not on the Activity view — ' +
|
|
24
|
+
'ask the user to click the bell icon (Activity) in the left nav, then retry.',
|
|
25
|
+
});
|
|
19
26
|
}
|
|
20
27
|
catch (err) {
|
|
21
28
|
throw wrapBridgeError(err, 'read the Activity feed');
|
package/dist/tools/channels.js
CHANGED
|
@@ -2,6 +2,7 @@ import { toolAnnotations } from '@chrischall/mcp-utils';
|
|
|
2
2
|
import { wrapBridgeError } from './errors.js';
|
|
3
3
|
import { untrustedResult, UNTRUSTED_DESCRIPTION_SUFFIX } from './untrusted.js';
|
|
4
4
|
import { OPEN_CONVERSATION_DESCRIPTION, readOpenConversation } from './conversation.js';
|
|
5
|
+
import { limitArg, trimRows } from './limit.js';
|
|
5
6
|
export function registerChannelTools(server, client) {
|
|
6
7
|
server.registerTool('teams_list_teams_and_channels', {
|
|
7
8
|
title: 'List Teams and their channels',
|
|
@@ -11,12 +12,18 @@ export function registerChannelTools(server, client) {
|
|
|
11
12
|
'team. Requires the user\'s browser to have the Teams-and-Channels view open (not ' +
|
|
12
13
|
'Chat) — if it returns nothing, ask them to click "Teams" in the left nav.' +
|
|
13
14
|
UNTRUSTED_DESCRIPTION_SUFFIX,
|
|
14
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
15
|
-
inputSchema: {},
|
|
16
|
-
}, async () => {
|
|
15
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
16
|
+
inputSchema: { limit: limitArg(300, 'team and channel rows') },
|
|
17
|
+
}, async ({ limit }) => {
|
|
17
18
|
try {
|
|
18
19
|
const rows = await client.listTeamsAndChannels();
|
|
19
|
-
return untrustedResult(
|
|
20
|
+
return untrustedResult(rows.length > 0
|
|
21
|
+
? trimRows(rows, limit, 'start', 300)
|
|
22
|
+
: {
|
|
23
|
+
rows,
|
|
24
|
+
empty_hint: 'No teams or channels are rendered. The Teams tab is probably not on the Teams view — ' +
|
|
25
|
+
'ask the user to click Teams in the left nav, then retry.',
|
|
26
|
+
});
|
|
20
27
|
}
|
|
21
28
|
catch (err) {
|
|
22
29
|
throw wrapBridgeError(err, 'list teams and channels');
|
|
@@ -33,13 +40,14 @@ export function registerChannelTools(server, client) {
|
|
|
33
40
|
'teams_list_teams_and_channels to show them what is available.' +
|
|
34
41
|
OPEN_CONVERSATION_DESCRIPTION +
|
|
35
42
|
UNTRUSTED_DESCRIPTION_SUFFIX,
|
|
36
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
37
|
-
inputSchema: {},
|
|
38
|
-
}, async () => {
|
|
43
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
44
|
+
inputSchema: { limit: limitArg(200, 'posts') },
|
|
45
|
+
}, async ({ limit }) => {
|
|
39
46
|
try {
|
|
40
|
-
const
|
|
47
|
+
const all = await client.getOpenChannelPosts();
|
|
41
48
|
const identity = await readOpenConversation(client, 'channel');
|
|
42
|
-
|
|
49
|
+
const { rows: posts, truncated } = trimRows(all, limit, 'end', 200);
|
|
50
|
+
return untrustedResult({ ...identity, posts, ...(truncated ? { truncated } : {}) });
|
|
43
51
|
}
|
|
44
52
|
catch (err) {
|
|
45
53
|
throw wrapBridgeError(err, 'read the open channel');
|
package/dist/tools/chat.js
CHANGED
|
@@ -2,6 +2,7 @@ import { toolAnnotations } from '@chrischall/mcp-utils';
|
|
|
2
2
|
import { wrapBridgeError } from './errors.js';
|
|
3
3
|
import { untrustedResult, UNTRUSTED_DESCRIPTION_SUFFIX } from './untrusted.js';
|
|
4
4
|
import { OPEN_CONVERSATION_DESCRIPTION, readOpenConversation } from './conversation.js';
|
|
5
|
+
import { filterSince, limitArg, sinceArg, trimRows } from './limit.js';
|
|
5
6
|
export function registerChatTools(server, client) {
|
|
6
7
|
server.registerTool('teams_list_chats', {
|
|
7
8
|
title: 'List Teams chats',
|
|
@@ -10,12 +11,18 @@ export function registerChatTools(server, client) {
|
|
|
10
11
|
'conversationKey (Teams\' internal thread id — not usable to open the chat, there is no ' +
|
|
11
12
|
'navigate capability). Reads the currently-rendered list from the user\'s live browser tab.' +
|
|
12
13
|
UNTRUSTED_DESCRIPTION_SUFFIX,
|
|
13
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
14
|
-
inputSchema: {},
|
|
15
|
-
}, async () => {
|
|
14
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
15
|
+
inputSchema: { limit: limitArg(200, 'chats') },
|
|
16
|
+
}, async ({ limit }) => {
|
|
16
17
|
try {
|
|
17
18
|
const rows = await client.listChats();
|
|
18
|
-
return untrustedResult(
|
|
19
|
+
return untrustedResult(rows.length > 0
|
|
20
|
+
? trimRows(rows, limit, 'start', 200)
|
|
21
|
+
: {
|
|
22
|
+
rows,
|
|
23
|
+
empty_hint: 'No chat list is rendered. The Teams tab is probably not on the Chat view — ' +
|
|
24
|
+
'ask the user to click Chat in the left nav, then retry.',
|
|
25
|
+
});
|
|
19
26
|
}
|
|
20
27
|
catch (err) {
|
|
21
28
|
throw wrapBridgeError(err, 'list chats');
|
|
@@ -31,13 +38,14 @@ export function registerChatTools(server, client) {
|
|
|
31
38
|
'include the quoted preview concatenated in.' +
|
|
32
39
|
OPEN_CONVERSATION_DESCRIPTION +
|
|
33
40
|
UNTRUSTED_DESCRIPTION_SUFFIX,
|
|
34
|
-
annotations: toolAnnotations({ readOnly: true }),
|
|
35
|
-
inputSchema: {},
|
|
36
|
-
}, async () => {
|
|
41
|
+
annotations: toolAnnotations({ readOnly: true, openWorld: true }),
|
|
42
|
+
inputSchema: { limit: limitArg(200, 'messages'), since: sinceArg },
|
|
43
|
+
}, async ({ limit, since }) => {
|
|
37
44
|
try {
|
|
38
|
-
const
|
|
45
|
+
const all = await client.getOpenChatMessages();
|
|
39
46
|
const identity = await readOpenConversation(client, 'chat');
|
|
40
|
-
|
|
47
|
+
const { rows: messages, truncated } = trimRows(filterSince(all, since), limit, 'end', 200);
|
|
48
|
+
return untrustedResult({ ...identity, messages, ...(truncated ? { truncated } : {}) });
|
|
41
49
|
}
|
|
42
50
|
catch (err) {
|
|
43
51
|
throw wrapBridgeError(err, 'read the open chat');
|
|
@@ -7,11 +7,17 @@ export const OPEN_CONVERSATION_DESCRIPTION = ' The result names the open convers
|
|
|
7
7
|
/**
|
|
8
8
|
* Best-effort: the identity read must never cost the user the messages
|
|
9
9
|
* themselves, so a failed read degrades to `null` plus a warning.
|
|
10
|
+
*
|
|
11
|
+
* Only a selected row whose `itemType` matches `kind` counts: the selector
|
|
12
|
+
* spans both sidebars, so a channel row left selected while a chat is open
|
|
13
|
+
* must not be reported as "the chat". If no row matches, more than one does,
|
|
14
|
+
* or the row carries no `itemType`, the conversation is unidentified.
|
|
10
15
|
*/
|
|
11
16
|
export async function readOpenConversation(client, kind) {
|
|
12
17
|
let conversation = null;
|
|
13
18
|
try {
|
|
14
|
-
|
|
19
|
+
const matches = (await client.getSelectedConversations()).filter((row) => row.itemType === kind);
|
|
20
|
+
conversation = matches.length === 1 ? matches[0] : null;
|
|
15
21
|
}
|
|
16
22
|
catch {
|
|
17
23
|
conversation = null;
|
|
@@ -8,7 +8,22 @@ export function registerHealthcheckTool(server, client) {
|
|
|
8
8
|
probePath: 'chat list (read_dom_list against the currently open Teams tab)',
|
|
9
9
|
probeFn: async () => {
|
|
10
10
|
const rows = await client.listChats();
|
|
11
|
+
// The chat list renders only while the Chat view is open, and on any
|
|
12
|
+
// other view (Teams, Activity, Calendar…) the read returns [] rather
|
|
13
|
+
// than throwing — so an empty read means "wrong view", not "healthy".
|
|
14
|
+
if (rows.length === 0)
|
|
15
|
+
throw new ChatViewNotOpenError();
|
|
11
16
|
return `${rows.length} chat(s) visible in the sidebar`;
|
|
12
17
|
},
|
|
18
|
+
classifyThrown: (err) => err instanceof ChatViewNotOpenError ? { kind: 'chat_view_not_open', hint: CHAT_VIEW_NOT_OPEN_HINT } : undefined,
|
|
13
19
|
});
|
|
14
20
|
}
|
|
21
|
+
const CHAT_VIEW_NOT_OPEN_HINT = 'The bridge reached the teams.cloud.microsoft tab, but no chat list is rendered: the Chat view ' +
|
|
22
|
+
'is not open (the tab is probably on Teams, Activity or Calendar). Ask the user to click Chat ' +
|
|
23
|
+
'in the left nav, then retry.';
|
|
24
|
+
class ChatViewNotOpenError extends Error {
|
|
25
|
+
constructor() {
|
|
26
|
+
super('bridge OK but no chat list rendered — is the Chat view open?');
|
|
27
|
+
this.name = 'ChatViewNotOpenError';
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Client-side trimming for every list/read tool. The bridge returns up to the
|
|
3
|
+
* selector's `maxItems` rows (200, or 300 for the teams-and-channels sidebar)
|
|
4
|
+
* in one read; dumping all of them into one result fills the context window
|
|
5
|
+
* with other people's messages the question did not need. Each tool takes an
|
|
6
|
+
* optional `limit` (default {@link DEFAULT_LIMIT}) and keeps the NEWEST rows —
|
|
7
|
+
* which sit at the END of a message thread (rendered oldest-first) and at the
|
|
8
|
+
* START of a sidebar or the Activity feed (rendered newest-first).
|
|
9
|
+
*/
|
|
10
|
+
import { z } from 'zod';
|
|
11
|
+
export const DEFAULT_LIMIT = 50;
|
|
12
|
+
/** The optional `limit` argument, capped at what the selector can return. */
|
|
13
|
+
export function limitArg(max, what) {
|
|
14
|
+
return z
|
|
15
|
+
.number()
|
|
16
|
+
.int()
|
|
17
|
+
.min(1)
|
|
18
|
+
.max(max)
|
|
19
|
+
.optional()
|
|
20
|
+
.describe(`Maximum ${what} to return, newest first kept (default ${DEFAULT_LIMIT}, max ${max}).`);
|
|
21
|
+
}
|
|
22
|
+
export function trimRows(rows, limit, newestAt, max) {
|
|
23
|
+
const n = limit ?? DEFAULT_LIMIT;
|
|
24
|
+
if (rows.length <= n)
|
|
25
|
+
return { rows };
|
|
26
|
+
const kept = newestAt === 'end' ? rows.slice(rows.length - n) : rows.slice(0, n);
|
|
27
|
+
return {
|
|
28
|
+
rows: kept,
|
|
29
|
+
truncated: {
|
|
30
|
+
total: rows.length,
|
|
31
|
+
returned: kept.length,
|
|
32
|
+
hint: `Only the newest ${kept.length} of ${rows.length} were returned; pass a larger limit (max ${max}) to read more.`,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/** The optional `since` argument (ISO 8601 date-time) for ISO-timed rows. */
|
|
37
|
+
export const sinceArg = z
|
|
38
|
+
.string()
|
|
39
|
+
.refine((s) => !Number.isNaN(Date.parse(s)), { message: 'since must be an ISO 8601 date-time' })
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('Only return messages at or after this ISO 8601 date-time (e.g. 2026-09-21T09:00:00Z). ' +
|
|
42
|
+
'Messages whose time cannot be read are kept.');
|
|
43
|
+
/** Drop rows whose ISO `time` is before `since`; rows with no readable time are kept. */
|
|
44
|
+
export function filterSince(rows, since) {
|
|
45
|
+
if (since === undefined)
|
|
46
|
+
return rows;
|
|
47
|
+
const cutoff = Date.parse(since);
|
|
48
|
+
return rows.filter((row) => {
|
|
49
|
+
const t = row.time === undefined ? Number.NaN : Date.parse(row.time);
|
|
50
|
+
return Number.isNaN(t) || t >= cutoff;
|
|
51
|
+
});
|
|
52
|
+
}
|
package/dist/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chrischall/microsoft-teams-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.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>",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
],
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "tsc && npm run bundle",
|
|
40
|
-
"bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --external:dotenv --banner:js='import { createRequire as __createRequire } from \"module\"; const require = __createRequire(import.meta.url);' --outfile=dist/bundle.js",
|
|
40
|
+
"bundle": "esbuild src/index.ts --bundle --platform=node --format=esm --external:dotenv --define:process.env.FETCHPROXY_WS_PORT=undefined --define:process.env.WS_NO_BUFFER_UTIL='\"1\"' --define:process.env.WS_NO_UTF_8_VALIDATE='\"1\"' --banner:js='import { createRequire as __createRequire } from \"module\"; const require = __createRequire(import.meta.url);' --outfile=dist/bundle.js",
|
|
41
41
|
"dev": "node dist/index.js",
|
|
42
42
|
"test": "npm run typecheck && vitest run",
|
|
43
43
|
"test:watch": "vitest",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"typecheck": "tsc -p tsconfig.check.json"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@chrischall/mcp-utils": "^
|
|
48
|
+
"@chrischall/mcp-utils": "^3.0.0",
|
|
49
49
|
"@fetchproxy/protocol": "^3.6.0",
|
|
50
50
|
"@fetchproxy/server": "^3.6.0",
|
|
51
51
|
"@modelcontextprotocol/server": "^2.3.0",
|
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.3.0",
|
|
10
10
|
"packages": [
|
|
11
11
|
{
|
|
12
12
|
"registryType": "npm",
|
|
13
13
|
"identifier": "@chrischall/microsoft-teams-mcp",
|
|
14
|
-
"version": "0.
|
|
14
|
+
"version": "0.3.0",
|
|
15
15
|
"transport": {
|
|
16
16
|
"type": "stdio"
|
|
17
17
|
},
|
|
@@ -20,7 +20,22 @@
|
|
|
20
20
|
"name": "TEAMS_WS_PORT",
|
|
21
21
|
"description": "fetchproxy concentrator port used for the browser bridge. Defaults to 37149, the fleet-wide shared port.",
|
|
22
22
|
"isRequired": false,
|
|
23
|
-
"format": "string"
|
|
23
|
+
"format": "string",
|
|
24
|
+
"isSecret": false
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "FETCHPROXY_WS_HOST",
|
|
28
|
+
"description": "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.",
|
|
29
|
+
"isRequired": false,
|
|
30
|
+
"format": "string",
|
|
31
|
+
"isSecret": false
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"name": "FETCHPROXY_IDENTITY_DIR",
|
|
35
|
+
"description": "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.",
|
|
36
|
+
"isRequired": false,
|
|
37
|
+
"format": "string",
|
|
38
|
+
"isSecret": false
|
|
24
39
|
}
|
|
25
40
|
]
|
|
26
41
|
}
|