@chrischall/microsoft-teams-mcp 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.js ADDED
@@ -0,0 +1,231 @@
1
+ /**
2
+ * Full-bridge Teams client.
3
+ *
4
+ * Unlike Outlook's bootstrap-capture archetype, this one touches the bridge
5
+ * on every call. Teams Web's message data lives only in a client-side sync
6
+ * cache fed by a WebSocket/registrar channel — there is no REST or GraphQL
7
+ * endpoint that returns it, so the only way to read it is to read the DOM the
8
+ * page has already rendered. That rules out a captured-token-then-plain-fetch
9
+ * design: every read here goes through `read_dom_list` against the user's
10
+ * live, signed-in `teams.microsoft.com` tab.
11
+ *
12
+ * Consequence: this MCP can only read whichever chat or channel is
13
+ * CURRENTLY DISPLAYED in that tab. `@fetchproxy/server` has no capability to
14
+ * navigate a tab to a different conversation — every declared capability is
15
+ * a fetch or a read, never a page interaction — so there is no way to ask
16
+ * for "chat X's messages" or "channel Y's posts" on demand.
17
+ * `listChats()`/`listTeamsAndChannels()` read their sidebars (always
18
+ * visible once that nav section is open); `getOpenChatMessages()`/
19
+ * `getOpenChannelPosts()` read whatever conversation the user has open.
20
+ * Verified live 2026-09-21 against a real Teams tenant.
21
+ */
22
+ import { createFetchproxyTransport, } from '@chrischall/mcp-utils/fetchproxy';
23
+ import { readPortEnv } from '@chrischall/mcp-utils';
24
+ import { PACKAGE_NAME, VERSION } from './version.js';
25
+ /**
26
+ * The two hosts Teams Web actually serves from. A tenant's tab may be on
27
+ * either; `readDomListAnyDomain` tries both in order and falls through to
28
+ * the next on a "no tab matching" failure, since only one will ever have a
29
+ * live tab.
30
+ */
31
+ export const DOMAINS = ['teams.microsoft.com', 'teams.cloud.microsoft'];
32
+ /**
33
+ * fetchproxy concentrator port — one for the whole fleet. `TEAMS_WS_PORT`
34
+ * overrides it for local development and for a hosted bridged registration
35
+ * (where mcp-host names this variable in `bridgePortEnv`).
36
+ */
37
+ const DEFAULT_WS_PORT = 37_149;
38
+ export function getWsPort() {
39
+ return readPortEnv('TEAMS_WS_PORT', DEFAULT_WS_PORT);
40
+ }
41
+ /**
42
+ * The currently-open chat's message thread. `.fui-ChatMessage` (others'
43
+ * messages) and `.fui-ChatMyMessage` (the signed-in user's own) are Teams
44
+ * v2's two message-row classes; both carry the same `message-author-name` /
45
+ * `time` / `chat-pane-message` structure. `sender` reads back even for a
46
+ * grouped/consecutive message Teams visually hides the name on — it stays
47
+ * in the DOM, just visually collapsed. A quoted-reply message's `text`
48
+ * includes the quoted preview concatenated in (a known limitation of bulk
49
+ * `.textContent` extraction, not fixable without a second, narrower field).
50
+ */
51
+ export const CHAT_MESSAGES_SELECTOR = {
52
+ name: 'chatMessages',
53
+ itemSelector: '.fui-ChatMessage, .fui-ChatMyMessage',
54
+ fields: [
55
+ { name: 'sender', selector: '[data-tid="message-author-name"]' },
56
+ { name: 'time', selector: 'time', attribute: 'datetime' },
57
+ { name: 'messageId', selector: 'time', attribute: 'id' },
58
+ { name: 'text', selector: '[data-tid="chat-pane-message"]' },
59
+ ],
60
+ maxItems: 200,
61
+ };
62
+ /**
63
+ * The chat-list sidebar (always rendered, regardless of which chat is
64
+ * open). `conversationKey` is Teams' own compound tree-item value — it
65
+ * embeds the real thread id (e.g. `19:<id>@thread.v2`) but is NOT usable to
66
+ * open that chat from here; there is no navigate capability. It is exposed
67
+ * so a caller can at least correlate a list entry with the currently-open
68
+ * chat's messages.
69
+ */
70
+ export const CHAT_LIST_SELECTOR = {
71
+ name: 'chatList',
72
+ itemSelector: '[data-testid="list-item"]',
73
+ fields: [
74
+ { name: 'title', selector: '[id^="title-chat-list-item_"]' },
75
+ { name: 'preview', selector: '[data-testid="comfy-message"]' },
76
+ { name: 'time', selector: '[id^="time-chat-list-item_"]' },
77
+ { name: 'conversationKey', attribute: 'data-fui-tree-item-value' },
78
+ { name: 'itemType', attribute: 'data-item-type' },
79
+ ],
80
+ maxItems: 200,
81
+ };
82
+ /**
83
+ * The Teams-and-Channels sidebar (the left rail under the "Teams" nav icon,
84
+ * a DIFFERENT view from Chat — always rendered once that view is open,
85
+ * regardless of which channel is open). Team and channel rows share one
86
+ * item selector; `title-*`/`time-*` use a compound attribute selector
87
+ * (`[id^="title-"][id*="-list-item-"]`) rather than a comma-joined pair of
88
+ * prefixes, because a channel and a team item use different id prefixes
89
+ * (`title-channel-list-item-*` / `title-team-list-item-*`) and this reads
90
+ * either without needing two alternatives. `teamName` is the parent team's
91
+ * display name shown under a channel row (absent on a team row itself).
92
+ */
93
+ export const TEAMS_AND_CHANNELS_SELECTOR = {
94
+ name: 'teamsAndChannels',
95
+ itemSelector: '[data-item-type="team"], [data-item-type="channel"]',
96
+ fields: [
97
+ { name: 'title', selector: '[id^="title-"][id*="-list-item-"]' },
98
+ { name: 'teamName', selector: '[id^="preview-channel-list-item-"]' },
99
+ { name: 'time', selector: '[id^="time-"][id*="-list-item-"]' },
100
+ { name: 'conversationKey', attribute: 'data-fui-tree-item-value' },
101
+ { name: 'itemType', attribute: 'data-item-type' },
102
+ ],
103
+ maxItems: 300,
104
+ };
105
+ /**
106
+ * Top-level posts in whichever CHANNEL is currently open (same "reads only
107
+ * what's displayed" constraint as chat messages — see module doc). Channel
108
+ * posts use a different renderer than chat messages (`channel-pane-message`,
109
+ * not `.fui-ChatMessage`), and their `<time>` element carries no ISO
110
+ * `datetime` attribute — only a human-readable `aria-label` — so `time` here
111
+ * is prose ("Tuesday, August 4, 2026 7:50 AM"), not ISO 8601 like
112
+ * `ChatMessageRow.time`. `subject` is present only on a post that has a
113
+ * title; a reply-shaped post has none. Threaded REPLIES under a post are not
114
+ * captured — only the top-level posts a channel's "Posts" tab lists.
115
+ */
116
+ export const CHANNEL_POSTS_SELECTOR = {
117
+ name: 'channelPosts',
118
+ itemSelector: '[data-tid="channel-pane-message"]',
119
+ fields: [
120
+ { name: 'sender', selector: '[id^="author-"]' },
121
+ { name: 'subject', selector: '[id^="subject-line-"]' },
122
+ { name: 'time', selector: 'time[data-tid="timestamp"]', attribute: 'aria-label' },
123
+ { name: 'messageId', selector: 'time[data-tid="timestamp"]', attribute: 'id' },
124
+ { name: 'text', selector: '[id^="content-"]' },
125
+ ],
126
+ maxItems: 200,
127
+ };
128
+ export class TeamsClient {
129
+ #transport;
130
+ #started = false;
131
+ constructor(opts = {}) {
132
+ this.#transport =
133
+ opts.transport ??
134
+ createFetchproxyTransport({
135
+ serverName: PACKAGE_NAME,
136
+ version: VERSION,
137
+ domains: [...DOMAINS],
138
+ capabilities: ['read_dom_list'],
139
+ domListSelectors: [
140
+ CHAT_MESSAGES_SELECTOR,
141
+ CHAT_LIST_SELECTOR,
142
+ TEAMS_AND_CHANNELS_SELECTOR,
143
+ CHANNEL_POSTS_SELECTOR,
144
+ ],
145
+ port: getWsPort(),
146
+ // stderr only — stdout is the JSON-RPC channel. Without this the
147
+ // first-ever pairing (or a scope widening) leaves a tool call
148
+ // hanging with no way for the user to know a Transporter approval
149
+ // is what it's waiting on.
150
+ onPairCode: (code) => {
151
+ console.error(`[microsoft-teams-mcp] fetchproxy pair code: ${code} — approve in the Transporter extension popup`);
152
+ },
153
+ });
154
+ }
155
+ /**
156
+ * `start()` only loads the identity keypair — it does not bind the port or
157
+ * dial the extension, which stays lazy until the first verb. Called once,
158
+ * lazily, so a server that never gets a tool call never touches the
159
+ * bridge at all.
160
+ */
161
+ async #ensureStarted() {
162
+ if (this.#started)
163
+ return;
164
+ await this.#transport.start();
165
+ this.#started = true;
166
+ }
167
+ /**
168
+ * Try each declared domain in turn, falling through to the next on a
169
+ * "no tab matching" failure. Only one domain will ever have a live tab —
170
+ * `readDomList` (unlike `captureRequestHeader`) is a point-in-time DOM
171
+ * read with no open capture window to race, so sequential try-then-fall-
172
+ * through is correct here (not `Promise.any`).
173
+ */
174
+ async #readDomListAnyDomain(name) {
175
+ await this.#ensureStarted();
176
+ const errors = [];
177
+ for (const domain of DOMAINS) {
178
+ try {
179
+ return await this.#transport.server.readDomList({ name, domain });
180
+ }
181
+ catch (e) {
182
+ const err = e;
183
+ errors.push(`${domain}: ${err.message}`);
184
+ // Only a "no tab on this domain" failure is worth trying the next
185
+ // domain for. Anything else (scope rejection, bridge down) is the
186
+ // same for every domain and should surface immediately.
187
+ if (!/no tab matching/i.test(err.message))
188
+ throw e;
189
+ }
190
+ }
191
+ throw new Error(`could not reach a signed-in Teams tab on any of [${DOMAINS.join(', ')}] (${errors.join('; ')}). ` +
192
+ 'Open teams.microsoft.com in a signed-in browser tab and retry.');
193
+ }
194
+ /** The chat-list sidebar, regardless of which chat is currently open. */
195
+ async listChats() {
196
+ return (await this.#readDomListAnyDomain('chatList'));
197
+ }
198
+ /**
199
+ * Messages from whichever chat is CURRENTLY DISPLAYED in the signed-in
200
+ * tab. There is no way to select a different chat from here — see the
201
+ * module doc.
202
+ */
203
+ async getOpenChatMessages() {
204
+ return (await this.#readDomListAnyDomain('chatMessages'));
205
+ }
206
+ /** The Teams-and-Channels sidebar, regardless of which channel is open. */
207
+ async listTeamsAndChannels() {
208
+ return (await this.#readDomListAnyDomain('teamsAndChannels'));
209
+ }
210
+ /**
211
+ * Top-level posts from whichever channel is CURRENTLY DISPLAYED in the
212
+ * signed-in tab (the Teams-and-Channels view must be open, not Chat).
213
+ * There is no way to select a different channel from here — see the
214
+ * module doc.
215
+ */
216
+ async getOpenChannelPosts() {
217
+ return (await this.#readDomListAnyDomain('channelPosts'));
218
+ }
219
+ async close() {
220
+ await this.#transport.close();
221
+ this.#started = false;
222
+ }
223
+ /** Non-secret bridge status for the healthcheck tool. */
224
+ status() {
225
+ return this.#transport.status();
226
+ }
227
+ /** The underlying bridge transport, for `registerBridgeHealthcheckTool`. */
228
+ get transport() {
229
+ return this.#transport;
230
+ }
231
+ }
package/dist/index.js ADDED
@@ -0,0 +1,23 @@
1
+ #!/usr/bin/env node
2
+ import { runMcp, loadDotenvSafely } from '@chrischall/mcp-utils';
3
+ import { VERSION } from './version.js';
4
+ import { TeamsClient } from './client.js';
5
+ import { registerChatTools } from './tools/chat.js';
6
+ import { registerChannelTools } from './tools/channels.js';
7
+ import { registerHealthcheckTool } from './tools/healthcheck.js';
8
+ loadDotenvSafely();
9
+ /**
10
+ * Built HERE, in the caller, not inside a registrar — see office-outlook-mcp
11
+ * for the full rationale (`runMcp` builds a server instance per served
12
+ * connection, so anything built inside a registrar would be rebuilt). For
13
+ * this MCP it matters even more: a second `TeamsClient` would mean a second
14
+ * fetchproxy identity/session for the same process.
15
+ */
16
+ const client = new TeamsClient();
17
+ await runMcp({
18
+ name: 'microsoft-teams-mcp',
19
+ version: VERSION,
20
+ banner: '[microsoft-teams-mcp] This project was developed and is maintained by AI. Use at your own discretion.',
21
+ deps: client,
22
+ tools: [registerChatTools, registerChannelTools, registerHealthcheckTool],
23
+ });
@@ -0,0 +1,42 @@
1
+ import { minifiedResult, toolAnnotations } from '@chrischall/mcp-utils';
2
+ import { wrapBridgeError } from './errors.js';
3
+ export function registerChannelTools(server, client) {
4
+ server.registerTool('teams_list_teams_and_channels', {
5
+ title: 'List Teams and their channels',
6
+ description: 'List the Teams the signed-in user belongs to and their channels, from the ' +
7
+ '"Teams" nav section\'s sidebar (a DIFFERENT view from Chat). Each row is a team or ' +
8
+ 'a channel — itemType distinguishes them; a channel row\'s teamName names its parent ' +
9
+ 'team. Requires the user\'s browser to have the Teams-and-Channels view open (not ' +
10
+ 'Chat) — if it returns nothing, ask them to click "Teams" in the left nav.',
11
+ annotations: toolAnnotations({ readOnly: true }),
12
+ inputSchema: {},
13
+ }, async () => {
14
+ try {
15
+ const rows = await client.listTeamsAndChannels();
16
+ return minifiedResult(rows);
17
+ }
18
+ catch (err) {
19
+ throw wrapBridgeError(err, 'list teams and channels');
20
+ }
21
+ });
22
+ server.registerTool('teams_get_open_channel_posts', {
23
+ title: 'Read the currently open channel',
24
+ description: 'Read the top-level posts in whichever Teams CHANNEL is CURRENTLY OPEN in the ' +
25
+ 'user\'s signed-in browser tab — sender, time (prose, e.g. "Tuesday, August 4, 2026 ' +
26
+ '7:50 AM" — not ISO 8601), subject (when the post has a title), and text. Threaded ' +
27
+ 'replies under a post are not included, only the top-level posts. There is no way ' +
28
+ 'to choose a different channel from here: ask the user to open the channel they ' +
29
+ 'mean first (the Teams-and-Channels view, not Chat), or use ' +
30
+ 'teams_list_teams_and_channels to show them what is available.',
31
+ annotations: toolAnnotations({ readOnly: true }),
32
+ inputSchema: {},
33
+ }, async () => {
34
+ try {
35
+ const rows = await client.getOpenChannelPosts();
36
+ return minifiedResult(rows);
37
+ }
38
+ catch (err) {
39
+ throw wrapBridgeError(err, 'read the open channel');
40
+ }
41
+ });
42
+ }
@@ -0,0 +1,40 @@
1
+ import { minifiedResult, toolAnnotations } from '@chrischall/mcp-utils';
2
+ import { wrapBridgeError } from './errors.js';
3
+ export function registerChatTools(server, client) {
4
+ server.registerTool('teams_list_chats', {
5
+ title: 'List Teams chats',
6
+ description: 'List the chats in the signed-in user\'s Teams chat sidebar (1:1s, group chats, meeting ' +
7
+ 'chats), each with its title, last-message preview, last-activity time, and a ' +
8
+ 'conversationKey (Teams\' internal thread id — not usable to open the chat, there is no ' +
9
+ 'navigate capability). Reads the currently-rendered list from the user\'s live browser tab.',
10
+ annotations: toolAnnotations({ readOnly: true }),
11
+ inputSchema: {},
12
+ }, async () => {
13
+ try {
14
+ const rows = await client.listChats();
15
+ return minifiedResult(rows);
16
+ }
17
+ catch (err) {
18
+ throw wrapBridgeError(err, 'list chats');
19
+ }
20
+ });
21
+ server.registerTool('teams_get_open_chat_messages', {
22
+ title: 'Read the currently open Teams chat',
23
+ description: 'Read the message thread of whichever Teams chat is CURRENTLY OPEN in the user\'s ' +
24
+ 'signed-in browser tab — sender, ISO-8601 time, message id, and text for each message. ' +
25
+ 'There is no way to choose a different chat from here (the bridge can only read the DOM, ' +
26
+ 'not navigate it): ask the user to open the chat they mean first, or use ' +
27
+ 'teams_list_chats to show them what is available. A quoted-reply message\'s text may ' +
28
+ 'include the quoted preview concatenated in.',
29
+ annotations: toolAnnotations({ readOnly: true }),
30
+ inputSchema: {},
31
+ }, async () => {
32
+ try {
33
+ const rows = await client.getOpenChatMessages();
34
+ return minifiedResult(rows);
35
+ }
36
+ catch (err) {
37
+ throw wrapBridgeError(err, 'read the open chat');
38
+ }
39
+ });
40
+ }
@@ -0,0 +1,17 @@
1
+ import { McpToolError } from '@chrischall/mcp-utils';
2
+ /** Classify a bridge-read failure into an actionable McpToolError. Shared by every tool. */
3
+ export function wrapBridgeError(err, action) {
4
+ const message = err instanceof Error ? err.message : String(err);
5
+ if (/no tab matching|could not reach a signed-in/i.test(message)) {
6
+ return new McpToolError(`Could not reach a signed-in Teams tab to ${action}.`, {
7
+ hint: 'Open teams.microsoft.com (or teams.cloud.microsoft) in Chrome, make sure you are ' +
8
+ 'signed in, and retry.',
9
+ });
10
+ }
11
+ if (/pair code|not granted|not in declared/i.test(message)) {
12
+ return new McpToolError(`The Teams browser bridge is not yet approved: ${message}`, {
13
+ hint: 'Approve the pairing request in the Transporter extension popup, then retry.',
14
+ });
15
+ }
16
+ return new McpToolError(`Failed to ${action}: ${message}`);
17
+ }
@@ -0,0 +1,14 @@
1
+ import { registerBridgeHealthcheckTool } from '@chrischall/mcp-utils/fetchproxy';
2
+ export function registerHealthcheckTool(server, client) {
3
+ registerBridgeHealthcheckTool({
4
+ server,
5
+ prefix: 'teams',
6
+ hostLabel: 'teams.microsoft.com',
7
+ transport: client.transport,
8
+ probePath: 'chat list (read_dom_list against the currently open Teams tab)',
9
+ probeFn: async () => {
10
+ const rows = await client.listChats();
11
+ return `${rows.length} chat(s) visible in the sidebar`;
12
+ },
13
+ });
14
+ }
@@ -0,0 +1,13 @@
1
+ /**
2
+ * The single source of the package version.
3
+ *
4
+ * Everything that needs a version imports from here, so release-please has one
5
+ * file to rewrite and there is no second marker to forget. Registered in
6
+ * `release-please-config.json` under `extra-files`.
7
+ *
8
+ * Note for anyone editing the comments in this file: `versionSyncTest` flags
9
+ * every line containing the marker string, so it must appear on the export
10
+ * line below and nowhere else — not even in prose.
11
+ */
12
+ export const PACKAGE_NAME = 'microsoft-teams-mcp';
13
+ export const VERSION = '0.1.0'; // x-release-please-version
package/mint.yaml ADDED
@@ -0,0 +1,42 @@
1
+ version: 1
2
+ name: Microsoft Teams
3
+ slug: teams
4
+ summary: >-
5
+ Microsoft Teams for Claude — read your chats, teams, channels, and their
6
+ currently open messages, routed through your signed-in browser tab
7
+ #
8
+ # Hosting note (a comment, not user-facing summary text): this is a FULL
9
+ # browser-bridge MCP, not a bootstrap-capture one. Teams' chat/message data
10
+ # lives only in a client-side sync cache fed by a WebSocket/registrar channel
11
+ # — there is no REST or GraphQL endpoint that returns it — so every read here
12
+ # is a `read_dom_list` call against the live signed-in tab, not a token
13
+ # capture followed by a plain fetch. The bridge is on the hot path for every
14
+ # tool call, not just once per token lifetime.
15
+ #
16
+ # A bridged registration needs `runtime: fly-shared`, `bridge: true` and a
17
+ # `bridgePortEnv`, which are REGISTRATION fields this manifest has no schema
18
+ # for — set them over the control API (PUT on the registration id, per
19
+ # mcp-host's BROWSER-BRIDGE.md), naming TEAMS_WS_PORT below as the port
20
+ # variable. `state.dataDir` below is required for `bridge`.
21
+ env:
22
+ - name: TEAMS_WS_PORT
23
+ required: false
24
+ help: >-
25
+ fetchproxy concentrator port used for the browser bridge. Defaults to
26
+ 37149, the fleet-wide shared port. Name this variable in the
27
+ registration's bridgePortEnv for a bridged deployment.
28
+ state:
29
+ dataDir: true
30
+ reason: >-
31
+ Holds the fetchproxy identity keypair under ~/.fetchproxy/identity.
32
+ Without persistence every cold start mints a fresh identity and re-
33
+ prompts pairing in the user's browser — on a scale-to-zero machine, that
34
+ means constantly.
35
+ egress:
36
+ # Empty on purpose: this is a pure browser-bridge MCP. Every Teams request
37
+ # (the read_dom_list calls in src/client.ts) is made by the user's
38
+ # signed-in tab via the fetchproxy extension, never by this process — there
39
+ # is no direct mode and no bootstrap that dials teams.microsoft.com
40
+ # server-side. The only socket the process opens is the loopback
41
+ # concentrator the extension connects TO.
42
+ allow: []
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "@chrischall/microsoft-teams-mcp",
3
+ "version": "0.1.0",
4
+ "mcpName": "io.github.chrischall/microsoft-teams-mcp",
5
+ "description": "Microsoft Teams MCP server for Claude — developed and maintained by AI (Claude Code)",
6
+ "author": "Claude Code (AI) <https://www.anthropic.com/claude>",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/chrischall/microsoft-teams-mcp.git"
10
+ },
11
+ "license": "MIT",
12
+ "publishConfig": {
13
+ "access": "public"
14
+ },
15
+ "keywords": [
16
+ "mcp",
17
+ "model-context-protocol",
18
+ "claude",
19
+ "ai",
20
+ "microsoft-teams",
21
+ "teams",
22
+ "office365",
23
+ "microsoft365",
24
+ "chat"
25
+ ],
26
+ "type": "module",
27
+ "bin": {
28
+ "microsoft-teams-mcp": "dist/bundle.js"
29
+ },
30
+ "files": [
31
+ "dist",
32
+ ".claude-plugin",
33
+ ".mcp.json",
34
+ "server.json",
35
+ "skills",
36
+ "mint.yaml"
37
+ ],
38
+ "scripts": {
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",
41
+ "dev": "node dist/index.js",
42
+ "test": "npm run typecheck && vitest run",
43
+ "test:watch": "vitest",
44
+ "test:coverage": "npm run typecheck && vitest run --coverage",
45
+ "typecheck": "tsc -p tsconfig.check.json"
46
+ },
47
+ "dependencies": {
48
+ "@chrischall/mcp-utils": "^2.2.1",
49
+ "@fetchproxy/protocol": "^3.1.0",
50
+ "@fetchproxy/server": "^3.1.0",
51
+ "@modelcontextprotocol/server": "^2.0.0",
52
+ "dotenv": "^18.0.1",
53
+ "zod": "^4.6.2"
54
+ },
55
+ "devDependencies": {
56
+ "@modelcontextprotocol/client": "^2.0.0",
57
+ "@types/node": "^26.0.0",
58
+ "@vitest/coverage-v8": "^5.0.0",
59
+ "esbuild": "^0.28.1",
60
+ "typescript": "^7.0.2",
61
+ "vitest": "^5.0.0"
62
+ }
63
+ }
package/server.json ADDED
@@ -0,0 +1,28 @@
1
+ {
2
+ "$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
3
+ "name": "io.github.chrischall/microsoft-teams-mcp",
4
+ "description": "Microsoft Teams for Claude — read your chats, teams, channels, and open messages, via your browser",
5
+ "repository": {
6
+ "url": "https://github.com/chrischall/microsoft-teams-mcp",
7
+ "source": "github"
8
+ },
9
+ "version": "0.1.0",
10
+ "packages": [
11
+ {
12
+ "registryType": "npm",
13
+ "identifier": "@chrischall/microsoft-teams-mcp",
14
+ "version": "0.1.0",
15
+ "transport": {
16
+ "type": "stdio"
17
+ },
18
+ "environmentVariables": [
19
+ {
20
+ "name": "TEAMS_WS_PORT",
21
+ "description": "fetchproxy concentrator port used for the browser bridge. Defaults to 37149, the fleet-wide shared port.",
22
+ "isRequired": false,
23
+ "format": "string"
24
+ }
25
+ ]
26
+ }
27
+ ]
28
+ }
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: teams-fpx
3
+ description: >-
4
+ Read Microsoft Teams data (chats, teams, channels, and whichever chat or
5
+ channel is currently open) from a shell with the fpx CLI (@fetchproxy/cli)
6
+ instead of running the microsoft-teams-mcp server. Teams' data lives only
7
+ in a client-side sync cache with no REST/GraphQL endpoint, so this reads
8
+ the rendered DOM of a signed-in browser tab via fpx's read_dom_list
9
+ capability — no login, no token, just an open tab. Use when you want Teams
10
+ data without the MCP, in a script, or on a machine where the MCP isn't
11
+ installed.
12
+ ---
13
+
14
+ # Microsoft Teams via fpx (no MCP)
15
+
16
+ Teams Web has no fetchable API for chat/message/channel content — it's
17
+ synced over a private WebSocket channel into a client-side cache, and the
18
+ web app renders straight from that cache. There is nothing to `curl` or POST
19
+ a GraphQL query to. The only way to read it is to read what the page has
20
+ already rendered, which is what `fpx dom-list` does: it asks the Transporter
21
+ extension to run a declared `querySelectorAll` + per-item field extraction
22
+ against your signed-in `teams.microsoft.com` tab and hands back structured
23
+ rows.
24
+
25
+ **This means the same limitation the MCP has applies here: you can only read
26
+ whichever chat or channel is currently open in the browser.** There is no
27
+ way to switch conversations from the CLI — open the one you want in Teams
28
+ first. Reading channels also needs the **Teams-and-Channels** nav section
29
+ open (the "Teams" icon in the left rail), not Chat.
30
+
31
+ ## One-time setup
32
+
33
+ ```sh
34
+ npm install -g @fetchproxy/cli # provides `fpx`, needs 2.1.0+ (read_dom_list)
35
+ fpx profile add teams --domain teams.microsoft.com --domain teams.cloud.microsoft
36
+ fpx profile declare teams --dom-list-selector \
37
+ 'chatList=[data-testid="list-item"]::title:[id^="title-chat-list-item_"],preview:[data-testid="comfy-message"],time:[id^="time-chat-list-item_"],conversationKey:@data-fui-tree-item-value,itemType:@data-item-type&max=200'
38
+ fpx profile declare teams --dom-list-selector \
39
+ 'chatMessages=.fui-ChatMessage, .fui-ChatMyMessage::sender:[data-tid="message-author-name"],time:time@datetime,messageId:time@id,text:[data-tid="chat-pane-message"]&max=200'
40
+ fpx profile declare teams --dom-list-selector \
41
+ 'teamsAndChannels=[data-item-type="team"], [data-item-type="channel"]::title:[id^="title-"][id*="-list-item-"],teamName:[id^="preview-channel-list-item-"],time:[id^="time-"][id*="-list-item-"],conversationKey:@data-fui-tree-item-value,itemType:@data-item-type&max=300'
42
+ fpx profile declare teams --dom-list-selector \
43
+ 'channelPosts=[data-tid="channel-pane-message"]::sender:[id^="author-"],subject:[id^="subject-line-"],time:time[data-tid="timestamp"]@aria-label,messageId:time[data-tid="timestamp"]@id,text:[id^="content-"]&max=200'
44
+ ```
45
+
46
+ Each `--dom-list-selector` flag declares a DIFFERENT named selector on the
47
+ same profile — run all four, not just one. Requirements: the
48
+ **Transporter** browser extension installed, with an open
49
+ `teams.microsoft.com` (or `teams.cloud.microsoft`) tab you're signed into.
50
+ The first `dom-list` call prints a pair code — approve it in the Transporter
51
+ popup; the grant persists until the declared scope changes again (each
52
+ `declare` above widens it once).
53
+
54
+ ## Core calls
55
+
56
+ ```sh
57
+ fpx dom-list chatList -p teams --storage-domain teams.microsoft.com | jq
58
+ fpx dom-list chatMessages -p teams --storage-domain teams.microsoft.com | jq
59
+ fpx dom-list teamsAndChannels -p teams --storage-domain teams.microsoft.com | jq
60
+ fpx dom-list channelPosts -p teams --storage-domain teams.microsoft.com | jq
61
+ ```
62
+
63
+ `--storage-domain` is required whenever a profile declares more than one
64
+ domain (this one does) — it tells fpx which declared domain's tab to target.
65
+ Use `teams.cloud.microsoft` instead if that's where your signed-in tab lives.
66
+
67
+ Ready-to-run recipes (jq filters for all four selectors) are in
68
+ `references/dom-list-recipes.md`.
69
+
70
+ ## Exit codes
71
+
72
+ - `0` — success.
73
+ - `2` — bridge unavailable: extension not connected, or pairing pending →
74
+ run the command again and approve the printed pair code, or check
75
+ `fpx health -p teams`.
76
+ - Error text containing `not in declared set` — the profile's declared scope
77
+ changed since you last paired. Revoke `fpx-teams` in the Transporter popup
78
+ and re-run; you'll be asked to approve the new scope.
79
+
80
+ ## Notes
81
+
82
+ - Read-only. Nothing here can send a message, open a chat/channel, or
83
+ interact with the page — `read_dom_list` only reads what's already
84
+ rendered.
85
+ - Sender names resolve even on consecutive messages from the same person,
86
+ where Teams visually hides the name — it's still in the DOM.
87
+ - A quoted chat reply's `text` field includes the quoted preview
88
+ concatenated in; same for a channel post that includes a reply preview.
89
+ - `channelPosts.time` is prose ("Tuesday, August 4, 2026 7:50 AM"), not
90
+ ISO 8601 — Teams' channel-post timestamp carries no `datetime` attribute,
91
+ unlike `chatMessages.time`.
92
+ - If your browser has more than one `teams.microsoft.com` tab open, the
93
+ bridge reads whichever answers first, not necessarily the one you meant —
94
+ close extras.
95
+ - This project is developed and maintained by AI (Claude).