@softeria/ms-365-mcp-server 0.185.1 → 0.186.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.
@@ -756,7 +756,8 @@
756
756
  "toolName": "list-folder-files",
757
757
  "presets": ["files", "onedrive", "personal"],
758
758
  "scopes": [["Files.Read"], ["Sites.Selected"]],
759
- "appScopes": [["Files.Read.All"], ["Sites.Read.All"], ["Sites.Selected"]]
759
+ "appScopes": [["Files.Read.All"], ["Sites.Read.All"], ["Sites.Selected"]],
760
+ "mcpApp": "file-browser"
760
761
  },
761
762
  {
762
763
  "pathPattern": "/drives/{drive-id}/items/{driveItem-id}",
@@ -93,6 +93,7 @@ import {
93
93
  userFieldEnforcement
94
94
  } from "./lib/user-field-policy.js";
95
95
  import logger from "./logger.js";
96
+ import { mcpAppToolMeta } from "./mcp-apps.js";
96
97
  import {
97
98
  describeError,
98
99
  describeShape,
@@ -2691,6 +2692,7 @@ function registerGraphToolWithMcp(server, tool, endpointConfig, graphClient, opt
2691
2692
  budget.definitionBudget ?? Number.POSITIVE_INFINITY,
2692
2693
  `${budget.schemaFingerprint}|${tool.alias}`
2693
2694
  ) : void 0;
2695
+ const appMeta = options.mcpApps && endpointConfig?.mcpApp ? mcpAppToolMeta(server, endpointConfig.mcpApp, tool.alias) : void 0;
2694
2696
  server.registerTool(
2695
2697
  tool.alias,
2696
2698
  {
@@ -2703,7 +2705,8 @@ function registerGraphToolWithMcp(server, tool, endpointConfig, graphClient, opt
2703
2705
  destructiveHint: destructive,
2704
2706
  openWorldHint: true
2705
2707
  // All tools call Microsoft Graph API
2706
- }
2708
+ },
2709
+ ...appMeta ? { _meta: appMeta } : {}
2707
2710
  },
2708
2711
  async (params) => executeGraphTool(tool, endpointConfig, graphClient, params, authManager, userFields)
2709
2712
  );
@@ -0,0 +1,68 @@
1
+ import { readFileSync } from "fs";
2
+ import path from "path";
3
+ import { fileURLToPath } from "url";
4
+ import logger from "./logger.js";
5
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
6
+ const MCP_APP_MIME_TYPE = "text/html;profile=mcp-app";
7
+ const CONFIG_PLACEHOLDER = "__MCP_APP_CONFIG__";
8
+ const RESOURCE_UI_META = { csp: {}, prefersBorder: true };
9
+ function mcpAppUri(app) {
10
+ return `ui://ms365/${app}.html`;
11
+ }
12
+ function mcpAppHtmlPath(app) {
13
+ return path.join(__dirname, "apps", `${app}.html`);
14
+ }
15
+ const views = /* @__PURE__ */ new Map();
16
+ function loadView(app) {
17
+ let view = views.get(app);
18
+ if (view === void 0) {
19
+ try {
20
+ view = readFileSync(mcpAppHtmlPath(app), "utf8");
21
+ if (!view.includes(CONFIG_PLACEHOLDER)) {
22
+ view = new Error(`${app}.html has no ${CONFIG_PLACEHOLDER}`);
23
+ }
24
+ } catch (error) {
25
+ view = error;
26
+ }
27
+ if (view instanceof Error) logger.error(`MCP app ${app} left out: ${view.message}`);
28
+ views.set(app, view);
29
+ }
30
+ return view;
31
+ }
32
+ const registered = /* @__PURE__ */ new WeakMap();
33
+ function mcpAppToolMeta(server, app, toolName) {
34
+ const uri = mcpAppUri(app);
35
+ let apps = registered.get(server);
36
+ if (!apps) {
37
+ apps = /* @__PURE__ */ new Set();
38
+ registered.set(server, apps);
39
+ }
40
+ if (!apps.has(app)) {
41
+ const view = loadView(app);
42
+ if (view instanceof Error) return void 0;
43
+ const config = JSON.stringify({ toolName }).replace(/</g, "\\u003c");
44
+ const html = view.replace(CONFIG_PLACEHOLDER, () => config);
45
+ server.registerResource(
46
+ app,
47
+ uri,
48
+ {
49
+ description: `MCP Apps view for ${toolName}`,
50
+ mimeType: MCP_APP_MIME_TYPE,
51
+ _meta: { ui: RESOURCE_UI_META }
52
+ },
53
+ async () => ({
54
+ contents: [
55
+ { uri, mimeType: MCP_APP_MIME_TYPE, text: html, _meta: { ui: RESOURCE_UI_META } }
56
+ ]
57
+ })
58
+ );
59
+ apps.add(app);
60
+ }
61
+ return { ui: { resourceUri: uri }, "ui/resourceUri": uri };
62
+ }
63
+ export {
64
+ MCP_APP_MIME_TYPE,
65
+ mcpAppHtmlPath,
66
+ mcpAppToolMeta,
67
+ mcpAppUri
68
+ };
package/dist/server.js CHANGED
@@ -249,7 +249,9 @@ class MicrosoftGraphServer {
249
249
  accountNames: this.accountNames,
250
250
  allowedScopes: this.options.allowedScopes,
251
251
  httpMode: this.hidesStdioOnlyTools(),
252
- userFields: this.options.userFields
252
+ userFields: this.options.userFields,
253
+ // The views parse the tool results as JSON
254
+ mcpApps: Boolean(this.options.enableMcpApps && !this.options.toon)
253
255
  };
254
256
  if (this.options.discovery) {
255
257
  registerDiscoveryTools(server, this.graphClient, registrationOptions);
@@ -311,6 +313,11 @@ class MicrosoftGraphServer {
311
313
  "--http-local-file-tools has no effect in stdio mode, where the local file tools need no flag."
312
314
  );
313
315
  }
316
+ if (this.options.enableMcpApps && this.options.toon) {
317
+ logger.warn(
318
+ "--enable-mcp-apps has no effect with --toon: the MCP Apps views read JSON tool results."
319
+ );
320
+ }
314
321
  if (this.options.obo) {
315
322
  if (!this.options.http) {
316
323
  throw new Error("--obo requires --http (On-Behalf-Of flow only works in HTTP mode).");
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@softeria/ms-365-mcp-server",
3
3
  "mcpName": "io.github.Softeria/ms-365-mcp-server",
4
- "version": "0.185.1",
4
+ "version": "0.186.0",
5
5
  "description": " A Model Context Protocol (MCP) server for interacting with Microsoft 365 and Office services through the Graph API",
6
6
  "type": "module",
7
7
  "main": "dist/index.js",