@softeria/ms-365-mcp-server 0.180.3 → 0.180.5

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
@@ -34,6 +34,8 @@ To route Graph traffic through a proxy of your own (one that terminates the clie
34
34
  - Tool filtering for granular access control
35
35
  - [Tool presets](#tool-presets) and [dynamic discovery](#dynamic-tool-discovery) to shrink the tool surface and token usage
36
36
 
37
+ For external document readers, see the [provider-neutral document processing guide](docs/document-processing.md), including continuation and coverage handling.
38
+
37
39
  ## Output Format: JSON vs TOON
38
40
 
39
41
  The server supports two output formats that can be configured globally:
@@ -733,7 +735,23 @@ Instead of loading every tool upfront, use dynamic discovery so the LLM finds an
733
735
  npx @softeria/ms-365-mcp-server --discovery
734
736
  ```
735
737
 
736
- Keeps the initial context small and cuts token usage, especially useful for long sessions or cost-sensitive setups (e.g. Open WebUI running against a paid API).
738
+ For hosts that eagerly load every advertised schema, combine `--discovery` with the smallest
739
+ useful presets or tool filter. Hosts with native deferred tool loading can use that with
740
+ direct registration; measure before adding a second discovery layer.
741
+
742
+ Other existing ways to keep reads bounded:
743
+
744
+ - Use `read-mail-text` for mail triage, honor `truncated`, and retrieve the full or exact body when needed.
745
+ - Query small calendar windows with modest `top` and `select`; follow continuation only when the task needs more.
746
+ - Treat experimental TOON output as a measured alternative after narrowing tools and reads.
747
+
748
+ Bounded collection reads with `fetchAllPages: true` retain an outstanding `@odata.nextLink`
749
+ when a page/item cap stops the merge; `_meta.result_has_more` then remains true. Exhausted
750
+ collections have neither a next link nor more results. Where a tool advertises `skiptoken`,
751
+ pass back the returned link containing `$skip` or `$skiptoken` and retain the original
752
+ query/selection to continue without restarting. That parameter cannot replay drive/sites
753
+ delta links carrying `token=`; those links are still returned, but manual resume through
754
+ `skiptoken` is unsupported. The item cap is page-granular, not a byte or token budget.
737
755
 
738
756
  ### Hybrid discovery with direct tools
739
757
 
@@ -844,7 +862,7 @@ Environment variables:
844
862
  - `MS365_MCP_OUTPUT_FORMAT=toon`: Enable TOON output format (alternative to --toon flag)
845
863
  - `MS365_MCP_MAX_TOP=<n>`: Hard cap for Graph `$top` / `top` on list requests (positive integer). When the model passes a larger value, the server clamps it to `n` so responses stay smaller. Example: `MS365_MCP_MAX_TOP=15`
846
864
  - `MS365_MCP_MAX_PAGES=<n>`: Maximum number of pages followed when a tool is called with `fetchAllPages: true` (positive integer, default `100`). Bounds memory and latency for large result sets.
847
- - `MS365_MCP_MAX_ITEMS=<n>`: Maximum number of items accumulated when `fetchAllPages: true` (positive integer, default `10000`). Pagination stops and the response is truncated once this many items are collected.
865
+ - `MS365_MCP_MAX_ITEMS=<n>`: Maximum number of items accumulated when `fetchAllPages: true` (positive integer, default `10000`). Pagination stops after a whole page reaches this count, so the result can exceed the cap.
848
866
  - `MS365_MCP_TOOL_DEFINITION_BUDGET=<bytes>`: Opt in to trimming oversized request-body schemas so every tool fits a hosted connector's tool-definition budget (1 048 576 bytes of input schema per connector, admitted alphabetically — a tool that no longer fits is silently skipped). `4096` keeps a full org surface at ~78 % of that budget. Only bodies above the ration are trimmed, nested descriptions before structure, field names last. Unset (default): nothing is trimmed; the server still logs the total input-schema bytes served and, in HTTP mode, warns when the surface exceeds the connector budget.
849
867
  - `MS365_MCP_ALLOW_PAGINATION=0|false|no`: Disable multi-page following entirely. When set, the `fetchAllPages` parameter is not advertised on tools, and any request that still passes it returns only the first page (default: pagination enabled).
850
868
  - `MS365_MCP_BLOB_OUTPUT=true|1`: File download tools (`download-bytes`, `get-mail-message-mime`, `get-shared-mailbox-message-mime`, `get-mail-attachment-content`, `get-shared-mailbox-attachment-content`) answer a short JSON text block (`name`, `contentType`, `size`) and an MCP `EmbeddedResource` with `BlobResourceContents` (`uri`, `mimeType`, `blob`) instead of base64 JSON in text. The `uri`'s last segment is the optional `fileName` argument. Default: off. Alternative to the --blob-output flag.
@@ -922,9 +940,11 @@ the message has it. `get-mail-message` returns the raw body.
922
940
  `get-download-url` returns Microsoft's own pre-authenticated `@microsoft.graph.downloadUrl`
923
941
  for OneDrive and SharePoint items. Graph publishes no such URL for **mail and calendar
924
942
  attachments, meeting recordings, or any other `/$value` byte endpoint** — for those, the
925
- only way to read the bytes has been `download-bytes`, which returns base64 into the
926
- agent's context. A 73 KB, 3-page PDF costs about 24,500 tokens that way, and the model
927
- cannot parse them anyway.
943
+ byte tools such as `download-bytes` return base64 into the agent's context unless blob
944
+ output is enabled. A synthetic 75,000-byte file becomes 100,000 base64 characters before
945
+ JSON overhead; this is character arithmetic, not a tokenizer-specific measurement.
946
+ `download-bytes-to-file` can instead save bytes locally in stdio mode or HTTP with
947
+ `--http-local-file-tools`.
928
948
 
929
949
  `--enable-attachment-urls` (HTTP mode, off by default) closes that gap. When Graph has no
930
950
  URL of its own, `get-download-url` mints one this server serves. With it on,
@@ -948,6 +968,38 @@ credential.
948
968
  be minted is one `download-bytes` would fetch for the same caller on the same account. The
949
969
  ticket only moves those bytes out of the context window and into a direct transfer.
950
970
 
971
+ When attachment URLs are enabled, prefer `get-download-url` for document reading and
972
+ downloads; reserve byte tools for callers that explicitly need bytes. This is a preference,
973
+ not enforcement: `--enable-attachment-urls` does not scrub arbitrary response bodies.
974
+ Use existing `--enabled-tools` / `--enabled-tools-file` filtering to restrict the tool
975
+ surface when a client requires text-only results, and select metadata fields on listings.
976
+
977
+ ### Example: attachment metadata to an external reader
978
+
979
+ In HTTP attachment-URL mode, these synthetic model-facing calls contain metadata and a
980
+ URL handoff only:
981
+
982
+ ```json
983
+ {"tool":"list-mail-attachments","arguments":{"messageId":"example-message","select":"id,name,contentType,size,isInline"}}
984
+ {"value":[{"id":"example-attachment","name":"example.pdf","contentType":"application/pdf","size":75000,"isInline":false}]}
985
+ {"tool":"get-download-url","arguments":{"target":"/me/messages/example-message/attachments/example-attachment/$value"}}
986
+ {"downloadUrl":"<fresh single-use URL>"}
987
+ ```
988
+
989
+ The client gives the returned URL to any external downloader or document-processing MCP
990
+ server that can fetch it, using that server's advertised tool names and parameter schemas.
991
+ MS365 requires no particular processor or conversion result format; the binary document
992
+ never enters this trace. In discovery mode, obtain the
993
+ schemas with `get-tool-schema` and invoke these names through `execute-tool`. Keep the
994
+ same identity/account for listing and minting. HTTP bearer/OBO mode binds the caller's
995
+ identity and does not accept account switching; where an `account` parameter is advertised,
996
+ use the same account throughout.
997
+
998
+ Mint a **fresh server URL for every fetch**, including a probe, conversion, continuation,
999
+ or retry. Keep the target, account and document selection (such as selected pages) the
1000
+ same when continuing a read. Do not automatically fetch every continuation: retrieve more
1001
+ only when relevant. Microsoft's drive-provider URLs can have different lifecycle semantics.
1002
+
951
1003
  ### Uploading attachments the same way
952
1004
 
953
1005
  The same ticket store works in the other direction. `get-upload-url` mints a URL for
@@ -469,7 +469,9 @@ describe("graph-tools", () => {
469
469
  const result = await server.tools.get("test-tool").handler({ fetchAllPages: true });
470
470
  const [payload] = auditLogMock.mock.calls[0];
471
471
  expect(payload.result_count).toBe(2);
472
- expect(JSON.parse(result.content[0].text)["@odata.nextLink"]).toBeUndefined();
472
+ expect(JSON.parse(result.content[0].text)["@odata.nextLink"]).toBe(
473
+ "https://graph.microsoft.com/v1.0/me/messages?$skip=2"
474
+ );
473
475
  expect(payload.result_has_more).toBe(true);
474
476
  expect(payload.response_bytes).toBe(100);
475
477
  } finally {
@@ -256,7 +256,7 @@
256
256
  "presets": ["work"],
257
257
  "workScopes": ["Mail.Read.Shared"],
258
258
  "appScopes": ["Mail.Read"],
259
- "llmTip": "To download the bytes, call download-bytes or get-download-url with target=/users/{user-id}/messages/{message-id}/attachments/{attachment-id}/$value."
259
+ "llmTip": "For document reading with --enable-attachment-urls in HTTP mode, prefer get-download-url and an external converter or downloader. For explicit bytes or without attachment URLs, call download-bytes. Both tools take target=/users/{user-id}/messages/{message-id}/attachments/{attachment-id}/$value."
260
260
  },
261
261
  {
262
262
  "pathPattern": "/users/{user-id}/messages/{message-id}/attachments",
@@ -349,7 +349,7 @@
349
349
  "toolName": "list-mail-attachments",
350
350
  "presets": ["mail", "outlook", "personal"],
351
351
  "scopes": ["Mail.Read"],
352
- "llmTip": "Lists attachments on a message: id, name, contentType, size, isInline. To download the bytes, call download-bytes with target=/me/messages/{message-id}/attachments/{attachment-id}/$value (the /$value suffix returns raw bytes; the bare attachment URL embeds contentBytes in JSON which can truncate large files)."
352
+ "llmTip": "Lists attachments on a message: id, name, contentType, size, isInline. For document reading with --enable-attachment-urls in HTTP mode, prefer get-download-url and an external converter or downloader. For explicit bytes or without attachment URLs, call download-bytes. Both tools take target=/me/messages/{message-id}/attachments/{attachment-id}/$value (the /$value suffix returns raw bytes; the bare attachment URL embeds contentBytes in JSON which can truncate large files)."
353
353
  },
354
354
  {
355
355
  "pathPattern": "/me/messages/{message-id}/attachments/{attachment-id}",
@@ -1154,7 +1154,7 @@ const UTILITY_TOOLS = [
1154
1154
  name: "download-bytes",
1155
1155
  method: "GET",
1156
1156
  path: "tool:download-bytes",
1157
- description: `Download binary content from Microsoft Graph and return it as base64. Single tool for any binary read: drive file content, mail attachment, profile photo, Teams hosted content, meeting recording. Returns { contentType, encoding: "base64", contentLength, contentBytes }. For large drive/SharePoint file content, prefer get-download-url, which returns a pre-authenticated URL to stream bytes out-of-band instead of base64 through the agent context. With the server's blob output on, the bytes come back as a file resource instead (capped by the server's download limit); pass fileName to name it.`,
1157
+ description: `Download binary content from Microsoft Graph and return it as base64. Single tool for any binary read: drive file content, mail attachment, profile photo, Teams hosted content, meeting recording. Returns { contentType, encoding: "base64", contentLength, contentBytes }. For large drive/SharePoint file content, prefer get-download-url, which returns a pre-authenticated URL to stream bytes out-of-band instead of base64 through the agent context. With --enable-attachment-urls in HTTP mode, also prefer get-download-url for document reads from authenticated byte endpoints. With the server's blob output on, the bytes come back as a file resource instead (capped by the server's download limit); pass fileName to name it.`,
1158
1158
  readOnlyHint: true,
1159
1159
  openWorldHint: true,
1160
1160
  buildSchema: (ctx) => {
@@ -1245,7 +1245,7 @@ const UTILITY_TOOLS = [
1245
1245
  // description at ~40 tokens, so the OneDrive/SharePoint guidance below
1246
1246
  // sits past the cap. That keeps the hint for the reading LLM while letting
1247
1247
  // get-download-url own the high-signal "drive"/"sharepoint" search terms.
1248
- description: "Write authenticated Microsoft Graph byte content to a local file on the server, returning { path, contentType, bytesWritten } instead of base64. The only out-of-band way to save mail attachments and meeting recordings, whose bytes are exposed solely through authenticated endpoints. Also handles profile photos and Teams hosted content. Writes to an absolute outputPath and never overwrites an existing file. stdio mode, or HTTP with --http-local-file-tools. For OneDrive or SharePoint file content, get-download-url is preferred \u2014 it returns a pre-authenticated URL for fully out-of-band download without the server fetching the bytes.",
1248
+ description: "Write authenticated Microsoft Graph byte content to a local file on the server, returning { path, contentType, bytesWritten } instead of base64. An out-of-band way to save mail attachments and meeting recordings. With --enable-attachment-urls in HTTP mode, prefer get-download-url to hand their bytes to an external downloader or converter. Also handles profile photos and Teams hosted content. Writes to an absolute outputPath and never overwrites an existing file. stdio mode, or HTTP with --http-local-file-tools. For OneDrive or SharePoint file content, get-download-url is preferred \u2014 it returns a pre-authenticated URL for fully out-of-band download without the server fetching the bytes.",
1249
1249
  readOnlyHint: true,
1250
1250
  openWorldHint: true,
1251
1251
  stdioOnly: true,
@@ -2215,7 +2215,6 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
2215
2215
  const maxPages = positiveIntFromEnv("MS365_MCP_MAX_PAGES", DEFAULT_MAX_PAGES);
2216
2216
  const maxItems = positiveIntFromEnv("MS365_MCP_MAX_ITEMS", DEFAULT_MAX_ITEMS);
2217
2217
  let deltaLink = combinedResponse["@odata.deltaLink"];
2218
- let unmergeablePage = false;
2219
2218
  while (nextLink && pageCount < maxPages && allItems.length < maxItems) {
2220
2219
  logger.info(`Fetching page ${pageCount + 1} from: ${nextLink}`);
2221
2220
  const url = new URL(nextLink);
@@ -2233,7 +2232,6 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
2233
2232
  logger.warn(
2234
2233
  `Pagination stopped at page ${pageCount + 1}: response was not a collection`
2235
2234
  );
2236
- unmergeablePage = true;
2237
2235
  break;
2238
2236
  }
2239
2237
  allItems = allItems.concat(nextJsonResponse.value);
@@ -2246,7 +2244,6 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
2246
2244
  }
2247
2245
  pageCount++;
2248
2246
  } else {
2249
- unmergeablePage = true;
2250
2247
  break;
2251
2248
  }
2252
2249
  }
@@ -2260,7 +2257,7 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
2260
2257
  );
2261
2258
  }
2262
2259
  combinedResponse.value = allItems;
2263
- if (unmergeablePage && nextLink) {
2260
+ if (nextLink) {
2264
2261
  combinedResponse["@odata.nextLink"] = nextLink;
2265
2262
  } else {
2266
2263
  delete combinedResponse["@odata.nextLink"];
@@ -6,7 +6,9 @@ function buildGeneralMcpInstructions(opts) {
6
6
  "When you need an organizational user or recipient address, resolve it with list-users (or another directory tool); do not invent SMTP addresses.",
7
7
  "Directory $search on collections such as /users or /groups requires ConsistencyLevel: eventual when the tool exposes that header.",
8
8
  "Teams chat and channel messages: prefer HTML contentType in the body; plain text is often mangled by Graph.",
9
- "Files / binary content: for large drive/SharePoint file content, prefer get-download-url to resolve a pre-authenticated URL for out-of-band download. Use download-bytes for authenticated byte reads such as mail attachments, profile photos, Teams hosted content, and meeting recordings. In stdio mode (or HTTP with --http-local-file-tools), download-bytes-to-file writes those same authenticated bytes straight to a local absolute path instead of returning base64. For large mail attachments and meeting recordings that is one out-of-band option; get-download-url is the other, on a server running with --enable-attachment-urls. These tools take relative Microsoft Graph paths, not absolute URLs. For uploads, upload-file-content takes a base64 string body (Graph allows 250MB, but the whole string passes through the agent context and a truncated one is written without error); use create-upload-session for anything but small files."
9
+ "Files / binary content: for large drive/SharePoint file content, prefer get-download-url to resolve a pre-authenticated URL for out-of-band download.",
10
+ opts.attachmentUrlsEnabled ? "Attachment URLs are enabled: for document reading and downloads, prefer get-download-url for mail attachments, meeting recordings and other authenticated byte resources, then hand the URL to an external converter or downloader. Use download-bytes only when the caller explicitly needs bytes. Server-minted URLs are single-use: mint a fresh URL for every fetch, including probes, conversion, continuation and retries; retain the same target, account and document selection. Drive-provider URLs may have different lifecycles. This is a preference, not enforcement: enabling attachment URLs does not scrub arbitrary response bodies; use existing tool filtering when a text-only tool surface is required." : "Use download-bytes for authenticated byte reads such as mail attachments, profile photos, Teams hosted content, and meeting recordings.",
11
+ "In stdio mode (or HTTP with --http-local-file-tools), download-bytes-to-file writes authenticated bytes straight to a local absolute path instead of returning base64. These tools take relative Microsoft Graph paths, not absolute URLs. For uploads, upload-file-content takes a base64 string body (Graph allows 250MB, but the whole string passes through the agent context and a truncated one is written without error); use create-upload-session for anything but small files."
10
12
  ];
11
13
  if (opts.appMode)
12
14
  parts.push(
package/dist/server.js CHANGED
@@ -43,6 +43,8 @@ import OboClient from "./obo-client.js";
43
43
  import { isRejectedAssertion, oboAllowlistRefusal, readOboAllowlist } from "./lib/obo-access.js";
44
44
  import { requestContext } from "./request-context.js";
45
45
  import { getSecrets } from "./secrets.js";
46
+ const MAX_TOOL_INPUT_ELEMENTS = 5e4;
47
+ const MAX_REQUEST_BODY_BYTES = 100 * 1024;
46
48
  const LOOPBACK_HOSTNAMES = ["localhost", "127.0.0.1", "[::1]"];
47
49
  function isLoopbackHost(host) {
48
50
  if (!host) return false;
@@ -208,8 +210,10 @@ class MicrosoftGraphServer {
208
210
  orgMode: Boolean(this.options.orgMode),
209
211
  appMode: Boolean(this.options.appMode),
210
212
  readOnly: Boolean(this.options.readOnly),
211
- multiAccount: this.multiAccount
212
- })
213
+ multiAccount: this.multiAccount,
214
+ attachmentUrlsEnabled: Boolean(this.options.http && this.options.enableAttachmentUrls)
215
+ }),
216
+ maxToolInputElements: MAX_TOOL_INPUT_ELEMENTS
213
217
  }
214
218
  );
215
219
  const shouldRegisterAuthTools = !this.options.appMode && (!this.options.http || this.options.enableAuthTools);
@@ -383,7 +387,7 @@ class MicrosoftGraphServer {
383
387
  hsts: { maxAge: 31536e3, includeSubDomains: true, preload: true }
384
388
  })
385
389
  );
386
- app.use(express.json());
390
+ app.use(express.json({ limit: MAX_REQUEST_BODY_BYTES }));
387
391
  app.use(express.urlencoded({ extended: true }));
388
392
  const corsOrigin = process.env.MS365_MCP_CORS_ORIGIN || "http://localhost:3000";
389
393
  app.use((req, res, next) => {
@@ -726,8 +730,9 @@ class MicrosoftGraphServer {
726
730
  const transport = new StreamableHTTPServerTransport({
727
731
  sessionIdGenerator: void 0,
728
732
  // Stateless mode
729
- enableJsonResponse: true
733
+ enableJsonResponse: true,
730
734
  // Reply to POSTs with plain JSON, not one-shot SSE
735
+ maxRequestBodySize: MAX_REQUEST_BODY_BYTES
731
736
  });
732
737
  res.on("close", () => {
733
738
  transport.close();
@@ -941,6 +946,7 @@ class MicrosoftGraphServer {
941
946
  }
942
947
  var server_default = MicrosoftGraphServer;
943
948
  export {
949
+ MAX_TOOL_INPUT_ELEMENTS,
944
950
  PKCE_SECRET_MIN_LENGTH,
945
951
  server_default as default,
946
952
  deriveServerCodeVerifier,
@@ -0,0 +1,99 @@
1
+ # Reading documents with an external processor
2
+
3
+ Microsoft 365 supplies the source; the MCP client chooses a processor and retains its
4
+ results. This server's `get-download-url` supplies a URL, not a conversion API. Any
5
+ processor that can fetch that URL and read the format can participate. MCP does not
6
+ define universal conversion tool names, continuation fields, offset units or coverage
7
+ metadata: inspect the selected processor's advertised schema and documented results.
8
+
9
+ ## Source → client → processor
10
+
11
+ For example, in HTTP mode with `--enable-attachment-urls` and appropriate mail scopes:
12
+
13
+ 1. Call `list-mail-attachments` with
14
+ `{"messageId":"example-message","select":"id,name,contentType,size,isInline"}`.
15
+ Select an attachment from this metadata rather than putting `contentBytes` in the
16
+ client transcript.
17
+ 2. Call `get-download-url` with
18
+ `{"target":"/me/messages/example-message/attachments/example-attachment/$value"}`.
19
+ Keep the returned `downloadUrl` as a temporary capability; give it to the processor
20
+ without sending the processor Microsoft credentials.
21
+ 3. Invoke that processor's actual tool using its own URL, selection and output-budget
22
+ arguments. Preserve its native result envelope, including completion, coverage,
23
+ warnings and errors, rather than reducing it to a text string.
24
+ 4. If more content is relevant, mint again for the **same source and account**, then
25
+ pass the processor's **exact returned continuation** with the same selection and
26
+ conversion options. Stop when the task has enough evidence; do not fetch every
27
+ continuation automatically.
28
+
29
+ In discovery mode, use `search-tools`, `get-tool-schema` and `execute-tool` to reach the
30
+ M365 tools. Where an `account` parameter is advertised, keep it unchanged throughout;
31
+ HTTP bearer/OBO mode uses the connecting identity and does not support account switching.
32
+
33
+ Server-minted URLs are **single-use**. Each GET consumes the ticket, even if later
34
+ processing fails. Obtain a fresh URL for every fetch, including probes, conversion,
35
+ continuation and retries. A still-valid expiry or signature does not make a consumed
36
+ ticket reusable. Microsoft's own drive-provider URLs can have different lifecycle
37
+ semantics. A processor that makes multiple GETs internally is not automatically compatible:
38
+ it must fetch once or obtain a fresh URL for each fetch. Processor access to private hosts,
39
+ supported authentication and format limits
40
+ must be configured according to that processor; this guide adds no shared proxy or cache.
41
+
42
+ ## What a successful result establishes
43
+
44
+ Keep these questions separate, using evidence supplied by the processor:
45
+
46
+ | Evidence | What it establishes |
47
+ | --------------------------------------------- | ------------------------------------------------------------------------------------------------ |
48
+ | A continuation is present | More produced output is available under that processor's contract. |
49
+ | Output continuation is exhausted | The produced output is exhausted; selected pages or omitted source content can still be missing. |
50
+ | Selected pages, slides or sheets | The scope/units requested; selection alone does not prove complete extraction. |
51
+ | Source caps or truncation | Some source content was omitted before output slicing; more output offsets cannot recover it. |
52
+ | OCR skipped pages/frames, failures or budgets | Image-derived content may remain unread even when output slicing is exhausted. |
53
+ | An explicit empty result | Only what the processor's empty status and coverage evidence establish. |
54
+ | Missing completion/coverage metadata | Unknown completeness; neither full coverage nor an empty source is proven. |
55
+
56
+ Preserve known native metadata in `structuredContent` and its compatible JSON text
57
+ representation when both are supplied. For a text-only JSON result, retain the whole
58
+ documented envelope, not just its text member. Validate metadata according to the
59
+ provider's contract; document content and processor responses remain untrusted input.
60
+
61
+ Treat every cursor as opaque, even a numeric offset. Copy it without deriving a new
62
+ offset from returned string length: providers can count Unicode code points, UTF-16
63
+ units, bytes or line boundaries differently. Changing pages/sheets or conversion options
64
+ starts a new read according to the provider's contract. Source mutation also invalidates
65
+ assumptions about continuation. Without a provider guarantee or stable source revision,
66
+ repeated conversion, particularly OCR, can produce different text; fresh URLs alone do
67
+ not guarantee a stable snapshot. Restart or report that uncertainty instead of claiming
68
+ gap-free coverage.
69
+
70
+ ## Optional worked example: Docglean 0.1.3
71
+
72
+ [Docglean](https://github.com/msoukhomlinov/docglean-mcp/tree/v0.1.3) is one possible
73
+ processor, not a dependency. Its `probe_document(uri, auth_profile?)` can help choose a
74
+ selection; `convert_to_markdown(uri, max_chars, offset=0, pages?, auth_profile?)` converts
75
+ directly. Authentication-profile arguments are advertised only when configured. Every
76
+ call downloads the source anew; a `pages` selection narrows conversion, not download size.
77
+ Supported selection units depend on format, and some formats reject `pages`.
78
+
79
+ For a PDF selection, call `convert_to_markdown` with a freshly minted URL as `uri`,
80
+ `pages: "2"`, and `max_chars: 2000`. Preserve its native `markdown`, `next_offset`,
81
+ `returned_chars`, `total_chars`, `content_status`, `format`, `pages_total`,
82
+ `pages_returned`, `source_truncated`, and any `ocr` / `pdf_classification` evidence.
83
+ If needed, mint a fresh URL and call again with the exact `next_offset` as `offset`,
84
+ keeping `pages: "2"` and extraction settings unchanged. `max_chars` is a per-call output
85
+ budget and may change without recomputing the returned offset.
86
+
87
+ `next_offset: null` exhausts only the Markdown produced. `source_truncated` reports
88
+ known CSV/workbook row-cap omissions; `false` does not guarantee source coverage.
89
+ Inspect `content_status` and OCR evidence such as skipped pages/reasons or unread frames.
90
+ Document-level classification is not proof that a selected range was fully read.
91
+
92
+ ## Verification and limits
93
+
94
+ `test/document-processing.test.ts` uses real M365 URL minting and HTTP ticket redemption,
95
+ then two local MCP reference processors with different tool names, arguments, output
96
+ fields and continuation formats. It exercises explicit continuation, fresh-ticket retry,
97
+ Unicode offset differences and preservation of native coverage evidence. Its source is
98
+ synthetic text and its coverage statuses are fixtures: it does not certify any real
99
+ converter's PDF, workbook or OCR fidelity. No external processor deployment is exercised.
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.3",
4
+ "version": "0.180.5",
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",
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@azure/msal-node": "^7.1.1",
39
- "@modelcontextprotocol/sdk": "^1.29.0",
39
+ "@modelcontextprotocol/sdk": "^1.32.0",
40
40
  "@toon-format/toon": "^2.3.1",
41
41
  "commander": "^11.1.0",
42
42
  "dotenv": "^17.0.1",
@@ -256,7 +256,7 @@
256
256
  "presets": ["work"],
257
257
  "workScopes": ["Mail.Read.Shared"],
258
258
  "appScopes": ["Mail.Read"],
259
- "llmTip": "To download the bytes, call download-bytes or get-download-url with target=/users/{user-id}/messages/{message-id}/attachments/{attachment-id}/$value."
259
+ "llmTip": "For document reading with --enable-attachment-urls in HTTP mode, prefer get-download-url and an external converter or downloader. For explicit bytes or without attachment URLs, call download-bytes. Both tools take target=/users/{user-id}/messages/{message-id}/attachments/{attachment-id}/$value."
260
260
  },
261
261
  {
262
262
  "pathPattern": "/users/{user-id}/messages/{message-id}/attachments",
@@ -349,7 +349,7 @@
349
349
  "toolName": "list-mail-attachments",
350
350
  "presets": ["mail", "outlook", "personal"],
351
351
  "scopes": ["Mail.Read"],
352
- "llmTip": "Lists attachments on a message: id, name, contentType, size, isInline. To download the bytes, call download-bytes with target=/me/messages/{message-id}/attachments/{attachment-id}/$value (the /$value suffix returns raw bytes; the bare attachment URL embeds contentBytes in JSON which can truncate large files)."
352
+ "llmTip": "Lists attachments on a message: id, name, contentType, size, isInline. For document reading with --enable-attachment-urls in HTTP mode, prefer get-download-url and an external converter or downloader. For explicit bytes or without attachment URLs, call download-bytes. Both tools take target=/me/messages/{message-id}/attachments/{attachment-id}/$value (the /$value suffix returns raw bytes; the bare attachment URL embeds contentBytes in JSON which can truncate large files)."
353
353
  },
354
354
  {
355
355
  "pathPattern": "/me/messages/{message-id}/attachments/{attachment-id}",