@softeria/ms-365-mcp-server 0.180.3 → 0.180.4
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 +55 -5
- package/dist/__tests__/graph-tools.test.js +3 -1
- package/dist/endpoints.json +2 -2
- package/dist/graph-tools.js +3 -6
- package/dist/mcp-instructions.js +3 -1
- package/dist/server.js +2 -1
- package/package.json +1 -1
- package/src/endpoints.json +2 -2
package/README.md
CHANGED
|
@@ -733,7 +733,23 @@ Instead of loading every tool upfront, use dynamic discovery so the LLM finds an
|
|
|
733
733
|
npx @softeria/ms-365-mcp-server --discovery
|
|
734
734
|
```
|
|
735
735
|
|
|
736
|
-
|
|
736
|
+
For hosts that eagerly load every advertised schema, combine `--discovery` with the smallest
|
|
737
|
+
useful presets or tool filter. Hosts with native deferred tool loading can use that with
|
|
738
|
+
direct registration; measure before adding a second discovery layer.
|
|
739
|
+
|
|
740
|
+
Other existing ways to keep reads bounded:
|
|
741
|
+
|
|
742
|
+
- Use `read-mail-text` for mail triage, honor `truncated`, and retrieve the full or exact body when needed.
|
|
743
|
+
- Query small calendar windows with modest `top` and `select`; follow continuation only when the task needs more.
|
|
744
|
+
- Treat experimental TOON output as a measured alternative after narrowing tools and reads.
|
|
745
|
+
|
|
746
|
+
Bounded collection reads with `fetchAllPages: true` retain an outstanding `@odata.nextLink`
|
|
747
|
+
when a page/item cap stops the merge; `_meta.result_has_more` then remains true. Exhausted
|
|
748
|
+
collections have neither a next link nor more results. Where a tool advertises `skiptoken`,
|
|
749
|
+
pass back the returned link containing `$skip` or `$skiptoken` and retain the original
|
|
750
|
+
query/selection to continue without restarting. That parameter cannot replay drive/sites
|
|
751
|
+
delta links carrying `token=`; those links are still returned, but manual resume through
|
|
752
|
+
`skiptoken` is unsupported. The item cap is page-granular, not a byte or token budget.
|
|
737
753
|
|
|
738
754
|
### Hybrid discovery with direct tools
|
|
739
755
|
|
|
@@ -844,7 +860,7 @@ Environment variables:
|
|
|
844
860
|
- `MS365_MCP_OUTPUT_FORMAT=toon`: Enable TOON output format (alternative to --toon flag)
|
|
845
861
|
- `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
862
|
- `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
|
|
863
|
+
- `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
864
|
- `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
865
|
- `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
866
|
- `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 +938,11 @@ the message has it. `get-mail-message` returns the raw body.
|
|
|
922
938
|
`get-download-url` returns Microsoft's own pre-authenticated `@microsoft.graph.downloadUrl`
|
|
923
939
|
for OneDrive and SharePoint items. Graph publishes no such URL for **mail and calendar
|
|
924
940
|
attachments, meeting recordings, or any other `/$value` byte endpoint** — for those, the
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
941
|
+
byte tools such as `download-bytes` return base64 into the agent's context unless blob
|
|
942
|
+
output is enabled. A synthetic 75,000-byte file becomes 100,000 base64 characters before
|
|
943
|
+
JSON overhead; this is character arithmetic, not a tokenizer-specific measurement.
|
|
944
|
+
`download-bytes-to-file` can instead save bytes locally in stdio mode or HTTP with
|
|
945
|
+
`--http-local-file-tools`.
|
|
928
946
|
|
|
929
947
|
`--enable-attachment-urls` (HTTP mode, off by default) closes that gap. When Graph has no
|
|
930
948
|
URL of its own, `get-download-url` mints one this server serves. With it on,
|
|
@@ -948,6 +966,38 @@ credential.
|
|
|
948
966
|
be minted is one `download-bytes` would fetch for the same caller on the same account. The
|
|
949
967
|
ticket only moves those bytes out of the context window and into a direct transfer.
|
|
950
968
|
|
|
969
|
+
When attachment URLs are enabled, prefer `get-download-url` for document reading and
|
|
970
|
+
downloads; reserve byte tools for callers that explicitly need bytes. This is a preference,
|
|
971
|
+
not enforcement: `--enable-attachment-urls` does not scrub arbitrary response bodies.
|
|
972
|
+
Use existing `--enabled-tools` / `--enabled-tools-file` filtering to restrict the tool
|
|
973
|
+
surface when a client requires text-only results, and select metadata fields on listings.
|
|
974
|
+
|
|
975
|
+
### Example: attachment metadata to an external reader
|
|
976
|
+
|
|
977
|
+
In HTTP attachment-URL mode, these synthetic model-facing calls contain metadata and a
|
|
978
|
+
URL handoff only:
|
|
979
|
+
|
|
980
|
+
```json
|
|
981
|
+
{"tool":"list-mail-attachments","arguments":{"messageId":"example-message","select":"id,name,contentType,size,isInline"}}
|
|
982
|
+
{"value":[{"id":"example-attachment","name":"example.pdf","contentType":"application/pdf","size":75000,"isInline":false}]}
|
|
983
|
+
{"tool":"get-download-url","arguments":{"target":"/me/messages/example-message/attachments/example-attachment/$value"}}
|
|
984
|
+
{"downloadUrl":"<fresh single-use URL>"}
|
|
985
|
+
```
|
|
986
|
+
|
|
987
|
+
The client gives the returned URL to any external downloader or document-processing MCP
|
|
988
|
+
server that can fetch it, using that server's advertised tool names and parameter schemas.
|
|
989
|
+
MS365 requires no particular processor or conversion result format; the binary document
|
|
990
|
+
never enters this trace. In discovery mode, obtain the
|
|
991
|
+
schemas with `get-tool-schema` and invoke these names through `execute-tool`. Keep the
|
|
992
|
+
same identity/account for listing and minting. HTTP bearer/OBO mode binds the caller's
|
|
993
|
+
identity and does not accept account switching; where an `account` parameter is advertised,
|
|
994
|
+
use the same account throughout.
|
|
995
|
+
|
|
996
|
+
Mint a **fresh server URL for every fetch**, including a probe, conversion, continuation,
|
|
997
|
+
or retry. Keep the target, account and document selection (such as selected pages) the
|
|
998
|
+
same when continuing a read. Do not automatically fetch every continuation: retrieve more
|
|
999
|
+
only when relevant. Microsoft's drive-provider URLs can have different lifecycle semantics.
|
|
1000
|
+
|
|
951
1001
|
### Uploading attachments the same way
|
|
952
1002
|
|
|
953
1003
|
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"]).
|
|
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 {
|
package/dist/endpoints.json
CHANGED
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
"presets": ["work"],
|
|
257
257
|
"workScopes": ["Mail.Read.Shared"],
|
|
258
258
|
"appScopes": ["Mail.Read"],
|
|
259
|
-
"llmTip": "
|
|
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.
|
|
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}",
|
package/dist/graph-tools.js
CHANGED
|
@@ -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.
|
|
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 (
|
|
2260
|
+
if (nextLink) {
|
|
2264
2261
|
combinedResponse["@odata.nextLink"] = nextLink;
|
|
2265
2262
|
} else {
|
|
2266
2263
|
delete combinedResponse["@odata.nextLink"];
|
package/dist/mcp-instructions.js
CHANGED
|
@@ -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.
|
|
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
|
@@ -208,7 +208,8 @@ class MicrosoftGraphServer {
|
|
|
208
208
|
orgMode: Boolean(this.options.orgMode),
|
|
209
209
|
appMode: Boolean(this.options.appMode),
|
|
210
210
|
readOnly: Boolean(this.options.readOnly),
|
|
211
|
-
multiAccount: this.multiAccount
|
|
211
|
+
multiAccount: this.multiAccount,
|
|
212
|
+
attachmentUrlsEnabled: Boolean(this.options.http && this.options.enableAttachmentUrls)
|
|
212
213
|
})
|
|
213
214
|
}
|
|
214
215
|
);
|
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
|
+
"version": "0.180.4",
|
|
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",
|
package/src/endpoints.json
CHANGED
|
@@ -256,7 +256,7 @@
|
|
|
256
256
|
"presets": ["work"],
|
|
257
257
|
"workScopes": ["Mail.Read.Shared"],
|
|
258
258
|
"appScopes": ["Mail.Read"],
|
|
259
|
-
"llmTip": "
|
|
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.
|
|
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}",
|