@softeria/ms-365-mcp-server 0.180.0 → 0.180.1

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/PRESETS.md CHANGED
@@ -4,6 +4,8 @@
4
4
 
5
5
  Tool and scope lists assume `--org-mode`; without it, personal accounts get fewer tools and scopes.
6
6
 
7
+ Every preset also includes the account tools (`login`, `logout`, `verify-login`, `list-accounts`, `select-account`, `remove-account`; only `verify-login` and `list-accounts` under `--read-only`). They are not listed or counted below.
8
+
7
9
  ## Summary
8
10
 
9
11
  | Preset | Mode | Tools | Scopes | Org mode | Description |
package/README.md CHANGED
@@ -827,6 +827,8 @@ When running as an MCP server, the following options can be used:
827
827
  --public-url <url> Public base URL for OAuth when behind a reverse proxy (see Open WebUI section and docs/deployment.md)
828
828
  ```
829
829
 
830
+ The account tools (`login`, `logout`, `verify-login`, `list-accounts`, `select-account`, `remove-account`) follow the same filters: `--enabled-tools` applies to them, every `--preset` includes them, and `--read-only` or `MS365_MCP_OAUTH_TOKEN` keeps only `verify-login` and `list-accounts`.
831
+
830
832
  Environment variables:
831
833
 
832
834
  - `READ_ONLY=true|1`: Alternative to --read-only flag
@@ -91,6 +91,8 @@ export async function renderPresetsMarkdown(): Promise<string> {
91
91
  '',
92
92
  'Tool and scope lists assume `--org-mode`; without it, personal accounts get fewer tools and scopes.',
93
93
  '',
94
+ 'Every preset also includes the account tools (`login`, `logout`, `verify-login`, `list-accounts`, `select-account`, `remove-account`; only `verify-login` and `list-accounts` under `--read-only`). They are not listed or counted below.',
95
+ '',
94
96
  '## Summary',
95
97
  '',
96
98
  '| Preset | Mode | Tools | Scopes | Org mode | Description |',
@@ -1,13 +1,34 @@
1
1
  import { z } from "zod";
2
2
  import logger from "./logger.js";
3
3
  import { getRequestTokens } from "./request-context.js";
4
- function registerAuthTools(server, authManager) {
4
+ function readOnlyHintOf(args) {
5
+ const annotations = args.find(
6
+ (arg) => typeof arg === "object" && arg !== null && "readOnlyHint" in arg
7
+ );
8
+ return annotations?.readOnlyHint === true;
9
+ }
10
+ function registerAuthTools(mcpServer, authManager, options = {}) {
11
+ let enabledToolsRegex;
12
+ if (options.enabledTools) {
13
+ try {
14
+ enabledToolsRegex = new RegExp(options.enabledTools, "i");
15
+ } catch {
16
+ }
17
+ }
18
+ const server = {
19
+ tool: ((name, ...args) => {
20
+ if (options.readOnly && !readOnlyHintOf(args)) return void 0;
21
+ if (enabledToolsRegex && !enabledToolsRegex.test(name)) return void 0;
22
+ return mcpServer.tool.call(mcpServer, name, ...args);
23
+ })
24
+ };
5
25
  server.tool(
6
26
  "login",
7
27
  "Authenticate with Microsoft account",
8
28
  {
9
29
  force: z.boolean().default(false).describe("Force a new login even if already logged in")
10
30
  },
31
+ { title: "login", readOnlyHint: false, openWorldHint: false },
11
32
  async ({ force }) => {
12
33
  try {
13
34
  if (!force) {
@@ -70,47 +91,59 @@ function registerAuthTools(server, authManager) {
70
91
  }
71
92
  }
72
93
  );
73
- server.tool("logout", "Log out from Microsoft account", {}, async () => {
74
- try {
75
- await authManager.logout();
76
- return {
77
- content: [
78
- {
79
- type: "text",
80
- text: JSON.stringify({ message: "Logged out successfully" })
81
- }
82
- ]
83
- };
84
- } catch {
94
+ server.tool(
95
+ "logout",
96
+ "Log out from Microsoft account",
97
+ {},
98
+ { title: "logout", readOnlyHint: false, openWorldHint: false },
99
+ async () => {
100
+ try {
101
+ await authManager.logout();
102
+ return {
103
+ content: [
104
+ {
105
+ type: "text",
106
+ text: JSON.stringify({ message: "Logged out successfully" })
107
+ }
108
+ ]
109
+ };
110
+ } catch {
111
+ return {
112
+ content: [
113
+ {
114
+ type: "text",
115
+ text: JSON.stringify({ error: "Logout failed" })
116
+ }
117
+ ]
118
+ };
119
+ }
120
+ }
121
+ );
122
+ server.tool(
123
+ "verify-login",
124
+ "Check current Microsoft authentication status",
125
+ {},
126
+ { title: "verify-login", readOnlyHint: true, openWorldHint: false },
127
+ async () => {
128
+ let testResult;
129
+ try {
130
+ testResult = await authManager.testLogin();
131
+ } catch (error) {
132
+ testResult = {
133
+ success: false,
134
+ message: `Login failed: ${error.message}`
135
+ };
136
+ }
85
137
  return {
86
138
  content: [
87
139
  {
88
140
  type: "text",
89
- text: JSON.stringify({ error: "Logout failed" })
141
+ text: JSON.stringify(testResult)
90
142
  }
91
143
  ]
92
144
  };
93
145
  }
94
- });
95
- server.tool("verify-login", "Check current Microsoft authentication status", {}, async () => {
96
- let testResult;
97
- try {
98
- testResult = await authManager.testLogin();
99
- } catch (error) {
100
- testResult = {
101
- success: false,
102
- message: `Login failed: ${error.message}`
103
- };
104
- }
105
- return {
106
- content: [
107
- {
108
- type: "text",
109
- text: JSON.stringify(testResult)
110
- }
111
- ]
112
- };
113
- });
146
+ );
114
147
  server.tool(
115
148
  "list-accounts",
116
149
  "List all Microsoft accounts configured in this server. Use this to discover available account emails before making tool calls. Reflects accounts added mid-session via --login.",
@@ -164,6 +197,7 @@ function registerAuthTools(server, authManager) {
164
197
  {
165
198
  account: z.string().describe("Email address or account ID of the account to select")
166
199
  },
200
+ { title: "select-account", readOnlyHint: false, openWorldHint: false },
167
201
  async ({ account }) => {
168
202
  try {
169
203
  await authManager.selectAccount(account);
@@ -196,6 +230,7 @@ function registerAuthTools(server, authManager) {
196
230
  {
197
231
  account: z.string().describe("Email address or account ID of the account to remove")
198
232
  },
233
+ { title: "remove-account", readOnlyHint: false, openWorldHint: false },
199
234
  async ({ account }) => {
200
235
  try {
201
236
  const success = await authManager.removeAccount(account);
package/dist/server.js CHANGED
@@ -214,7 +214,13 @@ class MicrosoftGraphServer {
214
214
  );
215
215
  const shouldRegisterAuthTools = !this.options.appMode && (!this.options.http || this.options.enableAuthTools);
216
216
  if (shouldRegisterAuthTools) {
217
- registerAuthTools(server, this.authManager);
217
+ registerAuthTools(server, this.authManager, {
218
+ enabledTools: this.options.enabledTools,
219
+ // With MS365_MCP_OAUTH_TOKEN the token comes from outside, so there is
220
+ // nothing to log in to or switch between. verify-login still checks the
221
+ // token, and list-accounts says cached accounts can't be used (#512).
222
+ readOnly: this.options.readOnly || Boolean(process.env.MS365_MCP_OAUTH_TOKEN)
223
+ });
218
224
  }
219
225
  const registrationOptions = {
220
226
  readOnly: this.options.readOnly,
@@ -60,6 +60,14 @@ const PRESET_META = {
60
60
  }
61
61
  };
62
62
  const UNIVERSAL_UTILITY_TOOLS = ["download-bytes", "download-bytes-to-file"];
63
+ const ACCOUNT_TOOLS = [
64
+ "login",
65
+ "logout",
66
+ "verify-login",
67
+ "list-accounts",
68
+ "select-account",
69
+ "remove-account"
70
+ ];
63
71
  const SCOPED_UTILITY_TOOLS = {
64
72
  "get-download-url": ["files", "onedrive", "personal", "work", "search"],
65
73
  "get-upload-url": ["mail", "calendar", "outlook", "personal", "work"],
@@ -79,7 +87,11 @@ for (const [tool, presets] of Object.entries(SCOPED_UTILITY_TOOLS)) {
79
87
  function getToolsForPreset(preset) {
80
88
  if (preset === "all") {
81
89
  const endpointNames2 = [...new Set(endpointEntries.map((e) => e.toolName))];
82
- const utilityNames = [...UNIVERSAL_UTILITY_TOOLS, ...Object.keys(SCOPED_UTILITY_TOOLS)];
90
+ const utilityNames = [
91
+ ...UNIVERSAL_UTILITY_TOOLS,
92
+ ...Object.keys(SCOPED_UTILITY_TOOLS),
93
+ ...ACCOUNT_TOOLS
94
+ ];
83
95
  return [.../* @__PURE__ */ new Set([...endpointNames2, ...utilityNames])].sort();
84
96
  }
85
97
  const endpointNames = [
@@ -91,6 +103,7 @@ function getToolsForPreset(preset) {
91
103
  return [
92
104
  .../* @__PURE__ */ new Set([
93
105
  ...endpointNames,
106
+ ...ACCOUNT_TOOLS,
94
107
  ...PRESET_META[preset]?.omitUniversalUtilities ? [] : UNIVERSAL_UTILITY_TOOLS,
95
108
  ...Object.entries(SCOPED_UTILITY_TOOLS).filter(([, presets]) => presets.includes(preset)).map(([name]) => name)
96
109
  ])
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.180.0",
4
+ "version": "0.180.1",
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",