teams-api 1.5.0 → 1.6.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/README.md +128 -10
- package/dist/actions/definitions.d.ts.map +1 -1
- package/dist/actions/definitions.js +2 -0
- package/dist/actions/definitions.js.map +1 -1
- package/dist/actions/file-actions.d.ts.map +1 -1
- package/dist/actions/file-actions.js +3 -1
- package/dist/actions/file-actions.js.map +1 -1
- package/dist/actions/image-description-actions.d.ts +28 -0
- package/dist/actions/image-description-actions.d.ts.map +1 -0
- package/dist/actions/image-description-actions.js +148 -0
- package/dist/actions/image-description-actions.js.map +1 -0
- package/dist/actions/message-actions.d.ts.map +1 -1
- package/dist/actions/message-actions.js +153 -3
- package/dist/actions/message-actions.js.map +1 -1
- package/dist/api/chat-service.d.ts +0 -10
- package/dist/api/chat-service.d.ts.map +1 -1
- package/dist/api/chat-service.js +1 -37
- package/dist/api/chat-service.js.map +1 -1
- package/dist/api/common.d.ts +4 -0
- package/dist/api/common.d.ts.map +1 -1
- package/dist/api/common.js +10 -1
- package/dist/api/common.js.map +1 -1
- package/dist/api/image-description.d.ts +20 -0
- package/dist/api/image-description.d.ts.map +1 -0
- package/dist/api/image-description.js +77 -0
- package/dist/api/image-description.js.map +1 -0
- package/dist/audit.d.ts +17 -0
- package/dist/audit.d.ts.map +1 -0
- package/dist/audit.js +53 -0
- package/dist/audit.js.map +1 -0
- package/dist/auth/auto-login.d.ts.map +1 -1
- package/dist/auth/auto-login.js +1 -3
- package/dist/auth/auto-login.js.map +1 -1
- package/dist/auth/interactive.d.ts.map +1 -1
- package/dist/auth/interactive.js +7 -8
- package/dist/auth/interactive.js.map +1 -1
- package/dist/auth/token-capture.d.ts.map +1 -1
- package/dist/auth/token-capture.js +62 -8
- package/dist/auth/token-capture.js.map +1 -1
- package/dist/browser-runtime.d.ts +11 -0
- package/dist/browser-runtime.d.ts.map +1 -1
- package/dist/browser-runtime.js +106 -0
- package/dist/browser-runtime.js.map +1 -1
- package/dist/conversation-protection.d.ts +21 -0
- package/dist/conversation-protection.d.ts.map +1 -0
- package/dist/conversation-protection.js +47 -0
- package/dist/conversation-protection.js.map +1 -0
- package/dist/mcp-auth.d.ts +56 -0
- package/dist/mcp-auth.d.ts.map +1 -0
- package/dist/mcp-auth.js +207 -0
- package/dist/mcp-auth.js.map +1 -0
- package/dist/mcp-server.d.ts +1 -0
- package/dist/mcp-server.d.ts.map +1 -1
- package/dist/mcp-server.js +37 -213
- package/dist/mcp-server.js.map +1 -1
- package/dist/model-context-protocol-download-content.d.ts +7 -0
- package/dist/model-context-protocol-download-content.d.ts.map +1 -0
- package/dist/model-context-protocol-download-content.js +90 -0
- package/dist/model-context-protocol-download-content.js.map +1 -0
- package/dist/server-instructions.d.ts.map +1 -1
- package/dist/server-instructions.js +4 -0
- package/dist/server-instructions.js.map +1 -1
- package/dist/smart-login.d.ts.map +1 -1
- package/dist/smart-login.js +3 -3
- package/dist/smart-login.js.map +1 -1
- package/dist/teams-client.d.ts +10 -1
- package/dist/teams-client.d.ts.map +1 -1
- package/dist/teams-client.js +82 -23
- package/dist/teams-client.js.map +1 -1
- package/dist/types.d.ts +54 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/package.json +8 -2
package/dist/mcp-auth.js
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.McpAuthManager = exports.AuthenticationInProgressError = exports.NeedsEmailError = void 0;
|
|
4
|
+
const platform_js_1 = require("./platform.js");
|
|
5
|
+
const telemetry_js_1 = require("./telemetry.js");
|
|
6
|
+
class NeedsEmailError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("I need your corporate email address to log into Teams. " +
|
|
9
|
+
"Please provide your email and call this tool again.");
|
|
10
|
+
this.name = "NeedsEmailError";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
exports.NeedsEmailError = NeedsEmailError;
|
|
14
|
+
class AuthenticationInProgressError extends Error {
|
|
15
|
+
constructor() {
|
|
16
|
+
super("A browser window has been opened for Microsoft Teams login. " +
|
|
17
|
+
"Please complete the login, then call this tool again.");
|
|
18
|
+
this.name = "AuthenticationInProgressError";
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.AuthenticationInProgressError = AuthenticationInProgressError;
|
|
22
|
+
function getEnvironmentValue(environment, name) {
|
|
23
|
+
const value = environment[name];
|
|
24
|
+
return value && value.length > 0 ? value : undefined;
|
|
25
|
+
}
|
|
26
|
+
function resolveMcpAuthEnvironment(environment) {
|
|
27
|
+
const debugPortValue = getEnvironmentValue(environment, "TEAMS_DEBUG_PORT");
|
|
28
|
+
return {
|
|
29
|
+
auto: environment.TEAMS_AUTO === "true",
|
|
30
|
+
bearerToken: getEnvironmentValue(environment, "TEAMS_BEARER_TOKEN"),
|
|
31
|
+
debug: environment.TEAMS_DEBUG === "true",
|
|
32
|
+
debugPort: debugPortValue ? Number(debugPortValue) : 9222,
|
|
33
|
+
email: getEnvironmentValue(environment, "TEAMS_EMAIL"),
|
|
34
|
+
login: environment.TEAMS_LOGIN === "true",
|
|
35
|
+
region: getEnvironmentValue(environment, "TEAMS_REGION"),
|
|
36
|
+
substrateToken: getEnvironmentValue(environment, "TEAMS_SUBSTRATE_TOKEN"),
|
|
37
|
+
token: getEnvironmentValue(environment, "TEAMS_TOKEN"),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
function formatError(error) {
|
|
41
|
+
return error instanceof Error ? error.message : String(error);
|
|
42
|
+
}
|
|
43
|
+
class McpAuthManager {
|
|
44
|
+
canAttemptAutoLogin;
|
|
45
|
+
clientFactory;
|
|
46
|
+
environment;
|
|
47
|
+
log;
|
|
48
|
+
recordAuth;
|
|
49
|
+
authenticationPromise = null;
|
|
50
|
+
clientInstance = null;
|
|
51
|
+
constructor(options) {
|
|
52
|
+
this.canAttemptAutoLogin =
|
|
53
|
+
options.canAttemptAutoLogin ?? platform_js_1.canAttemptAutoLogin;
|
|
54
|
+
this.clientFactory = options.clientFactory;
|
|
55
|
+
this.environment = options.environment ?? process.env;
|
|
56
|
+
this.log = options.log ?? (() => { });
|
|
57
|
+
this.recordAuth = options.recordAuth ?? telemetry_js_1.recordAuth;
|
|
58
|
+
}
|
|
59
|
+
async authenticateOnStartup() {
|
|
60
|
+
const authEnvironment = resolveMcpAuthEnvironment(this.environment);
|
|
61
|
+
if (!authEnvironment.token && !authEnvironment.email) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
try {
|
|
65
|
+
this.log("Starting Teams authentication during MCP server startup...");
|
|
66
|
+
await this.getClient();
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
this.log(`Teams authentication during MCP server startup failed: ${formatError(error)}`);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
async getClient(toolEmail) {
|
|
73
|
+
if (this.clientInstance) {
|
|
74
|
+
return this.clientInstance;
|
|
75
|
+
}
|
|
76
|
+
const authEnvironment = resolveMcpAuthEnvironment(this.environment);
|
|
77
|
+
if (this.shouldUseTwoPhaseAuthentication(toolEmail, authEnvironment)) {
|
|
78
|
+
if (!this.authenticationPromise) {
|
|
79
|
+
this.log("Starting Microsoft Teams login in the background...");
|
|
80
|
+
void this.startAuthentication(toolEmail).catch((error) => {
|
|
81
|
+
this.log(`Microsoft Teams login failed: ${formatError(error)}`);
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
throw new AuthenticationInProgressError();
|
|
85
|
+
}
|
|
86
|
+
return this.startAuthentication(toolEmail);
|
|
87
|
+
}
|
|
88
|
+
shouldUseTwoPhaseAuthentication(toolEmail, authEnvironment) {
|
|
89
|
+
if (!toolEmail ||
|
|
90
|
+
authEnvironment.email ||
|
|
91
|
+
authEnvironment.token ||
|
|
92
|
+
authEnvironment.debug) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
if (authEnvironment.login) {
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
98
|
+
if (authEnvironment.auto) {
|
|
99
|
+
return !this.canAttemptAutoLogin();
|
|
100
|
+
}
|
|
101
|
+
return !this.canAttemptAutoLogin();
|
|
102
|
+
}
|
|
103
|
+
startAuthentication(toolEmail) {
|
|
104
|
+
this.authenticationPromise ??= this.authenticate(toolEmail)
|
|
105
|
+
.then((client) => {
|
|
106
|
+
this.clientInstance = client;
|
|
107
|
+
return client;
|
|
108
|
+
})
|
|
109
|
+
.finally(() => {
|
|
110
|
+
this.authenticationPromise = null;
|
|
111
|
+
});
|
|
112
|
+
return this.authenticationPromise;
|
|
113
|
+
}
|
|
114
|
+
async authenticate(toolEmail) {
|
|
115
|
+
const authEnvironment = resolveMcpAuthEnvironment(this.environment);
|
|
116
|
+
const email = authEnvironment.email ?? toolEmail;
|
|
117
|
+
const log = this.log;
|
|
118
|
+
if (authEnvironment.token) {
|
|
119
|
+
if (!authEnvironment.region) {
|
|
120
|
+
throw new Error("TEAMS_REGION is required when TEAMS_TOKEN is set");
|
|
121
|
+
}
|
|
122
|
+
const client = this.clientFactory.fromToken(authEnvironment.token, authEnvironment.region, authEnvironment.bearerToken, authEnvironment.substrateToken);
|
|
123
|
+
if (email) {
|
|
124
|
+
client.setEmail(email);
|
|
125
|
+
}
|
|
126
|
+
this.recordAuth({ strategy: "token", success: true });
|
|
127
|
+
this.log("Microsoft Teams authentication successful.");
|
|
128
|
+
return client;
|
|
129
|
+
}
|
|
130
|
+
if (authEnvironment.auto) {
|
|
131
|
+
if (!email) {
|
|
132
|
+
throw new NeedsEmailError();
|
|
133
|
+
}
|
|
134
|
+
try {
|
|
135
|
+
const client = await this.clientFactory.create({
|
|
136
|
+
email,
|
|
137
|
+
region: authEnvironment.region,
|
|
138
|
+
headless: true,
|
|
139
|
+
verbose: false,
|
|
140
|
+
log,
|
|
141
|
+
});
|
|
142
|
+
this.recordAuth({ strategy: "auto", success: true });
|
|
143
|
+
this.log("Microsoft Teams authentication successful.");
|
|
144
|
+
return client;
|
|
145
|
+
}
|
|
146
|
+
catch (error) {
|
|
147
|
+
this.recordAuth({ strategy: "auto", success: false, error });
|
|
148
|
+
throw error;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
if (authEnvironment.login) {
|
|
152
|
+
try {
|
|
153
|
+
const client = await this.clientFactory.fromInteractiveLogin({
|
|
154
|
+
region: authEnvironment.region,
|
|
155
|
+
email,
|
|
156
|
+
verbose: false,
|
|
157
|
+
log,
|
|
158
|
+
});
|
|
159
|
+
if (email) {
|
|
160
|
+
client.setEmail(email);
|
|
161
|
+
}
|
|
162
|
+
this.recordAuth({ strategy: "login", success: true });
|
|
163
|
+
this.log("Microsoft Teams authentication successful.");
|
|
164
|
+
return client;
|
|
165
|
+
}
|
|
166
|
+
catch (error) {
|
|
167
|
+
this.recordAuth({ strategy: "login", success: false, error });
|
|
168
|
+
throw error;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (authEnvironment.debug) {
|
|
172
|
+
try {
|
|
173
|
+
const client = await this.clientFactory.fromDebugSession({
|
|
174
|
+
debugPort: authEnvironment.debugPort,
|
|
175
|
+
region: authEnvironment.region,
|
|
176
|
+
});
|
|
177
|
+
this.recordAuth({ strategy: "debug", success: true });
|
|
178
|
+
this.log("Microsoft Teams authentication successful.");
|
|
179
|
+
return client;
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
this.recordAuth({ strategy: "debug", success: false, error });
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
try {
|
|
187
|
+
const client = await this.clientFactory.connect({
|
|
188
|
+
email,
|
|
189
|
+
region: authEnvironment.region,
|
|
190
|
+
verbose: false,
|
|
191
|
+
log,
|
|
192
|
+
});
|
|
193
|
+
if (email) {
|
|
194
|
+
client.setEmail(email);
|
|
195
|
+
}
|
|
196
|
+
this.recordAuth({ strategy: "auto", success: true });
|
|
197
|
+
this.log("Microsoft Teams authentication successful.");
|
|
198
|
+
return client;
|
|
199
|
+
}
|
|
200
|
+
catch (error) {
|
|
201
|
+
this.recordAuth({ strategy: "auto", success: false, error });
|
|
202
|
+
throw error;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
exports.McpAuthManager = McpAuthManager;
|
|
207
|
+
//# sourceMappingURL=mcp-auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-auth.js","sourceRoot":"","sources":["../src/mcp-auth.ts"],"names":[],"mappings":";;;AAAA,+CAAkF;AAClF,iDAAiE;AAgEjE,MAAa,eAAgB,SAAQ,KAAK;IACxC;QACE,KAAK,CACH,yDAAyD;YACvD,qDAAqD,CACxD,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AARD,0CAQC;AAED,MAAa,6BAA8B,SAAQ,KAAK;IACtD;QACE,KAAK,CACH,8DAA8D;YAC5D,uDAAuD,CAC1D,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AARD,sEAQC;AAED,SAAS,mBAAmB,CAC1B,WAA+B,EAC/B,IAA8B;IAE9B,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,OAAO,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS,CAAC;AACvD,CAAC;AAED,SAAS,yBAAyB,CAChC,WAA+B;IAE/B,MAAM,cAAc,GAAG,mBAAmB,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC;IAE5E,OAAO;QACL,IAAI,EAAE,WAAW,CAAC,UAAU,KAAK,MAAM;QACvC,WAAW,EAAE,mBAAmB,CAAC,WAAW,EAAE,oBAAoB,CAAC;QACnE,KAAK,EAAE,WAAW,CAAC,WAAW,KAAK,MAAM;QACzC,SAAS,EAAE,cAAc,CAAC,CAAC,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C,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;YACrD,IAAI,CAAC,GAAG,CAAC,4CAA4C,CAAC,CAAC;YACvD,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,UAAU,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF;AA7LD,wCA6LC"}
|
package/dist/mcp-server.d.ts
CHANGED
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
* TEAMS_LOGIN — Set to "true" to use interactive browser login (all platforms)
|
|
18
18
|
* TEAMS_DEBUG_PORT — Chrome debug port (default: 9222)
|
|
19
19
|
* TEAMS_TELEMETRY — Set to "true" to enable full debug telemetry (contributor use)
|
|
20
|
+
* TEAMS_IMAGE_DESCRIPTION_API_KEY — Optional vision API key for teams_describe_image
|
|
20
21
|
*
|
|
21
22
|
* Usage in VS Code settings (mcp config):
|
|
22
23
|
* {
|
package/dist/mcp-server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA
|
|
1
|
+
{"version":3,"file":"mcp-server.d.ts","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG"}
|
package/dist/mcp-server.js
CHANGED
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
* TEAMS_LOGIN — Set to "true" to use interactive browser login (all platforms)
|
|
19
19
|
* TEAMS_DEBUG_PORT — Chrome debug port (default: 9222)
|
|
20
20
|
* TEAMS_TELEMETRY — Set to "true" to enable full debug telemetry (contributor use)
|
|
21
|
+
* TEAMS_IMAGE_DESCRIPTION_API_KEY — Optional vision API key for teams_describe_image
|
|
21
22
|
*
|
|
22
23
|
* Usage in VS Code settings (mcp config):
|
|
23
24
|
* {
|
|
@@ -41,107 +42,8 @@ const definitions_js_1 = require("./actions/definitions.js");
|
|
|
41
42
|
const formatters_js_1 = require("./actions/formatters.js");
|
|
42
43
|
const server_instructions_js_1 = require("./server-instructions.js");
|
|
43
44
|
const telemetry_js_1 = require("./telemetry.js");
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
constructor() {
|
|
47
|
-
super("I need your corporate email address to log into Teams. " +
|
|
48
|
-
"Please provide your email and call this tool again.");
|
|
49
|
-
this.name = "NeedsEmailError";
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
async function getClient(toolEmail) {
|
|
53
|
-
if (clientInstance) {
|
|
54
|
-
return clientInstance;
|
|
55
|
-
}
|
|
56
|
-
const envToken = process.env.TEAMS_TOKEN;
|
|
57
|
-
const envBearerToken = process.env.TEAMS_BEARER_TOKEN;
|
|
58
|
-
const envSubstrateToken = process.env.TEAMS_SUBSTRATE_TOKEN;
|
|
59
|
-
const envRegion = process.env.TEAMS_REGION;
|
|
60
|
-
const email = process.env.TEAMS_EMAIL || toolEmail;
|
|
61
|
-
const envAuto = process.env.TEAMS_AUTO === "true";
|
|
62
|
-
const envLogin = process.env.TEAMS_LOGIN === "true";
|
|
63
|
-
const envDebug = process.env.TEAMS_DEBUG === "true";
|
|
64
|
-
const envDebugPort = process.env.TEAMS_DEBUG_PORT
|
|
65
|
-
? Number(process.env.TEAMS_DEBUG_PORT)
|
|
66
|
-
: 9222;
|
|
67
|
-
if (envToken) {
|
|
68
|
-
if (!envRegion) {
|
|
69
|
-
throw new Error("TEAMS_REGION is required when TEAMS_TOKEN is set");
|
|
70
|
-
}
|
|
71
|
-
clientInstance = teams_client_js_1.TeamsClient.fromToken(envToken, envRegion, envBearerToken, envSubstrateToken);
|
|
72
|
-
if (email) {
|
|
73
|
-
clientInstance.setEmail(email);
|
|
74
|
-
}
|
|
75
|
-
(0, telemetry_js_1.recordAuth)({ strategy: "token", success: true });
|
|
76
|
-
}
|
|
77
|
-
else if (envAuto) {
|
|
78
|
-
if (!email) {
|
|
79
|
-
throw new NeedsEmailError();
|
|
80
|
-
}
|
|
81
|
-
try {
|
|
82
|
-
clientInstance = await teams_client_js_1.TeamsClient.create({
|
|
83
|
-
email,
|
|
84
|
-
region: envRegion,
|
|
85
|
-
headless: true,
|
|
86
|
-
verbose: false,
|
|
87
|
-
});
|
|
88
|
-
(0, telemetry_js_1.recordAuth)({ strategy: "auto", success: true });
|
|
89
|
-
}
|
|
90
|
-
catch (err) {
|
|
91
|
-
(0, telemetry_js_1.recordAuth)({ strategy: "auto", success: false, error: err });
|
|
92
|
-
throw err;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
else if (envLogin) {
|
|
96
|
-
try {
|
|
97
|
-
clientInstance = await teams_client_js_1.TeamsClient.fromInteractiveLogin({
|
|
98
|
-
region: envRegion,
|
|
99
|
-
email,
|
|
100
|
-
verbose: false,
|
|
101
|
-
});
|
|
102
|
-
if (email) {
|
|
103
|
-
clientInstance.setEmail(email);
|
|
104
|
-
}
|
|
105
|
-
(0, telemetry_js_1.recordAuth)({ strategy: "login", success: true });
|
|
106
|
-
}
|
|
107
|
-
catch (err) {
|
|
108
|
-
(0, telemetry_js_1.recordAuth)({ strategy: "login", success: false, error: err });
|
|
109
|
-
throw err;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
else if (envDebug) {
|
|
113
|
-
try {
|
|
114
|
-
clientInstance = await teams_client_js_1.TeamsClient.fromDebugSession({
|
|
115
|
-
debugPort: envDebugPort,
|
|
116
|
-
region: envRegion,
|
|
117
|
-
});
|
|
118
|
-
(0, telemetry_js_1.recordAuth)({ strategy: "debug", success: true });
|
|
119
|
-
}
|
|
120
|
-
catch (err) {
|
|
121
|
-
(0, telemetry_js_1.recordAuth)({ strategy: "debug", success: false, error: err });
|
|
122
|
-
throw err;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
// Default: smart login (cross-platform, zero-config)
|
|
127
|
-
try {
|
|
128
|
-
clientInstance = await teams_client_js_1.TeamsClient.connect({
|
|
129
|
-
email,
|
|
130
|
-
region: envRegion,
|
|
131
|
-
verbose: false,
|
|
132
|
-
});
|
|
133
|
-
if (email) {
|
|
134
|
-
clientInstance.setEmail(email);
|
|
135
|
-
}
|
|
136
|
-
(0, telemetry_js_1.recordAuth)({ strategy: "auto", success: true });
|
|
137
|
-
}
|
|
138
|
-
catch (err) {
|
|
139
|
-
(0, telemetry_js_1.recordAuth)({ strategy: "auto", success: false, error: err });
|
|
140
|
-
throw err;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
return clientInstance;
|
|
144
|
-
}
|
|
45
|
+
const model_context_protocol_download_content_js_1 = require("./model-context-protocol-download-content.js");
|
|
46
|
+
const mcp_auth_js_1 = require("./mcp-auth.js");
|
|
145
47
|
function parameterToZod(parameter) {
|
|
146
48
|
let schema;
|
|
147
49
|
switch (parameter.type) {
|
|
@@ -170,107 +72,32 @@ const server = new mcp_js_1.McpServer({
|
|
|
170
72
|
}, {
|
|
171
73
|
instructions: server_instructions_js_1.serverInstructions,
|
|
172
74
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
"application/json",
|
|
178
|
-
"application/xml",
|
|
179
|
-
"application/javascript",
|
|
180
|
-
"application/typescript",
|
|
181
|
-
"application/x-yaml",
|
|
182
|
-
"application/yaml",
|
|
183
|
-
"application/toml",
|
|
184
|
-
];
|
|
185
|
-
/** File extensions that are known to be text-based. */
|
|
186
|
-
const TEXT_FILE_EXTENSIONS = new Set([
|
|
187
|
-
"md",
|
|
188
|
-
"txt",
|
|
189
|
-
"csv",
|
|
190
|
-
"tsv",
|
|
191
|
-
"json",
|
|
192
|
-
"xml",
|
|
193
|
-
"yaml",
|
|
194
|
-
"yml",
|
|
195
|
-
"toml",
|
|
196
|
-
"html",
|
|
197
|
-
"htm",
|
|
198
|
-
"css",
|
|
199
|
-
"js",
|
|
200
|
-
"ts",
|
|
201
|
-
"jsx",
|
|
202
|
-
"tsx",
|
|
203
|
-
"py",
|
|
204
|
-
"rb",
|
|
205
|
-
"sh",
|
|
206
|
-
"bash",
|
|
207
|
-
"zsh",
|
|
208
|
-
"ps1",
|
|
209
|
-
"bat",
|
|
210
|
-
"cmd",
|
|
211
|
-
"sql",
|
|
212
|
-
"graphql",
|
|
213
|
-
"svg",
|
|
214
|
-
"log",
|
|
215
|
-
"ini",
|
|
216
|
-
"cfg",
|
|
217
|
-
"conf",
|
|
218
|
-
"env",
|
|
219
|
-
"properties",
|
|
220
|
-
]);
|
|
221
|
-
function isTextContent(mimeType, fileName) {
|
|
222
|
-
const lowerMime = mimeType.toLowerCase();
|
|
223
|
-
if (TEXT_MIME_PREFIXES.some((prefix) => lowerMime.startsWith(prefix))) {
|
|
224
|
-
return true;
|
|
225
|
-
}
|
|
226
|
-
// Fall back to file extension when MIME type is generic (e.g. application/octet-stream)
|
|
227
|
-
const extension = fileName.includes(".")
|
|
228
|
-
? fileName.split(".").pop()?.toLowerCase()
|
|
229
|
-
: undefined;
|
|
230
|
-
return extension !== undefined && TEXT_FILE_EXTENSIONS.has(extension);
|
|
75
|
+
function formatLogMessage(messages) {
|
|
76
|
+
return messages
|
|
77
|
+
.map((message) => message instanceof Error ? message.message : String(message))
|
|
78
|
+
.join(" ");
|
|
231
79
|
}
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
data: download.data.toString("base64"),
|
|
248
|
-
mimeType: download.contentType,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
else if (isTextContent(download.contentType, download.fileName)) {
|
|
252
|
-
blocks.push({
|
|
253
|
-
type: "resource",
|
|
254
|
-
resource: {
|
|
255
|
-
uri: fileUri,
|
|
256
|
-
mimeType: download.contentType,
|
|
257
|
-
text: download.data.toString("utf-8"),
|
|
258
|
-
},
|
|
259
|
-
});
|
|
260
|
-
}
|
|
261
|
-
else {
|
|
262
|
-
blocks.push({
|
|
263
|
-
type: "resource",
|
|
264
|
-
resource: {
|
|
265
|
-
uri: fileUri,
|
|
266
|
-
mimeType: download.contentType,
|
|
267
|
-
blob: download.data.toString("base64"),
|
|
268
|
-
},
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
}
|
|
272
|
-
return blocks;
|
|
80
|
+
function createMcpAuthLogFunction(mcpServer) {
|
|
81
|
+
return (...messages) => {
|
|
82
|
+
const data = formatLogMessage(messages);
|
|
83
|
+
void mcpServer
|
|
84
|
+
.sendLoggingMessage({
|
|
85
|
+
level: "info",
|
|
86
|
+
logger: "teams-api.auth",
|
|
87
|
+
data,
|
|
88
|
+
})
|
|
89
|
+
.catch((error) => {
|
|
90
|
+
if (process.env.TEAMS_TELEMETRY === "true") {
|
|
91
|
+
console.error("Failed to send MCP auth logging message:", error instanceof Error ? error.message : error);
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
};
|
|
273
95
|
}
|
|
96
|
+
const authManager = new mcp_auth_js_1.McpAuthManager({
|
|
97
|
+
clientFactory: teams_client_js_1.TeamsClient,
|
|
98
|
+
log: createMcpAuthLogFunction(server),
|
|
99
|
+
});
|
|
100
|
+
// ── Register all actions as MCP tools ─────────────────────────────────
|
|
274
101
|
for (const action of definitions_js_1.actions) {
|
|
275
102
|
const toolName = `teams_${action.name.replace(/-/g, "_")}`;
|
|
276
103
|
const inputSchema = {};
|
|
@@ -296,23 +123,18 @@ for (const action of definitions_js_1.actions) {
|
|
|
296
123
|
const outputFormat = parameters.format ?? "concise";
|
|
297
124
|
const start = Date.now();
|
|
298
125
|
try {
|
|
299
|
-
const client = await getClient(parameters.email);
|
|
126
|
+
const client = await authManager.getClient(parameters.email);
|
|
300
127
|
const result = await action.execute(client, parameters);
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
// Redact binary data before recording telemetry — Buffer serialises as
|
|
304
|
-
// a large numeric array and would massively bloat telemetry.jsonl.
|
|
305
|
-
const telemetryResult = action.name === "download-file" && Array.isArray(result)
|
|
306
|
-
? result.map(({ data, ...rest }) => ({
|
|
307
|
-
...rest,
|
|
308
|
-
byteLength: data.byteLength,
|
|
309
|
-
}))
|
|
128
|
+
const outputResult = action.name === "download-file" && Array.isArray(result)
|
|
129
|
+
? (0, model_context_protocol_download_content_js_1.createDownloadOutputResults)(result)
|
|
310
130
|
: result;
|
|
131
|
+
const output = (0, formatters_js_1.formatOutput)(action, outputResult, outputFormat);
|
|
132
|
+
const durationMs = Date.now() - start;
|
|
311
133
|
(0, telemetry_js_1.recordToolCall)({
|
|
312
134
|
tool: action.name,
|
|
313
135
|
format: outputFormat,
|
|
314
136
|
parameters: parameters,
|
|
315
|
-
result:
|
|
137
|
+
result: outputResult,
|
|
316
138
|
output,
|
|
317
139
|
durationMs,
|
|
318
140
|
});
|
|
@@ -322,7 +144,7 @@ for (const action of definitions_js_1.actions) {
|
|
|
322
144
|
];
|
|
323
145
|
if (action.name === "download-file" && Array.isArray(result)) {
|
|
324
146
|
const downloads = result;
|
|
325
|
-
contentBlocks.push(...buildDownloadContentBlocks(downloads));
|
|
147
|
+
contentBlocks.push(...(0, model_context_protocol_download_content_js_1.buildDownloadContentBlocks)(downloads));
|
|
326
148
|
}
|
|
327
149
|
return {
|
|
328
150
|
content: contentBlocks,
|
|
@@ -330,7 +152,8 @@ for (const action of definitions_js_1.actions) {
|
|
|
330
152
|
}
|
|
331
153
|
catch (error) {
|
|
332
154
|
const durationMs = Date.now() - start;
|
|
333
|
-
if (error instanceof NeedsEmailError
|
|
155
|
+
if (error instanceof mcp_auth_js_1.NeedsEmailError ||
|
|
156
|
+
error instanceof mcp_auth_js_1.AuthenticationInProgressError) {
|
|
334
157
|
(0, telemetry_js_1.recordToolError)({
|
|
335
158
|
tool: action.name,
|
|
336
159
|
format: outputFormat,
|
|
@@ -357,6 +180,7 @@ for (const action of definitions_js_1.actions) {
|
|
|
357
180
|
async function main() {
|
|
358
181
|
const transport = new stdio_js_1.StdioServerTransport();
|
|
359
182
|
await server.connect(transport);
|
|
183
|
+
void authManager.authenticateOnStartup();
|
|
360
184
|
}
|
|
361
185
|
main().catch((error) => {
|
|
362
186
|
console.error("MCP server error:", error.message);
|
package/dist/mcp-server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";;AACA
|
|
1
|
+
{"version":3,"file":"mcp-server.js","sourceRoot":"","sources":["../src/mcp-server.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;;AAEH,oEAAoE;AACpE,wEAAiF;AAEjF,6BAAwB;AACxB,uDAAgD;AAChD,6DAAmD;AACnD,2DAAuD;AAGvD,qEAA8D;AAC9D,iDAAiE;AACjE,6GAGsD;AACtD,+CAIuB;AAGvB,SAAS,cAAc,CAAC,SAA0B;IAChD,IAAI,MAAoB,CAAC;IACzB,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,QAAQ;YACX,MAAM,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM;QACR,KAAK,QAAQ;YACX,MAAM,GAAG,OAAC,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM;QACR,KAAK,SAAS;YACZ,MAAM,GAAG,OAAC,CAAC,OAAO,EAAE,CAAC;YACrB,MAAM;QACR,KAAK,UAAU;YACb,MAAM,GAAG,OAAC,CAAC,KAAK,CAAC,OAAC,CAAC,MAAM,EAAE,CAAC,CAAC;YAC7B,MAAM;IACV,CAAC;IACD,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,S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AE,IAAI,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;oBACzD,OAAO,EAAE,IAAI;iBACd,CAAC;YACJ,CAAC;YACD,IAAA,8BAAe,EAAC;gBACd,IAAI,EAAE,MAAM,CAAC,IAAI;gBACjB,MAAM,EAAE,YAAY;gBACpB,UAAU,EAAE,UAAqC;gBACjD,KAAK;gBACL,UAAU;aACX,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CACF,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,+BAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAChC,KAAK,WAAW,CAAC,qBAAqB,EAAE,CAAC;AAC3C,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,mBAAmB,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;IAClD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ContentBlock } from "@modelcontextprotocol/sdk/types.js";
|
|
2
|
+
import type { DownloadResult } from "./actions/file-actions.js";
|
|
3
|
+
export declare function buildDownloadContentBlocks(downloads: DownloadResult[]): ContentBlock[];
|
|
4
|
+
export declare function createDownloadOutputResults(downloads: DownloadResult[]): Array<Omit<DownloadResult, "data"> & {
|
|
5
|
+
byteLength: number;
|
|
6
|
+
}>;
|
|
7
|
+
//# sourceMappingURL=model-context-protocol-download-content.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-context-protocol-download-content.d.ts","sourceRoot":"","sources":["../src/model-context-protocol-download-content.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AA6DhE,wBAAgB,0BAA0B,CACxC,SAAS,EAAE,cAAc,EAAE,GAC1B,YAAY,EAAE,CAqBhB;AAED,wBAAgB,2BAA2B,CACzC,SAAS,EAAE,cAAc,EAAE,GAC1B,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,GAAG;IAAE,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC,CAK9D"}
|