@softeria/ms-365-mcp-server 0.172.0 → 0.173.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 CHANGED
@@ -155,7 +155,7 @@ The `--list-permissions` JSON includes:
155
155
 
156
156
  ### Allowed Scopes
157
157
 
158
- By default, MSAL requests the scopes implied by the enabled tools, and the tool surface is controlled by `--enabled-tools`, `--preset`, `--org-mode`, and `--read-only`.
158
+ By default, MSAL requests the scopes implied by the enabled tools, and the tool surface is controlled by `--enabled-tools`, `--enabled-tools-file`, `--preset`, `--org-mode`, and `--read-only`.
159
159
 
160
160
  Enterprise and headless deployments can add a scope boundary with `--allowed-scopes` or `MS365_MCP_ALLOWED_SCOPES`. When configured, the server first computes the normal tool surface, then hides Graph tools whose required scopes are not covered by the allowlist. OAuth metadata and login flows request only the effective permissions for the tools that remain enabled.
161
161
 
@@ -166,6 +166,19 @@ npx @softeria/ms-365-mcp-server \
166
166
  --allowed-scopes 'User.Read Mail.Read Files.Read'
167
167
  ```
168
168
 
169
+ For longer filters, put one regex per line in a file and pass `--enabled-tools-file` / `ENABLED_TOOLS_FILE`. Blank lines and whole-line `#` comments are dropped; the rest are joined with `|`, so the file is equivalent to `--enabled-tools=line1|line2|…`:
170
+
171
+ ```text
172
+ # tools.txt
173
+ ^list-mail-messages$
174
+ ^get-mail-message$
175
+ drive|download-bytes
176
+ ```
177
+
178
+ ```bash
179
+ npx @softeria/ms-365-mcp-server --org-mode --enabled-tools-file ./tools.txt
180
+ ```
181
+
169
182
  CLI value takes precedence over `MS365_MCP_ALLOWED_SCOPES`; if neither is set, the default tool-derived scope behavior is unchanged. Supplying an empty value fails at startup so deployments do not accidentally fall back to a wider tool surface.
170
183
 
171
184
  Scope coverage is hierarchy-aware: for example, `Mail.ReadWrite` covers tools that require `Mail.Read`, and `Files.ReadWrite.All` covers tools that require `Files.Read`.
@@ -672,7 +685,7 @@ The following options can be used when running ms-365-mcp-server directly from t
672
685
  --login Login using device code flow
673
686
  --logout Log out and clear saved credentials
674
687
  --verify-login Verify login without starting the server
675
- --list-permissions List required Graph API permissions and exit (respects --org-mode, --preset, --enabled-tools, --allowed-scopes)
688
+ --list-permissions List required Graph API permissions and exit (respects --org-mode, --preset, --enabled-tools, --enabled-tools-file, --allowed-scopes)
676
689
  --org-mode Enable organization/work mode from start (includes Teams, SharePoint, etc.)
677
690
  --work-mode Alias for --org-mode
678
691
  --force-work-scopes Backwards compatibility alias for --org-mode (deprecated)
@@ -715,6 +728,9 @@ When running as an MCP server, the following options can be used:
715
728
  (requires --attachment-port; see "Splitting the attachment listener")
716
729
  --no-dynamic-registration Disable OAuth Dynamic Client Registration (enabled by default in HTTP mode)
717
730
  --enabled-tools <pattern> Filter tools using regex pattern (e.g., "excel|contact" to enable Excel and Contact tools)
731
+ --enabled-tools-file <path> Filter tools using a file with one regex per line (same as --enabled-tools;
732
+ blank lines and whole-line # comments ignored). Overrides --enabled-tools;
733
+ overridden by --preset. Equivalent env var: ENABLED_TOOLS_FILE
718
734
  --preset <names> Use preset tool categories (comma-separated). See "Tool Presets" section above
719
735
  --list-presets List all available presets and exit
720
736
  --toon (experimental) Enable TOON output format for 30-60% token reduction
@@ -728,6 +744,7 @@ Environment variables:
728
744
 
729
745
  - `READ_ONLY=true|1`: Alternative to --read-only flag
730
746
  - `ENABLED_TOOLS`: Filter tools using a regex pattern (alternative to --enabled-tools flag)
747
+ - `ENABLED_TOOLS_FILE`: Path to a file with one regex per line (alternative to --enabled-tools-file). Blank lines and whole-line `#` comments are dropped, then lines are joined with `|` (same as `ENABLED_TOOLS=line1|line2|…`). Layering (later wins): `--enabled-tools` → `--enabled-tools-file` → `--preset` → `ENABLED_TOOLS` → `ENABLED_TOOLS_FILE`
731
748
  - `MS365_MCP_ORG_MODE=true|1`: Enable organization/work mode (alternative to --org-mode flag)
732
749
  - `MS365_MCP_FORCE_WORK_SCOPES=true|1`: Backwards compatibility for MS365_MCP_ORG_MODE
733
750
  - `MS365_MCP_OUTPUT_FORMAT=toon`: Enable TOON output format (alternative to --toon flag)
package/dist/cli.js CHANGED
@@ -2,6 +2,7 @@ import { Command, Option } from "commander";
2
2
  import { readFileSync } from "fs";
3
3
  import path from "path";
4
4
  import { fileURLToPath } from "url";
5
+ import { readEnabledToolsFromFile } from "./lib/enabled-tools-file.js";
5
6
  import { assertSignoffMarkersVisible } from "./lib/message-signoff.js";
6
7
  import { assertUploadDirsAbsolute } from "./lib/upload-dirs.js";
7
8
  import { getCombinedPresetPattern, listPresets, presetRequiresOrgMode } from "./tool-categories.js";
@@ -40,6 +41,9 @@ program.name("ms-365-mcp-server").description("Microsoft 365 MCP Server").versio
40
41
  ).option(
41
42
  "--enabled-tools <pattern>",
42
43
  'Filter tools using regex pattern (e.g., "excel|contact" to enable Excel and Contact tools)'
44
+ ).option(
45
+ "--enabled-tools-file <path>",
46
+ "Filter tools using a file with one regex per line (same semantics as --enabled-tools; blank lines and whole-line # comments ignored). Overrides --enabled-tools; overridden by --preset. Equivalent env var: ENABLED_TOOLS_FILE."
43
47
  ).option(
44
48
  "--allowed-scopes <scopes>",
45
49
  "Limit exposed tools to Graph scopes covered by this whitespace-separated allowlist"
@@ -114,6 +118,15 @@ function parseArgs() {
114
118
  console.log(JSON.stringify({ presets }, null, 2));
115
119
  process.exit(0);
116
120
  }
121
+ if (typeof options.enabledToolsFile === "string") {
122
+ try {
123
+ options.enabledTools = readEnabledToolsFromFile(options.enabledToolsFile);
124
+ } catch (error) {
125
+ console.error(`Error: ${error.message}`);
126
+ process.exit(1);
127
+ }
128
+ }
129
+ delete options.enabledToolsFile;
117
130
  if (options.preset) {
118
131
  const presetNames = options.preset.split(",").map((p) => p.trim());
119
132
  try {
@@ -137,6 +150,14 @@ function parseArgs() {
137
150
  if (process.env.ENABLED_TOOLS) {
138
151
  options.enabledTools = process.env.ENABLED_TOOLS;
139
152
  }
153
+ if (process.env.ENABLED_TOOLS_FILE) {
154
+ try {
155
+ options.enabledTools = readEnabledToolsFromFile(process.env.ENABLED_TOOLS_FILE);
156
+ } catch (error) {
157
+ console.error(`Error: ${error.message}`);
158
+ process.exit(1);
159
+ }
160
+ }
140
161
  if (options.allowedScopes === void 0 && process.env.MS365_MCP_ALLOWED_SCOPES !== void 0) {
141
162
  options.allowedScopes = process.env.MS365_MCP_ALLOWED_SCOPES;
142
163
  }
@@ -0,0 +1,19 @@
1
+ import { readFileSync } from "node:fs";
2
+ function parseEnabledToolsFileContent(content) {
3
+ return content.split(/\r?\n/).map((line) => line.trim()).filter((line) => !line.startsWith("#")).filter((line) => line.length > 0).join("|");
4
+ }
5
+ function readEnabledToolsFromFile(filePath) {
6
+ let content;
7
+ try {
8
+ content = readFileSync(filePath, "utf8");
9
+ } catch (error) {
10
+ throw new Error(
11
+ `could not read enabled tools file ${JSON.stringify(filePath)}: ${error.message}`
12
+ );
13
+ }
14
+ return parseEnabledToolsFileContent(content);
15
+ }
16
+ export {
17
+ parseEnabledToolsFileContent,
18
+ readEnabledToolsFromFile
19
+ };
@@ -228,7 +228,7 @@ The client automatically discovers OAuth endpoints and opens a browser for authe
228
228
  - **Admin consent**: grant tenant-wide consent to avoid per-user consent prompts
229
229
  - **Managed identity**: use managed identity for Key Vault access (no secrets in environment variables)
230
230
  - **Read-only mode**: use `--read-only` to disable all write operations (send, delete, update, create)
231
- - **Tool filtering**: use `--enabled-tools <regex>` or `--preset <names>` to restrict available tools
231
+ - **Tool filtering**: use `--enabled-tools <regex>`, `--enabled-tools-file <path>` (one regex per line), or `--preset <names>` to restrict available tools
232
232
  - **CORS**: configure `MS365_MCP_CORS_ORIGIN` to restrict allowed origins (defaults to `http://localhost:3000`); set explicitly when clients run on a different origin
233
233
  - **Disable Dynamic Client Registration**: when only a known client talks to the server, set `MS365_MCP_DISABLE_DCR=true` (or pass `--no-dynamic-registration`) to close the anonymous `/register` endpoint
234
234
  - **Structured audit log**: enabled by default. Every tool invocation that reaches Microsoft Graph emits one JSON line on stderr (captured by the container platform's log collector) and to `~/.ms-365-mcp-server/logs/audit.log` (mode `0o600`, or under `MS365_MCP_LOG_DIR` when set) with `{ event, request_id, user_principal_name, tool, http_method, http_status?, status, duration_ms, recipient_count?, recipient_domains?, recipient_domains_truncated?, graph_batch_subrequest_count?, graph_batch_http_status_counts?, graph_batch_error_code_counts?, result_count?, result_has_more?, response_bytes?, target_resource?, error_type?, error_code? }`. A few refusals short-circuit before that and emit nothing: a confirm-gate rejection, an `account` param that contradicts the bearer identity, and a failure to resolve an account token. Policy-blocked tool attempts emit `event: "tool.denied"` with `status: "denied"`, `reason` (`allowed_scopes` or `tool_allowlist`), and `missing_scopes` when applicable. When an audited generated Microsoft Graph tool targets a derivable resource through an ID-like path parameter such as `{message-id}` or `{driveItem-id}`, `target_resource` is `{ type, id }`, where `id` is the Graph path up to that resource ID. Later path parameters such as `{path}`, query values, returned content, and Graph response bodies are NEVER recorded, and error messages are reduced to `error_type` / `error_code` so upstream library errors do not leak token fragments or query-string PII. Response _metadata_ is recorded — `result_count`, `result_has_more` and `response_bytes` describe how much came back so that a bulk read is distinguishable from an ordinary one; none of them reveals any of its content. Two things derived from tool parameters **are** recorded, both deliberately. First, `target_resource.id` substitutes ID-like path parameters into the resource path, so a tool on `/users/{user-id}/...` records whatever identifier the caller passed, which may be a full email address. Second, a request whose body carries `toRecipients` / `ccRecipients` / `bccRecipients` / `attendees` / `recipients`, at any casing and several levels down, including inside a `graph-batch` sub-request, records `recipient_count`, the number of entries in those arrays, and `recipient_domains`, the **domain part only** of their addresses and only where it parses as a plain hostname, never the local part and never a subject or message body. An entry that names someone without an address (a `driveRecipient` given as `alias` or `objectId`) counts but contributes no domain. It keys on body shape rather than on the endpoint, so it covers sends, forwards, invites and file shares but equally draft creation and edits, event updates and `findMeetingTimes`, and it reads high rather than low: an attached message's own recipients are counted too. `recipient_domains` holds at most 50 **distinct domains**, alphabetically, and sets `recipient_domains_truncated: true` when there were more; `recipient_count` is unaffected by the cap. All three are absent when the body carries no recipient array at all. A request that fails after reaching Graph still records recipients, since a timeout is not proof of non-delivery. Gaps remain, so absence proves nothing: a draft composed outside this server and sent by id, the original thread's recipients on a reply (Graph resolves those server-side), and a body nesting recipients deeper than the walker descends. This describes the structured audit log only; the operational logger is separate and does log tool parameters. Forms the "who accessed what, when" trail required for GDPR / HIPAA / PIPEDA / SOC 2 audit. Opt-out: `MS365_MCP_AUDIT_LOG=false`
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.172.0",
4
+ "version": "0.173.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",