@mindstone/mcp-server-microsoft-teams 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/CHANGELOG.md +11 -0
- package/LICENSE +97 -0
- package/README.md +35 -0
- package/dist/client.d.ts +6 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +52 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.d.ts.map +1 -0
- package/dist/server.js +12 -0
- package/dist/server.js.map +1 -0
- package/dist/teams.d.ts +15 -0
- package/dist/teams.d.ts.map +1 -0
- package/dist/teams.js +175 -0
- package/dist/teams.js.map +1 -0
- package/dist/tools.d.ts +3 -0
- package/dist/tools.d.ts.map +1 -0
- package/dist/tools.js +63 -0
- package/dist/tools.js.map +1 -0
- package/dist/types.d.ts +7 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +25 -0
- package/dist/types.js.map +1 -0
- package/dist/utils.d.ts +20 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +171 -0
- package/dist/utils.js.map +1 -0
- package/package.json +55 -0
- package/server.json +71 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this connector will be documented in this file.
|
|
4
|
+
|
|
5
|
+
## [Unreleased]
|
|
6
|
+
|
|
7
|
+
## [0.1.0] - 2026-05-19
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- Initial Microsoft 365 Teams MCP server with seven tools for chats, messages, search, channels, sends, and replies.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Functional Source License, Version 1.1, MIT Future License
|
|
2
|
+
|
|
3
|
+
## Abbreviation
|
|
4
|
+
|
|
5
|
+
FSL-1.1-MIT
|
|
6
|
+
|
|
7
|
+
## Notice
|
|
8
|
+
|
|
9
|
+
Copyright 2026 Mindstone Learning Limited
|
|
10
|
+
|
|
11
|
+
## Terms and Conditions
|
|
12
|
+
|
|
13
|
+
### Licensor ("We")
|
|
14
|
+
|
|
15
|
+
The party offering the Software under these Terms and Conditions.
|
|
16
|
+
|
|
17
|
+
**Licensor**: Mindstone Learning Limited
|
|
18
|
+
|
|
19
|
+
### The Software
|
|
20
|
+
|
|
21
|
+
The "Software" is each version of the software that we make available under
|
|
22
|
+
these Terms and Conditions, as indicated by our inclusion of these Terms and
|
|
23
|
+
Conditions with the Software.
|
|
24
|
+
|
|
25
|
+
**Software**: Microsoft 365 Teams MCP Server
|
|
26
|
+
|
|
27
|
+
### License Grant
|
|
28
|
+
|
|
29
|
+
Subject to your compliance with this License Grant and the Patents,
|
|
30
|
+
Redistribution and Trademark clauses below, we hereby grant you the right to
|
|
31
|
+
use, copy, modify, create derivative works, publicly perform, publicly display
|
|
32
|
+
and redistribute the Software for any Permitted Purpose identified below.
|
|
33
|
+
|
|
34
|
+
### Permitted Purpose
|
|
35
|
+
|
|
36
|
+
A Permitted Purpose is any purpose other than a Competing Use. A "Competing
|
|
37
|
+
Use" means making the Software available to third parties as a commercial
|
|
38
|
+
hosted service that directly competes with any product or service provided by
|
|
39
|
+
the Licensor.
|
|
40
|
+
|
|
41
|
+
### Patents
|
|
42
|
+
|
|
43
|
+
To the extent your use for a Permitted Purpose would necessarily infringe our
|
|
44
|
+
patents, the license grant above includes a license under our patents. If you
|
|
45
|
+
make a claim against any party that the Software infringes or contributes to
|
|
46
|
+
the infringement of any patent, then your patent license to the Software ends
|
|
47
|
+
immediately.
|
|
48
|
+
|
|
49
|
+
### Redistribution
|
|
50
|
+
|
|
51
|
+
The Terms and Conditions apply to all copies, modifications and derivatives of
|
|
52
|
+
the Software.
|
|
53
|
+
|
|
54
|
+
If you redistribute any copies, modifications or derivatives of the Software,
|
|
55
|
+
you must include a copy of or a link to these Terms and Conditions and not
|
|
56
|
+
remove any copyright notices provided in or with the Software.
|
|
57
|
+
|
|
58
|
+
### Disclaimer
|
|
59
|
+
|
|
60
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
|
|
61
|
+
IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
|
|
62
|
+
PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
|
|
63
|
+
|
|
64
|
+
IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
|
|
65
|
+
SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES, OF
|
|
66
|
+
ANY CHARACTER INCLUDING DAMAGES FOR LOSS OF GOODWILL, LOST PROFITS, LOST SALES
|
|
67
|
+
OR BUSINESS, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, LOST CONTENT,
|
|
68
|
+
DATA OR DATA USE, BREACH OF DUTY OF GOOD FAITH, OR ANY AND ALL OTHER DAMAGES
|
|
69
|
+
OR LOSSES OF ANY KIND OR NATURE WHATSOEVER (WHETHER DIRECT, INDIRECT, SPECIAL,
|
|
70
|
+
COLLATERAL, INCIDENTAL, CONSEQUENTIAL OR OTHERWISE) ARISING OUT OF OR IN
|
|
71
|
+
CONNECTION WITH THE SOFTWARE OR THIS LICENSE, EVEN IF SUCH PARTY SHALL HAVE
|
|
72
|
+
BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES.
|
|
73
|
+
|
|
74
|
+
### Trademark
|
|
75
|
+
|
|
76
|
+
Except for displaying the License Details and identifying us as the origin of
|
|
77
|
+
the Software, you have no right under these Terms and Conditions to use our
|
|
78
|
+
trademarks, trade names, service marks or product names.
|
|
79
|
+
|
|
80
|
+
## Change Date
|
|
81
|
+
|
|
82
|
+
Four years from the date the Software is made available under these Terms and
|
|
83
|
+
Conditions: **2030-05-19**
|
|
84
|
+
|
|
85
|
+
## Change License
|
|
86
|
+
|
|
87
|
+
MIT License
|
|
88
|
+
|
|
89
|
+
## License Details
|
|
90
|
+
|
|
91
|
+
| Parameter | Value |
|
|
92
|
+
|---|---|
|
|
93
|
+
| Licensor | Mindstone Learning Limited |
|
|
94
|
+
| Software | Microsoft 365 Teams MCP Server |
|
|
95
|
+
| Use Limitation | Competing Use |
|
|
96
|
+
| Change Date | 2030-05-19 |
|
|
97
|
+
| Change License | MIT |
|
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Microsoft 365 Teams MCP Server
|
|
2
|
+
|
|
3
|
+
Read and write Microsoft Teams chats, teams, channels, and presence through Microsoft Graph.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npx -y @mindstone/mcp-server-microsoft-teams
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Configuration
|
|
12
|
+
|
|
13
|
+
This server uses host-orchestrated Microsoft 365 OAuth. Configure these environment variables from your MCP host:
|
|
14
|
+
|
|
15
|
+
| Variable | Required | Description |
|
|
16
|
+
|---|---:|---|
|
|
17
|
+
| `MS_CLIENT_ID` | yes | Microsoft Entra application client ID |
|
|
18
|
+
| `MS_CONFIG_DIR` | yes | Microsoft config directory containing account credentials |
|
|
19
|
+
| `MS_ACCOUNT_EMAIL` | no | Account email for multi-account mode |
|
|
20
|
+
| `MS_MCP_PACKAGE_ID` | no | Logical package ID in recovery responses |
|
|
21
|
+
| `MICROSOFT_REQUEST_TIMEOUT_MS` | no | Upstream Graph timeout in milliseconds, max 300000 |
|
|
22
|
+
|
|
23
|
+
## Tools
|
|
24
|
+
|
|
25
|
+
| Tool | Description |
|
|
26
|
+
|---|---|
|
|
27
|
+
| `list_chats` | List recent Teams chats |
|
|
28
|
+
| `get_chat` | Get details about a specific chat |
|
|
29
|
+
| `list_chat_messages` | List recent messages from a chat |
|
|
30
|
+
| `send_chat_message` | Send a message to a chat |
|
|
31
|
+
| `list_teams` | List Teams you are a member of |
|
|
32
|
+
| `list_channels` | List channels in a team |
|
|
33
|
+
| `get_presence` | Get your current presence status |
|
|
34
|
+
|
|
35
|
+
Some Teams Graph APIs may require tenant admin approval.
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { type Client, type TokenProvider } from '@mindstone/mcp-server-microsoft-shared';
|
|
2
|
+
export declare function getGraphClient(): Client;
|
|
3
|
+
export declare function getTokenProvider(): TokenProvider;
|
|
4
|
+
export declare function withGraphRetry<T>(fn: (client: Client, signal: AbortSignal) => Promise<T>, signal: AbortSignal): Promise<T>;
|
|
5
|
+
export declare function callGraph<T>(extra: unknown, fn: (client: Client, signal: AbortSignal) => Promise<T>): Promise<T>;
|
|
6
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,MAAM,EAEX,KAAK,aAAa,EACnB,MAAM,wCAAwC,CAAC;AA+BhD,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,gBAAgB,IAAI,aAAa,CAEhD;AAED,wBAAsB,cAAc,CAAC,CAAC,EACpC,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,EACvD,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,CAAC,CAAC,CAaZ;AAED,wBAAsB,SAAS,CAAC,CAAC,EAC/B,KAAK,EAAE,OAAO,EACd,EAAE,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,KAAK,OAAO,CAAC,CAAC,CAAC,GACtD,OAAO,CAAC,CAAC,CAAC,CAGZ"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { createGraphClientWithRetry, createLogger, } from '@mindstone/mcp-server-microsoft-shared';
|
|
2
|
+
import { abortableSignal, extractCallerSignal, runWithSignal } from './utils.js';
|
|
3
|
+
const log = createLogger('microsoft-teams-mcp');
|
|
4
|
+
const MS_CONFIG_DIR = process.env.MS_CONFIG_DIR ?? '';
|
|
5
|
+
const MS_CLIENT_ID = process.env.MS_CLIENT_ID ?? '';
|
|
6
|
+
const MS_ACCOUNT_EMAIL = process.env.MS_ACCOUNT_EMAIL || undefined;
|
|
7
|
+
let cached = null;
|
|
8
|
+
let initError = null;
|
|
9
|
+
function ensureInitialized() {
|
|
10
|
+
if (cached)
|
|
11
|
+
return cached;
|
|
12
|
+
if (initError)
|
|
13
|
+
throw new Error(initError);
|
|
14
|
+
if (!MS_CONFIG_DIR || !MS_CLIENT_ID) {
|
|
15
|
+
initError =
|
|
16
|
+
'Missing required environment variables: MS_CONFIG_DIR, MS_CLIENT_ID. Connect Microsoft 365 via the host application before invoking tools.';
|
|
17
|
+
log.error(initError);
|
|
18
|
+
throw new Error(initError);
|
|
19
|
+
}
|
|
20
|
+
cached = createGraphClientWithRetry({
|
|
21
|
+
configDir: MS_CONFIG_DIR,
|
|
22
|
+
clientId: MS_CLIENT_ID,
|
|
23
|
+
email: MS_ACCOUNT_EMAIL,
|
|
24
|
+
});
|
|
25
|
+
return cached;
|
|
26
|
+
}
|
|
27
|
+
export function getGraphClient() {
|
|
28
|
+
return ensureInitialized().client;
|
|
29
|
+
}
|
|
30
|
+
export function getTokenProvider() {
|
|
31
|
+
return ensureInitialized().tokenProvider;
|
|
32
|
+
}
|
|
33
|
+
export async function withGraphRetry(fn, signal) {
|
|
34
|
+
const { client, tokenProvider } = ensureInitialized();
|
|
35
|
+
try {
|
|
36
|
+
return await fn(client, signal);
|
|
37
|
+
}
|
|
38
|
+
catch (err) {
|
|
39
|
+
const statusCode = err?.statusCode;
|
|
40
|
+
if (statusCode === 401) {
|
|
41
|
+
log.warn('Got 401, invalidating cached token and retrying');
|
|
42
|
+
tokenProvider.invalidateCachedToken();
|
|
43
|
+
return fn(client, signal);
|
|
44
|
+
}
|
|
45
|
+
throw err;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
export async function callGraph(extra, fn) {
|
|
49
|
+
const signal = abortableSignal(extractCallerSignal(extra));
|
|
50
|
+
return runWithSignal(withGraphRetry(fn, signal), signal);
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,YAAY,GAIb,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAEjF,MAAM,GAAG,GAAG,YAAY,CAAC,qBAAqB,CAAC,CAAC;AAEhD,MAAM,aAAa,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,CAAC;AACtD,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,EAAE,CAAC;AACpD,MAAM,gBAAgB,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,IAAI,SAAS,CAAC;AAEnE,IAAI,MAAM,GAAgC,IAAI,CAAC;AAC/C,IAAI,SAAS,GAAkB,IAAI,CAAC;AAEpC,SAAS,iBAAiB;IACxB,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC;IAC1B,IAAI,SAAS;QAAE,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IAE1C,IAAI,CAAC,aAAa,IAAI,CAAC,YAAY,EAAE,CAAC;QACpC,SAAS;YACP,4IAA4I,CAAC;QAC/I,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;QACrB,MAAM,IAAI,KAAK,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,GAAG,0BAA0B,CAAC;QAClC,SAAS,EAAE,aAAa;QACxB,QAAQ,EAAE,YAAY;QACtB,KAAK,EAAE,gBAAgB;KACxB,CAAC,CAAC;IACH,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,cAAc;IAC5B,OAAO,iBAAiB,EAAE,CAAC,MAAM,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,iBAAiB,EAAE,CAAC,aAAa,CAAC;AAC3C,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,EAAuD,EACvD,MAAmB;IAEnB,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,GAAG,iBAAiB,EAAE,CAAC;IACtD,IAAI,CAAC;QACH,OAAO,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,MAAM,UAAU,GAAI,GAA+B,EAAE,UAAU,CAAC;QAChE,IAAI,UAAU,KAAK,GAAG,EAAE,CAAC;YACvB,GAAG,CAAC,IAAI,CAAC,iDAAiD,CAAC,CAAC;YAC5D,aAAa,CAAC,qBAAqB,EAAE,CAAC;YACtC,OAAO,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC5B,CAAC;QACD,MAAM,GAAG,CAAC;IACZ,CAAC;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,KAAc,EACd,EAAuD;IAEvD,MAAM,MAAM,GAAG,eAAe,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAC,CAAC;IAC3D,OAAO,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC;AAC3D,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Microsoft 365 Teams MCP Server.
|
|
4
|
+
*
|
|
5
|
+
* Environment variables (injected by the host):
|
|
6
|
+
* - MS_CONFIG_DIR Path to the per-user Microsoft config dir
|
|
7
|
+
* (credentials/, accounts.json).
|
|
8
|
+
* - MS_CLIENT_ID Microsoft Entra (Azure AD) application client ID.
|
|
9
|
+
* - MS_ACCOUNT_EMAIL Account email when running in multi-account
|
|
10
|
+
* per-instance mode. Optional; falls back to the
|
|
11
|
+
* first account in accounts.json.
|
|
12
|
+
* - MS_MCP_PACKAGE_ID Logical package ID surfaced in error responses.
|
|
13
|
+
* Defaults to "Microsoft365Teams".
|
|
14
|
+
* - MICROSOFT_REQUEST_TIMEOUT_MS Override the default 60s upstream timeout
|
|
15
|
+
* (positive integer ≤ 300000).
|
|
16
|
+
* - MICROSOFT_DISABLE_REFRESH=1 Disable token refresh on this surface; the
|
|
17
|
+
* connector fails-closed with the structured
|
|
18
|
+
* auth_required response so the host can drive
|
|
19
|
+
* reauth.
|
|
20
|
+
*/
|
|
21
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
22
|
+
import { createServer } from './server.js';
|
|
23
|
+
import { SERVER_VERSION } from './types.js';
|
|
24
|
+
if (process.argv.includes('--version') || process.argv.includes('-v')) {
|
|
25
|
+
console.log(SERVER_VERSION);
|
|
26
|
+
process.exit(0);
|
|
27
|
+
}
|
|
28
|
+
if (process.argv.includes('--help') || process.argv.includes('-h')) {
|
|
29
|
+
console.log('Microsoft 365 Teams MCP Server. Configure MS_CONFIG_DIR + MS_CLIENT_ID and run over stdio from an MCP host.');
|
|
30
|
+
process.exit(0);
|
|
31
|
+
}
|
|
32
|
+
async function main() {
|
|
33
|
+
const server = createServer();
|
|
34
|
+
const transport = new StdioServerTransport();
|
|
35
|
+
await server.connect(transport);
|
|
36
|
+
console.error('[microsoft-teams-mcp] running on stdio');
|
|
37
|
+
}
|
|
38
|
+
process.on('SIGINT', () => process.exit(0));
|
|
39
|
+
process.on('SIGTERM', () => process.exit(0));
|
|
40
|
+
main().catch((error) => {
|
|
41
|
+
console.error('Fatal error:', error);
|
|
42
|
+
process.exit(1);
|
|
43
|
+
});
|
|
44
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;GAkBG;AACH,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE5C,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACtE,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC5B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;IACnE,OAAO,CAAC,GAAG,CACT,6GAA6G,CAC9G,CAAC;IACF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,MAAM,GAAG,YAAY,EAAE,CAAC;IAC9B,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,OAAO,CAAC,KAAK,CAAC,wCAAwC,CAAC,CAAC;AAC1D,CAAC;AAED,OAAO,CAAC,EAAE,CAAC,QAAQ,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAE7C,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,OAAO,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IACrC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAIpE,wBAAgB,YAAY,IAAI,SAAS,CAOxC"}
|
package/dist/server.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
2
|
+
import { SERVER_NAME, SERVER_VERSION } from './types.js';
|
|
3
|
+
import { registerTeamsTools } from './tools.js';
|
|
4
|
+
export function createServer() {
|
|
5
|
+
const server = new McpServer({
|
|
6
|
+
name: SERVER_NAME,
|
|
7
|
+
version: SERVER_VERSION,
|
|
8
|
+
});
|
|
9
|
+
registerTeamsTools(server);
|
|
10
|
+
return server;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAEhD,MAAM,UAAU,YAAY;IAC1B,MAAM,MAAM,GAAG,IAAI,SAAS,CAAC;QAC3B,IAAI,EAAE,WAAW;QACjB,OAAO,EAAE,cAAc;KACxB,CAAC,CAAC;IACH,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC3B,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/teams.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Client } from '@mindstone/mcp-server-microsoft-shared';
|
|
2
|
+
export declare class TeamsBusinessError extends Error {
|
|
3
|
+
readonly nextStep: string;
|
|
4
|
+
constructor(message: string, nextStep: string);
|
|
5
|
+
}
|
|
6
|
+
type ArgBag = Record<string, unknown>;
|
|
7
|
+
export declare function listChats(client: Client, args: ArgBag, signal: AbortSignal): Promise<unknown>;
|
|
8
|
+
export declare function getChat(client: Client, args: ArgBag, signal: AbortSignal): Promise<unknown>;
|
|
9
|
+
export declare function listChatMessages(client: Client, args: ArgBag, signal: AbortSignal): Promise<unknown>;
|
|
10
|
+
export declare function sendChatMessage(client: Client, args: ArgBag, signal: AbortSignal): Promise<unknown>;
|
|
11
|
+
export declare function listTeams(client: Client, _args: ArgBag, signal: AbortSignal): Promise<unknown>;
|
|
12
|
+
export declare function listChannels(client: Client, args: ArgBag, signal: AbortSignal): Promise<unknown>;
|
|
13
|
+
export declare function getPresence(client: Client, _args: ArgBag, signal: AbortSignal): Promise<unknown>;
|
|
14
|
+
export {};
|
|
15
|
+
//# sourceMappingURL=teams.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.d.ts","sourceRoot":"","sources":["../src/teams.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAqB,MAAM,EAAE,MAAM,wCAAwC,CAAC;AAExF,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAEd,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;CAK9C;AAMD,KAAK,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AA6DtC,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CA0BlB;AAED,wBAAsB,OAAO,CAC3B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAoBlB;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAelB;AAwBD,wBAAsB,SAAS,CAC7B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAgBlB;AAED,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAalB;AAYD,wBAAsB,WAAW,CAC/B,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,MAAM,EACb,MAAM,EAAE,WAAW,GAClB,OAAO,CAAC,OAAO,CAAC,CAOlB"}
|
package/dist/teams.js
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
export class TeamsBusinessError extends Error {
|
|
2
|
+
nextStep;
|
|
3
|
+
constructor(message, nextStep) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.name = 'TeamsBusinessError';
|
|
6
|
+
this.nextStep = nextStep;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
function stringArg(args, ...names) {
|
|
10
|
+
for (const name of names) {
|
|
11
|
+
const value = args[name];
|
|
12
|
+
if (typeof value === 'string' && value.trim())
|
|
13
|
+
return value.trim();
|
|
14
|
+
}
|
|
15
|
+
return undefined;
|
|
16
|
+
}
|
|
17
|
+
function numberArg(args, ...names) {
|
|
18
|
+
for (const name of names) {
|
|
19
|
+
const value = args[name];
|
|
20
|
+
if (typeof value === 'number' && Number.isFinite(value))
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
function clampTop(value, defaultValue, maxValue) {
|
|
26
|
+
if (value == null)
|
|
27
|
+
return defaultValue;
|
|
28
|
+
return Math.max(1, Math.min(value, maxValue));
|
|
29
|
+
}
|
|
30
|
+
function stripHtml(html) {
|
|
31
|
+
return html
|
|
32
|
+
.replace(/<[^>]*>/g, '')
|
|
33
|
+
.replace(/ /g, ' ')
|
|
34
|
+
.replace(/&/g, '&')
|
|
35
|
+
.replace(/</g, '<')
|
|
36
|
+
.replace(/>/g, '>')
|
|
37
|
+
.replace(/"/g, '"')
|
|
38
|
+
.trim();
|
|
39
|
+
}
|
|
40
|
+
function requireStringArg(args, name, label, nextStep) {
|
|
41
|
+
const value = stringArg(args, name);
|
|
42
|
+
if (value)
|
|
43
|
+
return value;
|
|
44
|
+
throw new TeamsBusinessError(`Missing required parameter: "${name}" (${label}).`, nextStep);
|
|
45
|
+
}
|
|
46
|
+
function formatMessage(msg) {
|
|
47
|
+
return {
|
|
48
|
+
id: msg.id,
|
|
49
|
+
from: msg.from?.user?.displayName ?? 'Unknown',
|
|
50
|
+
content: stripHtml(msg.body?.content ?? ''),
|
|
51
|
+
contentType: msg.body?.contentType,
|
|
52
|
+
createdAt: msg.createdDateTime,
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
export async function listChats(client, args, signal) {
|
|
56
|
+
const top = clampTop(numberArg(args, 'top'), 25, 50);
|
|
57
|
+
const response = (await client
|
|
58
|
+
.api('/me/chats')
|
|
59
|
+
.options({ signal })
|
|
60
|
+
.top(top)
|
|
61
|
+
.select('id,topic,chatType,createdDateTime,lastUpdatedDateTime')
|
|
62
|
+
.get());
|
|
63
|
+
const chats = (response.value ?? []).sort((a, b) => {
|
|
64
|
+
const dateA = a.lastUpdatedDateTime ? new Date(a.lastUpdatedDateTime).getTime() : 0;
|
|
65
|
+
const dateB = b.lastUpdatedDateTime ? new Date(b.lastUpdatedDateTime).getTime() : 0;
|
|
66
|
+
return dateB - dateA;
|
|
67
|
+
});
|
|
68
|
+
return {
|
|
69
|
+
count: chats.length,
|
|
70
|
+
chats: chats.map((chat) => ({
|
|
71
|
+
id: chat.id,
|
|
72
|
+
topic: chat.topic ?? '(No topic)',
|
|
73
|
+
type: chat.chatType,
|
|
74
|
+
createdAt: chat.createdDateTime,
|
|
75
|
+
lastUpdated: chat.lastUpdatedDateTime,
|
|
76
|
+
})),
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
export async function getChat(client, args, signal) {
|
|
80
|
+
const chatId = requireStringArg(args, 'chatId', 'chat ID', 'get_chat');
|
|
81
|
+
const chat = (await client
|
|
82
|
+
.api(`/me/chats/${chatId}`)
|
|
83
|
+
.options({ signal })
|
|
84
|
+
.expand('members')
|
|
85
|
+
.get());
|
|
86
|
+
return {
|
|
87
|
+
id: chat.id,
|
|
88
|
+
topic: chat.topic ?? '(No topic)',
|
|
89
|
+
type: chat.chatType,
|
|
90
|
+
createdAt: chat.createdDateTime,
|
|
91
|
+
lastUpdated: chat.lastUpdatedDateTime,
|
|
92
|
+
members: chat.members?.map((member) => ({
|
|
93
|
+
displayName: member.displayName,
|
|
94
|
+
email: member.email,
|
|
95
|
+
roles: member.roles,
|
|
96
|
+
})),
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
export async function listChatMessages(client, args, signal) {
|
|
100
|
+
const chatId = requireStringArg(args, 'chatId', 'chat ID', 'list_chat_messages');
|
|
101
|
+
const top = clampTop(numberArg(args, 'top'), 50, 50);
|
|
102
|
+
const response = (await client
|
|
103
|
+
.api(`/me/chats/${chatId}/messages`)
|
|
104
|
+
.options({ signal })
|
|
105
|
+
.top(top)
|
|
106
|
+
.get());
|
|
107
|
+
const messages = response.value ?? [];
|
|
108
|
+
return {
|
|
109
|
+
chatId,
|
|
110
|
+
count: messages.length,
|
|
111
|
+
messages: messages.map(formatMessage),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
export async function sendChatMessage(client, args, signal) {
|
|
115
|
+
const chatId = requireStringArg(args, 'chatId', 'chat ID', 'send_chat_message');
|
|
116
|
+
const content = requireStringArg(args, 'content', 'message body', 'send_chat_message');
|
|
117
|
+
const response = (await client.api(`/me/chats/${chatId}/messages`).options({ signal }).post({
|
|
118
|
+
body: {
|
|
119
|
+
contentType: content.includes('<') ? 'html' : 'text',
|
|
120
|
+
content,
|
|
121
|
+
},
|
|
122
|
+
}));
|
|
123
|
+
return {
|
|
124
|
+
success: true,
|
|
125
|
+
messageId: response.id,
|
|
126
|
+
message: 'Message sent successfully',
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function formatChannel(channel) {
|
|
130
|
+
return {
|
|
131
|
+
id: channel.id,
|
|
132
|
+
name: channel.displayName,
|
|
133
|
+
description: channel.description,
|
|
134
|
+
membershipType: channel.membershipType,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
export async function listTeams(client, _args, signal) {
|
|
138
|
+
const response = (await client
|
|
139
|
+
.api('/me/joinedTeams')
|
|
140
|
+
.options({ signal })
|
|
141
|
+
.select('id,displayName,description')
|
|
142
|
+
.get());
|
|
143
|
+
const teams = response.value ?? [];
|
|
144
|
+
return {
|
|
145
|
+
count: teams.length,
|
|
146
|
+
teams: teams.map((team) => ({
|
|
147
|
+
id: team.id,
|
|
148
|
+
name: team.displayName,
|
|
149
|
+
description: team.description,
|
|
150
|
+
})),
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
export async function listChannels(client, args, signal) {
|
|
154
|
+
const teamId = requireStringArg(args, 'teamId', 'team ID', 'list_channels');
|
|
155
|
+
const response = (await client
|
|
156
|
+
.api(`/teams/${teamId}/channels`)
|
|
157
|
+
.options({ signal })
|
|
158
|
+
.select('id,displayName,description,membershipType')
|
|
159
|
+
.get());
|
|
160
|
+
const channels = response.value ?? [];
|
|
161
|
+
return {
|
|
162
|
+
teamId,
|
|
163
|
+
count: channels.length,
|
|
164
|
+
channels: channels.map(formatChannel),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
export async function getPresence(client, _args, signal) {
|
|
168
|
+
const presence = (await client.api('/me/presence').options({ signal }).get());
|
|
169
|
+
return {
|
|
170
|
+
availability: presence.availability,
|
|
171
|
+
activity: presence.activity,
|
|
172
|
+
statusMessage: presence.statusMessage?.message?.content,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
//# sourceMappingURL=teams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teams.js","sourceRoot":"","sources":["../src/teams.ts"],"names":[],"mappings":"AAEA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,QAAQ,CAAS;IAE1B,YAAY,OAAe,EAAE,QAAgB;QAC3C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAQD,SAAS,SAAS,CAAC,IAAY,EAAE,GAAG,KAAe;IACjD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE;YAAE,OAAO,KAAK,CAAC,IAAI,EAAE,CAAC;IACrE,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,SAAS,SAAS,CAAC,IAAY,EAAE,GAAG,KAAe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,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC;KACtC,CAAC;AACJ,CAAC;AAYD,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAc,EACd,KAAa,EACb,MAAmB;IAEnB,MAAM,QAAQ,GAAG,CAAC,MAAM,MAAM,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,GAAG,EAAE,CAAa,CAAC;IAC1F,OAAO;QACL,YAAY,EAAE,QAAQ,CAAC,YAAY;QACnC,QAAQ,EAAE,QAAQ,CAAC,QAAQ;QAC3B,aAAa,EAAE,QAAQ,CAAC,aAAa,EAAE,OAAO,EAAE,OAAO;KACxD,CAAC;AACJ,CAAC"}
|
package/dist/tools.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AAyBzE,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,SAAS,GAAG,IAAI,CAgG1D"}
|
package/dist/tools.js
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { callGraph } from './client.js';
|
|
3
|
+
import { successJson, withErrorHandling } from './utils.js';
|
|
4
|
+
import { getChat, getPresence, listChannels, listChats, listChatMessages, listTeams, sendChatMessage, } from './teams.js';
|
|
5
|
+
const READ_ANNOTATIONS = {
|
|
6
|
+
readOnlyHint: true,
|
|
7
|
+
openWorldHint: true,
|
|
8
|
+
};
|
|
9
|
+
const WRITE_ANNOTATIONS = {
|
|
10
|
+
readOnlyHint: false,
|
|
11
|
+
destructiveHint: false,
|
|
12
|
+
openWorldHint: true,
|
|
13
|
+
};
|
|
14
|
+
export function registerTeamsTools(server) {
|
|
15
|
+
server.registerTool('list_chats', {
|
|
16
|
+
description: 'List recent Teams chats (1:1, group, and meeting chats).',
|
|
17
|
+
inputSchema: z.object({
|
|
18
|
+
top: z.number().optional().describe('Max chats to return (default: 25, max: 50)'),
|
|
19
|
+
}).shape,
|
|
20
|
+
annotations: READ_ANNOTATIONS,
|
|
21
|
+
}, withErrorHandling(async (args, extra) => successJson(await callGraph(extra, (c, signal) => listChats(c, args, signal)))));
|
|
22
|
+
server.registerTool('get_chat', {
|
|
23
|
+
description: 'Get details about a specific chat.',
|
|
24
|
+
inputSchema: z.object({
|
|
25
|
+
chatId: z.string().describe('Chat ID'),
|
|
26
|
+
}).shape,
|
|
27
|
+
annotations: READ_ANNOTATIONS,
|
|
28
|
+
}, withErrorHandling(async (args, extra) => successJson(await callGraph(extra, (c, signal) => getChat(c, args, signal)))));
|
|
29
|
+
server.registerTool('list_chat_messages', {
|
|
30
|
+
description: 'Get recent messages from a chat.',
|
|
31
|
+
inputSchema: z.object({
|
|
32
|
+
chatId: z.string().describe('Chat ID'),
|
|
33
|
+
top: z.number().optional().describe('Max messages to return (default: 50, max: 50)'),
|
|
34
|
+
}).shape,
|
|
35
|
+
annotations: READ_ANNOTATIONS,
|
|
36
|
+
}, withErrorHandling(async (args, extra) => successJson(await callGraph(extra, (c, signal) => listChatMessages(c, args, signal)))));
|
|
37
|
+
server.registerTool('send_chat_message', {
|
|
38
|
+
description: 'Send a message to a chat.',
|
|
39
|
+
inputSchema: z.object({
|
|
40
|
+
chatId: z.string().describe('Chat ID'),
|
|
41
|
+
content: z.string().describe('Message content (HTML supported)'),
|
|
42
|
+
}).shape,
|
|
43
|
+
annotations: WRITE_ANNOTATIONS,
|
|
44
|
+
}, withErrorHandling(async (args, extra) => successJson(await callGraph(extra, (c, signal) => sendChatMessage(c, args, signal)))));
|
|
45
|
+
server.registerTool('list_teams', {
|
|
46
|
+
description: 'List Teams you are a member of.',
|
|
47
|
+
inputSchema: z.object({}).shape,
|
|
48
|
+
annotations: READ_ANNOTATIONS,
|
|
49
|
+
}, withErrorHandling(async (args, extra) => successJson(await callGraph(extra, (c, signal) => listTeams(c, args, signal)))));
|
|
50
|
+
server.registerTool('list_channels', {
|
|
51
|
+
description: 'List channels in a Team.',
|
|
52
|
+
inputSchema: z.object({
|
|
53
|
+
teamId: z.string().describe('Team ID'),
|
|
54
|
+
}).shape,
|
|
55
|
+
annotations: READ_ANNOTATIONS,
|
|
56
|
+
}, withErrorHandling(async (args, extra) => successJson(await callGraph(extra, (c, signal) => listChannels(c, args, signal)))));
|
|
57
|
+
server.registerTool('get_presence', {
|
|
58
|
+
description: 'Get your current presence status (available, busy, away, etc.).',
|
|
59
|
+
inputSchema: z.object({}).shape,
|
|
60
|
+
annotations: READ_ANNOTATIONS,
|
|
61
|
+
}, withErrorHandling(async (args, extra) => successJson(await callGraph(extra, (c, signal) => getPresence(c, args, signal)))));
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=tools.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC5D,OAAO,EACL,OAAO,EACP,WAAW,EACX,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,gBAAgB,GAAG;IACvB,YAAY,EAAE,IAAI;IAClB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,iBAAiB,GAAG;IACxB,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,UAAU,kBAAkB,CAAC,MAAiB;IAClD,MAAM,CAAC,YAAY,CACjB,YAAY,EACZ;QACE,WAAW,EAAE,0DAA0D;QACvE,WAA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ACvC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC;SACvC,CAAC,CAAC,KAAK;QACR,WAAW,EAAE,gBAAgB;KAC9B,EACD,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CACtC,WAAW,CAAC,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,YAAY,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAClF,CACF,CAAC;IAEF,MAAM,CAAC,YAAY,CACjB,cAAc,EACd;QACE,WAAW,EAAE,iEAAiE;QAC9E,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,KAAK;QAC/B,WAAW,EAAE,gBAAgB;KAC9B,EACD,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,CACtC,WAAW,CAAC,MAAM,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CACjF,CACF,CAAC;AACJ,CAAC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const SERVER_NAME = "mcp-server-microsoft-teams";
|
|
2
|
+
export declare const SERVER_VERSION: string;
|
|
3
|
+
export declare const MS_PACKAGE_ID_DEFAULT = "Microsoft365Teams";
|
|
4
|
+
export declare const AUTH_TOOL_NAME = "authenticate_microsoft_account";
|
|
5
|
+
export declare const REQUEST_TIMEOUT_MS: number;
|
|
6
|
+
export declare function getMsPackageId(): string;
|
|
7
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,WAAW,+BAA+B,CAAC;AACxD,eAAO,MAAM,cAAc,QAAc,CAAC;AAE1C,eAAO,MAAM,qBAAqB,sBAAsB,CAAC;AACzD,eAAO,MAAM,cAAc,mCAAmC,CAAC;AAkB/D,eAAO,MAAM,kBAAkB,QAA4B,CAAC;AAE5D,wBAAgB,cAAc,IAAI,MAAM,CAEvC"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
const pkg = require('../package.json');
|
|
4
|
+
export const SERVER_NAME = 'mcp-server-microsoft-teams';
|
|
5
|
+
export const SERVER_VERSION = pkg.version;
|
|
6
|
+
export const MS_PACKAGE_ID_DEFAULT = 'Microsoft365Teams';
|
|
7
|
+
export const AUTH_TOOL_NAME = 'authenticate_microsoft_account';
|
|
8
|
+
const DEFAULT_REQUEST_TIMEOUT_MS = 60_000;
|
|
9
|
+
const MAX_REQUEST_TIMEOUT_MS = 300_000;
|
|
10
|
+
function resolveRequestTimeoutMs() {
|
|
11
|
+
const raw = process.env.MICROSOFT_REQUEST_TIMEOUT_MS;
|
|
12
|
+
if (!raw)
|
|
13
|
+
return DEFAULT_REQUEST_TIMEOUT_MS;
|
|
14
|
+
const parsed = Number.parseInt(raw, 10);
|
|
15
|
+
if (Number.isFinite(parsed) && parsed > 0 && parsed <= MAX_REQUEST_TIMEOUT_MS) {
|
|
16
|
+
return parsed;
|
|
17
|
+
}
|
|
18
|
+
console.error(`[microsoft-teams-mcp] MICROSOFT_REQUEST_TIMEOUT_MS=${raw} is invalid; falling back to ${DEFAULT_REQUEST_TIMEOUT_MS}ms.`);
|
|
19
|
+
return DEFAULT_REQUEST_TIMEOUT_MS;
|
|
20
|
+
}
|
|
21
|
+
export const REQUEST_TIMEOUT_MS = resolveRequestTimeoutMs();
|
|
22
|
+
export function getMsPackageId() {
|
|
23
|
+
return process.env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c;IAC5B,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,qBAAqB,CAAC;AAChE,CAAC"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
export declare function abortableSignal(callerSignal?: AbortSignal): AbortSignal;
|
|
3
|
+
export declare function extractCallerSignal(extra: unknown): AbortSignal | undefined;
|
|
4
|
+
export declare function runWithSignal<T>(promise: Promise<T>, signal: AbortSignal): Promise<T>;
|
|
5
|
+
export declare function buildAuthRequiredResponse(): Record<string, unknown>;
|
|
6
|
+
export declare function authRequiredJson(): string;
|
|
7
|
+
export interface ErrorPayload {
|
|
8
|
+
error: string;
|
|
9
|
+
action_required: string;
|
|
10
|
+
next_step: string;
|
|
11
|
+
reason?: string;
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
export declare function errorResponse(payload: ErrorPayload): CallToolResult;
|
|
15
|
+
export declare function successJson(data: unknown): string;
|
|
16
|
+
export declare function buildErrorResponse(err: unknown): CallToolResult;
|
|
17
|
+
type ToolHandler<T> = (args: T, extra: unknown) => Promise<CallToolResult>;
|
|
18
|
+
export declare function withErrorHandling<T>(fn: (args: T, extra: unknown) => Promise<string | CallToolResult>): ToolHandler<T>;
|
|
19
|
+
export {};
|
|
20
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AAUzE,wBAAgB,eAAe,CAAC,YAAY,CAAC,EAAE,WAAW,GAAG,WAAW,CAmBvE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,WAAW,GAAG,SAAS,CAM3E;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CA4BrF;AAED,wBAAgB,yBAAyB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAUnE;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAMD,wBAAgB,aAAa,CAAC,OAAO,EAAE,YAAY,GAAG,cAAc,CAKnE;AAED,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAEjD;AA6BD,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,cAAc,CAqC/D;AAED,KAAK,WAAW,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;AAE3E,wBAAgB,iBAAiB,CAAC,CAAC,EACjC,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,GAAG,cAAc,CAAC,GAChE,WAAW,CAAC,CAAC,CAAC,CAYhB"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { MicrosoftRefreshDisabledError, detectAuthRequiredReason, formatGraphError, } from '@mindstone/mcp-server-microsoft-shared';
|
|
2
|
+
import { TeamsBusinessError } from './teams.js';
|
|
3
|
+
import { AUTH_TOOL_NAME, REQUEST_TIMEOUT_MS, getMsPackageId } from './types.js';
|
|
4
|
+
export function abortableSignal(callerSignal) {
|
|
5
|
+
const timeoutSignal = AbortSignal.timeout(REQUEST_TIMEOUT_MS);
|
|
6
|
+
if (!callerSignal)
|
|
7
|
+
return timeoutSignal;
|
|
8
|
+
if (typeof AbortSignal.any === 'function') {
|
|
9
|
+
return AbortSignal.any([callerSignal, timeoutSignal]);
|
|
10
|
+
}
|
|
11
|
+
const controller = new AbortController();
|
|
12
|
+
const onAbort = (reason) => controller.abort(reason);
|
|
13
|
+
if (callerSignal.aborted) {
|
|
14
|
+
controller.abort(callerSignal.reason);
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
callerSignal.addEventListener('abort', () => onAbort(callerSignal.reason), { once: true });
|
|
18
|
+
}
|
|
19
|
+
if (timeoutSignal.aborted) {
|
|
20
|
+
controller.abort(timeoutSignal.reason);
|
|
21
|
+
}
|
|
22
|
+
else {
|
|
23
|
+
timeoutSignal.addEventListener('abort', () => onAbort(timeoutSignal.reason), { once: true });
|
|
24
|
+
}
|
|
25
|
+
return controller.signal;
|
|
26
|
+
}
|
|
27
|
+
export function extractCallerSignal(extra) {
|
|
28
|
+
if (extra && typeof extra === 'object' && 'signal' in extra) {
|
|
29
|
+
const signal = extra.signal;
|
|
30
|
+
if (signal instanceof AbortSignal)
|
|
31
|
+
return signal;
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
export function runWithSignal(promise, signal) {
|
|
36
|
+
return new Promise((resolve, reject) => {
|
|
37
|
+
if (signal.aborted) {
|
|
38
|
+
reject(signal.reason ?? new Error('Request aborted'));
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
let settled = false;
|
|
42
|
+
const onAbort = () => {
|
|
43
|
+
if (settled)
|
|
44
|
+
return;
|
|
45
|
+
settled = true;
|
|
46
|
+
reject(signal.reason ?? new Error('Request aborted'));
|
|
47
|
+
};
|
|
48
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
49
|
+
promise.then((value) => {
|
|
50
|
+
if (settled)
|
|
51
|
+
return;
|
|
52
|
+
settled = true;
|
|
53
|
+
signal.removeEventListener('abort', onAbort);
|
|
54
|
+
resolve(value);
|
|
55
|
+
}, (err) => {
|
|
56
|
+
if (settled)
|
|
57
|
+
return;
|
|
58
|
+
settled = true;
|
|
59
|
+
signal.removeEventListener('abort', onAbort);
|
|
60
|
+
reject(err);
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
export function buildAuthRequiredResponse() {
|
|
65
|
+
return {
|
|
66
|
+
status: 'auth_required',
|
|
67
|
+
user_action: { id: 'microsoft.connect_account' },
|
|
68
|
+
agent_action: {
|
|
69
|
+
instruction: "Connect your Microsoft 365 account to continue. The user will be redirected to Microsoft's sign-in.",
|
|
70
|
+
},
|
|
71
|
+
setupToolName: AUTH_TOOL_NAME,
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
export function authRequiredJson() {
|
|
75
|
+
return JSON.stringify(buildAuthRequiredResponse());
|
|
76
|
+
}
|
|
77
|
+
function errorJson(payload) {
|
|
78
|
+
return JSON.stringify({ ok: false, ...payload });
|
|
79
|
+
}
|
|
80
|
+
export function errorResponse(payload) {
|
|
81
|
+
return {
|
|
82
|
+
content: [{ type: 'text', text: errorJson(payload) }],
|
|
83
|
+
isError: true,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export function successJson(data) {
|
|
87
|
+
return JSON.stringify(data);
|
|
88
|
+
}
|
|
89
|
+
function isRefreshDisabledError(err) {
|
|
90
|
+
let cursor = err;
|
|
91
|
+
for (let depth = 0; depth < 6 && cursor != null; depth += 1) {
|
|
92
|
+
if (cursor instanceof MicrosoftRefreshDisabledError)
|
|
93
|
+
return true;
|
|
94
|
+
if (typeof cursor === 'object') {
|
|
95
|
+
const obj = cursor;
|
|
96
|
+
if (obj.code === 'MICROSOFT_REFRESH_DISABLED')
|
|
97
|
+
return true;
|
|
98
|
+
cursor = obj.cause ?? obj.originalError;
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
break;
|
|
102
|
+
}
|
|
103
|
+
if (err instanceof Error) {
|
|
104
|
+
const msg = err.message;
|
|
105
|
+
if (msg.includes('Microsoft token refresh is disabled by host'))
|
|
106
|
+
return true;
|
|
107
|
+
if (msg.includes('host has disabled refresh'))
|
|
108
|
+
return true;
|
|
109
|
+
}
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
function detectTokenProviderAuthReason(err) {
|
|
113
|
+
if (!(err instanceof Error))
|
|
114
|
+
return null;
|
|
115
|
+
const msg = err.message.toLowerCase();
|
|
116
|
+
if (msg.includes('microsoft token expired'))
|
|
117
|
+
return 'token_expired';
|
|
118
|
+
return null;
|
|
119
|
+
}
|
|
120
|
+
export function buildErrorResponse(err) {
|
|
121
|
+
if (err instanceof TeamsBusinessError) {
|
|
122
|
+
return errorResponse({
|
|
123
|
+
error: err.message,
|
|
124
|
+
action_required: 'Adjust the arguments per the message above and try again.',
|
|
125
|
+
next_step: err.nextStep,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
if (isRefreshDisabledError(err)) {
|
|
129
|
+
return {
|
|
130
|
+
content: [{ type: 'text', text: authRequiredJson() }],
|
|
131
|
+
isError: true,
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
const reason = detectAuthRequiredReason(err) ?? detectTokenProviderAuthReason(err);
|
|
135
|
+
if (reason) {
|
|
136
|
+
return {
|
|
137
|
+
content: [
|
|
138
|
+
{
|
|
139
|
+
type: 'text',
|
|
140
|
+
text: JSON.stringify({
|
|
141
|
+
...buildAuthRequiredResponse(),
|
|
142
|
+
reason,
|
|
143
|
+
error: formatGraphError(err),
|
|
144
|
+
package_id: getMsPackageId(),
|
|
145
|
+
}),
|
|
146
|
+
},
|
|
147
|
+
],
|
|
148
|
+
isError: true,
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
return errorResponse({
|
|
152
|
+
error: formatGraphError(err),
|
|
153
|
+
action_required: 'Retry the call. If it continues to fail, run authenticate_microsoft_account to refresh the connection.',
|
|
154
|
+
next_step: AUTH_TOOL_NAME,
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
export function withErrorHandling(fn) {
|
|
158
|
+
return async (args, extra) => {
|
|
159
|
+
try {
|
|
160
|
+
const result = await fn(args, extra);
|
|
161
|
+
if (typeof result === 'string') {
|
|
162
|
+
return { content: [{ type: 'text', text: result }] };
|
|
163
|
+
}
|
|
164
|
+
return result;
|
|
165
|
+
}
|
|
166
|
+
catch (err) {
|
|
167
|
+
return buildErrorResponse(err);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,OAAO,EACL,6BAA6B,EAC7B,wBAAwB,EACxB,gBAAgB,GACjB,MAAM,wCAAwC,CAAC;AAEhD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEhF,MAAM,UAAU,eAAe,CAAC,YAA0B;IACxD,MAAM,aAAa,GAAG,WAAW,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;IAC9D,IAAI,CAAC,YAAY;QAAE,OAAO,aAAa,CAAC;IACxC,IAAI,OAAO,WAAW,CAAC,GAAG,KAAK,UAAU,EAAE,CAAC;QAC1C,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC,YAAY,EAAE,aAAa,CAAC,CAAC,CAAC;IACxD,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,eAAe,EAAE,CAAC;IACzC,MAAM,OAAO,GAAG,CAAC,MAAe,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC9D,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;QACzB,UAAU,CAAC,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IACxC,CAAC;SA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E,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,EAAE,CAAC;YACvD,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,kBAAkB,CAAC,GAAG,CAAC,CAAC;QACjC,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mindstone/mcp-server-microsoft-teams",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"mcpName": "io.github.mindstone/mcp-server-microsoft-teams",
|
|
5
|
+
"description": "Microsoft 365 Teams MCP server — list chats, read chat messages, send chat messages, list teams and channels, and get presence via Microsoft Graph",
|
|
6
|
+
"license": "FSL-1.1-MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"bin": {
|
|
9
|
+
"mcp-server-microsoft-teams": "dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE",
|
|
15
|
+
"CHANGELOG.md",
|
|
16
|
+
"server.json"
|
|
17
|
+
],
|
|
18
|
+
"repository": {
|
|
19
|
+
"type": "git",
|
|
20
|
+
"url": "https://github.com/mindstone/mcp-servers.git",
|
|
21
|
+
"directory": "connectors/microsoft-teams"
|
|
22
|
+
},
|
|
23
|
+
"homepage": "https://github.com/mindstone/mcp-servers/tree/main/connectors/microsoft-teams",
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "shx rm -rf dist && tsc && shx chmod +x dist/index.js && npm run security:internal-refs",
|
|
29
|
+
"prepare": "npm run build",
|
|
30
|
+
"prepublishOnly": "npm run build && npm test",
|
|
31
|
+
"watch": "tsc --watch",
|
|
32
|
+
"start": "node dist/index.js",
|
|
33
|
+
"test": "vitest run",
|
|
34
|
+
"test:watch": "vitest",
|
|
35
|
+
"test:coverage": "vitest run --coverage",
|
|
36
|
+
"security:internal-refs": "node scripts/check-internal-refs.mjs"
|
|
37
|
+
},
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"@mindstone/mcp-server-microsoft-shared": "^0.1.0",
|
|
40
|
+
"@modelcontextprotocol/sdk": "^1.26.0",
|
|
41
|
+
"zod": "^3.23.0"
|
|
42
|
+
},
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@mindstone/mcp-test-harness": "file:../../test-harness",
|
|
45
|
+
"@types/node": "^22",
|
|
46
|
+
"@vitest/coverage-v8": "^4.1.3",
|
|
47
|
+
"msw": "^2.13.2",
|
|
48
|
+
"shx": "^0.3.4",
|
|
49
|
+
"typescript": "^5.8.2",
|
|
50
|
+
"vitest": "^4.1.3"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=20"
|
|
54
|
+
}
|
|
55
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "io.github.mindstone/mcp-server-microsoft-teams",
|
|
4
|
+
"title": "Microsoft 365 Teams",
|
|
5
|
+
"description": "Microsoft 365 Teams MCP server: list chats, read chat messages, send chat messages, list teams and channels, and get presence via Microsoft Graph",
|
|
6
|
+
"version": "0.1.0",
|
|
7
|
+
"repository": {
|
|
8
|
+
"url": "https://github.com/mindstone/mcp-servers",
|
|
9
|
+
"source": "github",
|
|
10
|
+
"subfolder": "connectors/microsoft-teams"
|
|
11
|
+
},
|
|
12
|
+
"packages": [
|
|
13
|
+
{
|
|
14
|
+
"registryType": "npm",
|
|
15
|
+
"registryBaseUrl": "https://registry.npmjs.org",
|
|
16
|
+
"identifier": "@mindstone/mcp-server-microsoft-teams",
|
|
17
|
+
"version": "0.1.0",
|
|
18
|
+
"runtimeHint": "npx",
|
|
19
|
+
"transport": {
|
|
20
|
+
"type": "stdio"
|
|
21
|
+
},
|
|
22
|
+
"environmentVariables": [
|
|
23
|
+
{
|
|
24
|
+
"name": "MS_CLIENT_ID",
|
|
25
|
+
"description": "Microsoft Entra (Azure AD) application client ID",
|
|
26
|
+
"isRequired": true,
|
|
27
|
+
"isSecret": false,
|
|
28
|
+
"format": "string"
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
"name": "MS_CONFIG_DIR",
|
|
32
|
+
"description": "Path to the per-user Microsoft config directory (credentials/, accounts.json)",
|
|
33
|
+
"isRequired": true,
|
|
34
|
+
"isSecret": false,
|
|
35
|
+
"format": "filepath"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "MS_ACCOUNT_EMAIL",
|
|
39
|
+
"description": "Account email when running in multi-account per-instance mode (falls back to the first account in accounts.json)",
|
|
40
|
+
"isRequired": false,
|
|
41
|
+
"isSecret": false,
|
|
42
|
+
"format": "string"
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"name": "MS_MCP_PACKAGE_ID",
|
|
46
|
+
"description": "Logical package ID surfaced in error responses",
|
|
47
|
+
"isRequired": false,
|
|
48
|
+
"isSecret": false,
|
|
49
|
+
"default": "Microsoft365Teams",
|
|
50
|
+
"format": "string"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"name": "MICROSOFT_REQUEST_TIMEOUT_MS",
|
|
54
|
+
"description": "Override the upstream Microsoft Graph request timeout in milliseconds (max 300000 = 5 min)",
|
|
55
|
+
"isRequired": false,
|
|
56
|
+
"isSecret": false,
|
|
57
|
+
"default": "60000",
|
|
58
|
+
"format": "number"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
"_meta": {
|
|
64
|
+
"io.modelcontextprotocol.registry/publisher-provided": {
|
|
65
|
+
"com.mindstone.rebel": {
|
|
66
|
+
"catalogId": "bundled-microsoft-teams",
|
|
67
|
+
"provider": "rebel-oss"
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|