@softeria/ms-365-mcp-server 0.114.4 → 0.114.6
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/auth.js +13 -4
- package/dist/server.js +1 -1
- package/package.json +1 -1
package/dist/auth.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PublicClientApplication } from "@azure/msal-node";
|
|
1
|
+
import { AuthError, PublicClientApplication } from "@azure/msal-node";
|
|
2
2
|
import logger from "./logger.js";
|
|
3
3
|
import { readFileSync } from "fs";
|
|
4
4
|
import { fileURLToPath } from "url";
|
|
@@ -236,6 +236,13 @@ function buildScopeDiagnostics(toolScopes, allowedScopesInput) {
|
|
|
236
236
|
extraAllowedScopesNotUsedByTools: [...allowedScopesInput].sort((a, b) => a.localeCompare(b)).filter((scope) => !isScopeUsedByTools(scope, toolPermissions))
|
|
237
237
|
};
|
|
238
238
|
}
|
|
239
|
+
function describeAuthError(error) {
|
|
240
|
+
if (error instanceof AuthError) {
|
|
241
|
+
const suberror = error.subError ? ` / ${error.subError}` : "";
|
|
242
|
+
return `${error.errorCode}${suberror} (correlationId: ${error.correlationId || "none"}): ${error.errorMessage}`;
|
|
243
|
+
}
|
|
244
|
+
return error.message;
|
|
245
|
+
}
|
|
239
246
|
class AuthManager {
|
|
240
247
|
constructor(config, scopes = [], expectedAccount, storage) {
|
|
241
248
|
logger.info(`And scopes are ${scopes.join(", ")}`, scopes);
|
|
@@ -451,8 +458,8 @@ class AuthManager {
|
|
|
451
458
|
this.tokenExpiry = response.expiresOn ? new Date(response.expiresOn).getTime() : null;
|
|
452
459
|
await this.saveTokenCache();
|
|
453
460
|
return this.accessToken;
|
|
454
|
-
} catch {
|
|
455
|
-
logger.error(
|
|
461
|
+
} catch (error) {
|
|
462
|
+
logger.error(`Silent token acquisition failed: ${describeAuthError(error)}`);
|
|
456
463
|
throw new Error("Silent token acquisition failed");
|
|
457
464
|
}
|
|
458
465
|
}
|
|
@@ -766,7 +773,8 @@ class AuthManager {
|
|
|
766
773
|
const response = await this.msalApp.acquireTokenSilent(silentRequest);
|
|
767
774
|
await this.saveTokenCache();
|
|
768
775
|
return response.accessToken;
|
|
769
|
-
} catch {
|
|
776
|
+
} catch (error) {
|
|
777
|
+
logger.error(`Silent token acquisition failed: ${describeAuthError(error)}`);
|
|
770
778
|
throw new Error(
|
|
771
779
|
`Failed to acquire token for account '${targetAccount.username || targetAccount.name || "unknown"}'. The token may have expired. Please re-login with: --login`
|
|
772
780
|
);
|
|
@@ -780,6 +788,7 @@ export {
|
|
|
780
788
|
buildScopesFromEndpoints,
|
|
781
789
|
collapseScopeHierarchy,
|
|
782
790
|
auth_default as default,
|
|
791
|
+
describeAuthError,
|
|
783
792
|
getEndpointRequiredScopes,
|
|
784
793
|
getMissingAllowedScopes,
|
|
785
794
|
getSelectedAccountPath,
|
package/dist/server.js
CHANGED
|
@@ -191,7 +191,7 @@ class MicrosoftGraphServer {
|
|
|
191
191
|
const protocol = req.secure ? "https" : "http";
|
|
192
192
|
const requestOrigin = `${protocol}://${req.get("host")}`;
|
|
193
193
|
const browserBase = publicBase ?? requestOrigin;
|
|
194
|
-
const scopes = resolveAuthScopes(this.options);
|
|
194
|
+
const scopes = this.options.obo ? [`${this.secrets.clientId}/access_as_user`] : resolveAuthScopes(this.options);
|
|
195
195
|
const metadata = {
|
|
196
196
|
issuer: browserBase,
|
|
197
197
|
authorization_endpoint: `${browserBase}/authorize`,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softeria/ms-365-mcp-server",
|
|
3
|
-
"version": "0.114.
|
|
3
|
+
"version": "0.114.6",
|
|
4
4
|
"description": " A Model Context Protocol (MCP) server for interacting with Microsoft 365 and Office services through the Graph API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|