@softeria/ms-365-mcp-server 0.180.4 → 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:
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;
@@ -210,7 +212,8 @@ class MicrosoftGraphServer {
210
212
  readOnly: Boolean(this.options.readOnly),
211
213
  multiAccount: this.multiAccount,
212
214
  attachmentUrlsEnabled: Boolean(this.options.http && this.options.enableAttachmentUrls)
213
- })
215
+ }),
216
+ maxToolInputElements: MAX_TOOL_INPUT_ELEMENTS
214
217
  }
215
218
  );
216
219
  const shouldRegisterAuthTools = !this.options.appMode && (!this.options.http || this.options.enableAuthTools);
@@ -384,7 +387,7 @@ class MicrosoftGraphServer {
384
387
  hsts: { maxAge: 31536e3, includeSubDomains: true, preload: true }
385
388
  })
386
389
  );
387
- app.use(express.json());
390
+ app.use(express.json({ limit: MAX_REQUEST_BODY_BYTES }));
388
391
  app.use(express.urlencoded({ extended: true }));
389
392
  const corsOrigin = process.env.MS365_MCP_CORS_ORIGIN || "http://localhost:3000";
390
393
  app.use((req, res, next) => {
@@ -727,8 +730,9 @@ class MicrosoftGraphServer {
727
730
  const transport = new StreamableHTTPServerTransport({
728
731
  sessionIdGenerator: void 0,
729
732
  // Stateless mode
730
- enableJsonResponse: true
733
+ enableJsonResponse: true,
731
734
  // Reply to POSTs with plain JSON, not one-shot SSE
735
+ maxRequestBodySize: MAX_REQUEST_BODY_BYTES
732
736
  });
733
737
  res.on("close", () => {
734
738
  transport.close();
@@ -942,6 +946,7 @@ class MicrosoftGraphServer {
942
946
  }
943
947
  var server_default = MicrosoftGraphServer;
944
948
  export {
949
+ MAX_TOOL_INPUT_ELEMENTS,
945
950
  PKCE_SECRET_MIN_LENGTH,
946
951
  server_default as default,
947
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.4",
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",