@softeria/ms-365-mcp-server 0.183.0 → 0.184.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/README.md +6 -2
- package/bin/modules/simplified-openapi.mjs +29 -0
- package/dist/endpoints.json +16 -4
- package/dist/generated/client.js +15 -1
- package/dist/graph-tools.js +64 -14
- package/package.json +1 -1
- package/src/endpoints.json +16 -4
package/README.md
CHANGED
|
@@ -954,7 +954,11 @@ SharePoint files get a minted URL too, instead of Graph's own: that one is about
|
|
|
954
954
|
characters, too long for an agent that has to type it into a command, such as `curl` in a
|
|
955
955
|
sandbox that cannot see tool results. A minted URL only
|
|
956
956
|
works if the preset's scopes cover the resource: a contacts, tasks or excel preset has no Mail
|
|
957
|
-
scopes, so a
|
|
957
|
+
scopes, so it cannot read a mail attachment. For a mail or calendar attachment addressed by
|
|
958
|
+
its message or event id (such as `/me/messages/{id}/attachments/{id}/$value`),
|
|
959
|
+
`get-download-url` asks Graph about the attachment first. When Graph rejects the ids, finds no
|
|
960
|
+
such attachment or denies access, it returns Graph's error instead of a URL; otherwise the URL
|
|
961
|
+
comes with the attachment's `name`, `size` and `contentType`, when Graph reports them.
|
|
958
962
|
|
|
959
963
|
The minted URL looks like:
|
|
960
964
|
|
|
@@ -986,7 +990,7 @@ URL handoff only:
|
|
|
986
990
|
{"tool":"list-mail-attachments","arguments":{"messageId":"example-message","select":"id,name,contentType,size,isInline"}}
|
|
987
991
|
{"value":[{"id":"example-attachment","name":"example.pdf","contentType":"application/pdf","size":75000,"isInline":false}]}
|
|
988
992
|
{"tool":"get-download-url","arguments":{"target":"/me/messages/example-message/attachments/example-attachment/$value"}}
|
|
989
|
-
{"downloadUrl":"<fresh single-use URL>"}
|
|
993
|
+
{"downloadUrl":"<fresh single-use URL>","name":"example.pdf","size":75000,"contentType":"application/pdf"}
|
|
990
994
|
```
|
|
991
995
|
|
|
992
996
|
The client gives the returned URL to any external downloader or document-processing MCP
|
|
@@ -155,6 +155,9 @@ export function createAndSaveSimplifiedOpenAPI(
|
|
|
155
155
|
return param;
|
|
156
156
|
});
|
|
157
157
|
}
|
|
158
|
+
if (eo.extraQueryParams) {
|
|
159
|
+
operation.parameters = applyExtraQueryParams(operation.parameters, eo);
|
|
160
|
+
}
|
|
158
161
|
} else {
|
|
159
162
|
delete value[method];
|
|
160
163
|
}
|
|
@@ -183,6 +186,32 @@ export function createAndSaveSimplifiedOpenAPI(
|
|
|
183
186
|
fs.writeFileSync(openapiTrimmedFile, yaml.dump(openApiSpec));
|
|
184
187
|
}
|
|
185
188
|
|
|
189
|
+
// Adds the optional query params an endpoint declares in extraQueryParams (name -> JSON
|
|
190
|
+
// Schema), for options Microsoft's spec leaves out. A same-named spec param is replaced, not
|
|
191
|
+
// kept beside ours: the spec is downloaded fresh, so the build must survive Microsoft adding it.
|
|
192
|
+
export function applyExtraQueryParams(parameters, endpoint, warn = console.warn) {
|
|
193
|
+
const extras = Object.entries(endpoint.extraQueryParams ?? {});
|
|
194
|
+
if (extras.length === 0) return parameters;
|
|
195
|
+
|
|
196
|
+
const bare = (name) => String(name).replace(/^\$/, '').toLowerCase();
|
|
197
|
+
const declared = new Set(extras.map(([name]) => bare(name)));
|
|
198
|
+
const kept = (parameters ?? []).filter((param) => {
|
|
199
|
+
if (param.in !== 'query' || !declared.has(bare(param.name))) return true;
|
|
200
|
+
warn(
|
|
201
|
+
`${endpoint.toolName}: the spec now has query param ${param.name}; using extraQueryParams`
|
|
202
|
+
);
|
|
203
|
+
return false;
|
|
204
|
+
});
|
|
205
|
+
const added = extras.map(([name, { description, ...schema }]) => ({
|
|
206
|
+
name,
|
|
207
|
+
in: 'query',
|
|
208
|
+
required: false,
|
|
209
|
+
...(description === undefined ? {} : { description }),
|
|
210
|
+
schema,
|
|
211
|
+
}));
|
|
212
|
+
return [...kept, ...added];
|
|
213
|
+
}
|
|
214
|
+
|
|
186
215
|
// Microsoft's spec is generated from CSDL, so operations that are plain CRUD over a
|
|
187
216
|
// navigation property never get prose. They get scaffolding naming the property and its
|
|
188
217
|
// parent instead - "Create new navigation property to messages for users" - which
|
package/dist/endpoints.json
CHANGED
|
@@ -1259,7 +1259,13 @@
|
|
|
1259
1259
|
"method": "get",
|
|
1260
1260
|
"toolName": "get-onenote-page-content",
|
|
1261
1261
|
"presets": ["onenote", "personal"],
|
|
1262
|
-
"scopes": ["Notes.Read"]
|
|
1262
|
+
"scopes": ["Notes.Read"],
|
|
1263
|
+
"extraQueryParams": {
|
|
1264
|
+
"includeIDs": {
|
|
1265
|
+
"type": "boolean",
|
|
1266
|
+
"description": "Add each element's generated id, for use as an update target."
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1263
1269
|
},
|
|
1264
1270
|
{
|
|
1265
1271
|
"pathPattern": "/me/onenote/pages/{onenotePage-id}/content",
|
|
@@ -1276,7 +1282,7 @@
|
|
|
1276
1282
|
"properties": {
|
|
1277
1283
|
"target": {
|
|
1278
1284
|
"type": "string",
|
|
1279
|
-
"description": "Element to change:
|
|
1285
|
+
"description": "Element to change: #<data-id>, a generated id (no #), or 'body' or 'title'. Most replace actions need the generated id: read the page content with includeIDs=true, and again after each update, as ids can change."
|
|
1280
1286
|
},
|
|
1281
1287
|
"action": {
|
|
1282
1288
|
"type": "string",
|
|
@@ -1343,7 +1349,13 @@
|
|
|
1343
1349
|
"method": "get",
|
|
1344
1350
|
"toolName": "get-sharepoint-site-onenote-page-content",
|
|
1345
1351
|
"presets": ["onenote", "work"],
|
|
1346
|
-
"workScopes": ["Notes.Read.All"]
|
|
1352
|
+
"workScopes": ["Notes.Read.All"],
|
|
1353
|
+
"extraQueryParams": {
|
|
1354
|
+
"includeIDs": {
|
|
1355
|
+
"type": "boolean",
|
|
1356
|
+
"description": "Add each element's generated id, for use as an update target."
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1347
1359
|
},
|
|
1348
1360
|
{
|
|
1349
1361
|
"pathPattern": "/sites/{site-id}/onenote/notebooks",
|
|
@@ -1390,7 +1402,7 @@
|
|
|
1390
1402
|
"properties": {
|
|
1391
1403
|
"target": {
|
|
1392
1404
|
"type": "string",
|
|
1393
|
-
"description": "Element to change:
|
|
1405
|
+
"description": "Element to change: #<data-id>, a generated id (no #), or 'body' or 'title'. Most replace actions need the generated id: read the page content with includeIDs=true, and again after each update, as ids can change."
|
|
1394
1406
|
},
|
|
1395
1407
|
"action": {
|
|
1396
1408
|
"type": "string",
|
package/dist/generated/client.js
CHANGED
|
@@ -3723,7 +3723,7 @@ const microsoft_graph_onenotePageCollectionResponse = z.object({
|
|
|
3723
3723
|
const update_onenote_page_content_Body = z.array(
|
|
3724
3724
|
z.object({
|
|
3725
3725
|
target: z.string().describe(
|
|
3726
|
-
"Element to change:
|
|
3726
|
+
"Element to change: #<data-id>, a generated id (no #), or 'body' or 'title'. Most replace actions need the generated id: read the page content with includeIDs=true, and again after each update, as ids can change."
|
|
3727
3727
|
),
|
|
3728
3728
|
action: z.enum(["append", "insert", "prepend", "replace", "delete"]).describe("What to do at the target. 'delete' takes no content."),
|
|
3729
3729
|
position: z.enum(["after", "before"]).describe(
|
|
@@ -11199,6 +11199,13 @@ resource.`,
|
|
|
11199
11199
|
alias: "get-onenote-page-content",
|
|
11200
11200
|
description: `The page's HTML content.`,
|
|
11201
11201
|
requestFormat: "json",
|
|
11202
|
+
parameters: [
|
|
11203
|
+
{
|
|
11204
|
+
name: "includeIDs",
|
|
11205
|
+
type: "Query",
|
|
11206
|
+
schema: z.boolean().describe("Add each element's generated id, for use as an update target.").optional()
|
|
11207
|
+
}
|
|
11208
|
+
],
|
|
11202
11209
|
response: z.void()
|
|
11203
11210
|
},
|
|
11204
11211
|
{
|
|
@@ -14371,6 +14378,13 @@ The same item might appear more than once in a delta feed, for various reasons.
|
|
|
14371
14378
|
alias: "get-sharepoint-site-onenote-page-content",
|
|
14372
14379
|
description: `The page's HTML content.`,
|
|
14373
14380
|
requestFormat: "json",
|
|
14381
|
+
parameters: [
|
|
14382
|
+
{
|
|
14383
|
+
name: "includeIDs",
|
|
14384
|
+
type: "Query",
|
|
14385
|
+
schema: z.boolean().describe("Add each element's generated id, for use as an update target.").optional()
|
|
14386
|
+
}
|
|
14387
|
+
],
|
|
14374
14388
|
response: z.void()
|
|
14375
14389
|
},
|
|
14376
14390
|
{
|
package/dist/graph-tools.js
CHANGED
|
@@ -18,6 +18,7 @@ import { api as betaApi } from "./generated/client-beta.js";
|
|
|
18
18
|
import { api } from "./generated/client.js";
|
|
19
19
|
import {
|
|
20
20
|
getBlobMaxBytes,
|
|
21
|
+
GraphApiError,
|
|
21
22
|
isBlobOutputEnabled
|
|
22
23
|
} from "./graph-client.js";
|
|
23
24
|
import { getAttachmentMinting } from "./lib/attachment-minting.js";
|
|
@@ -841,19 +842,50 @@ async function mintUploadUrl(target, name, contentType, accountParam, authManage
|
|
|
841
842
|
};
|
|
842
843
|
}
|
|
843
844
|
const MAIL_EVENT_ATTACHMENT_VALUE = /^(?:\/me|\/users\/[^/]+|\/groups\/[^/]+)\/(?:messages|events)\/[^/]+\/attachments\/[^/]+\/\$value$/;
|
|
844
|
-
|
|
845
|
-
|
|
845
|
+
const UNFETCHABLE_ATTACHMENT_STATUSES = /* @__PURE__ */ new Set([400, 403, 404]);
|
|
846
|
+
function isWrongIdCode(code) {
|
|
847
|
+
return code !== void 0 && (code.startsWith("ErrorInvalidId") || code === "ErrorItemNotFound");
|
|
848
|
+
}
|
|
849
|
+
async function probeAttachment(target, graphClient, accessToken, ticketKeepsToken) {
|
|
850
|
+
if (!MAIL_EVENT_ATTACHMENT_VALUE.test(target)) return { probe: {}, fields: {} };
|
|
846
851
|
try {
|
|
847
852
|
const meta = await graphClient.makeRequest(
|
|
848
|
-
`${target.slice(0, -"/$value".length)}?$select=name,contentType`,
|
|
853
|
+
`${target.slice(0, -"/$value".length)}?$select=name,contentType,size`,
|
|
849
854
|
{ accessToken }
|
|
850
855
|
);
|
|
851
856
|
return {
|
|
852
|
-
|
|
853
|
-
|
|
857
|
+
probe: {
|
|
858
|
+
...typeof meta?.contentType === "string" && { probedContentType: meta.contentType },
|
|
859
|
+
...typeof meta?.name === "string" && { probedName: meta.name }
|
|
860
|
+
},
|
|
861
|
+
fields: {
|
|
862
|
+
...typeof meta?.name === "string" && { name: meta.name },
|
|
863
|
+
...typeof meta?.size === "number" && { size: meta.size },
|
|
864
|
+
...typeof meta?.contentType === "string" && { contentType: meta.contentType }
|
|
865
|
+
}
|
|
854
866
|
};
|
|
855
|
-
} catch {
|
|
856
|
-
|
|
867
|
+
} catch (error) {
|
|
868
|
+
if (error instanceof GraphApiError && (UNFETCHABLE_ATTACHMENT_STATUSES.has(error.httpStatus) || error.httpStatus === 401 && ticketKeepsToken)) {
|
|
869
|
+
const idHint = isWrongIdCode(error.graphErrorCode) ? ' Check the ids in the target: copy them exactly as Graph returned them, including any trailing "=".' : "";
|
|
870
|
+
return {
|
|
871
|
+
refusal: {
|
|
872
|
+
content: [
|
|
873
|
+
{
|
|
874
|
+
type: "text",
|
|
875
|
+
text: JSON.stringify({
|
|
876
|
+
error: `No download URL was made: ${error.message}${idHint}`
|
|
877
|
+
})
|
|
878
|
+
}
|
|
879
|
+
],
|
|
880
|
+
isError: true,
|
|
881
|
+
_meta: {
|
|
882
|
+
http_status: error.httpStatus,
|
|
883
|
+
...error.graphErrorCode ? { error_code: error.graphErrorCode } : {}
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
};
|
|
887
|
+
}
|
|
888
|
+
return { probe: {}, fields: {} };
|
|
857
889
|
}
|
|
858
890
|
}
|
|
859
891
|
async function mintDownloadUrl(target, accountParam, authManager, probeWith, known) {
|
|
@@ -894,11 +926,28 @@ async function mintDownloadUrl(target, accountParam, authManager, probeWith, kno
|
|
|
894
926
|
isError: true
|
|
895
927
|
};
|
|
896
928
|
}
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
929
|
+
let accountToken;
|
|
930
|
+
if (!requestToken && authManager) {
|
|
931
|
+
try {
|
|
932
|
+
accountToken = await authManager.getTokenForAccount(accountParam);
|
|
933
|
+
} catch (error) {
|
|
934
|
+
return {
|
|
935
|
+
content: [
|
|
936
|
+
{
|
|
937
|
+
type: "text",
|
|
938
|
+
text: JSON.stringify({
|
|
939
|
+
error: `No download URL was made: ${error.message}`
|
|
940
|
+
})
|
|
941
|
+
}
|
|
942
|
+
],
|
|
943
|
+
isError: true
|
|
944
|
+
};
|
|
945
|
+
}
|
|
946
|
+
}
|
|
947
|
+
const probeToken = requestToken ?? accountToken;
|
|
948
|
+
const probed = known ? known : probeWith && probeToken ? await probeAttachment(target, probeWith, probeToken, Boolean(requestToken)) : void 0;
|
|
949
|
+
if (probed && "refusal" in probed) return probed.refusal;
|
|
950
|
+
const probe = probed?.probe ?? {};
|
|
902
951
|
let ticket;
|
|
903
952
|
try {
|
|
904
953
|
ticket = requestToken ? minting.store.mintWithToken(target, requestToken, void 0, probe) : minting.store.mint(target, accountParam, void 0, probe);
|
|
@@ -917,7 +966,7 @@ async function mintDownloadUrl(target, accountParam, authManager, probeWith, kno
|
|
|
917
966
|
type: "text",
|
|
918
967
|
text: JSON.stringify({
|
|
919
968
|
downloadUrl: buildAttachmentUrl(minting.config, ticket.id),
|
|
920
|
-
...
|
|
969
|
+
...probed?.fields,
|
|
921
970
|
expiresAt: new Date(ticket.expiresAtMs).toISOString(),
|
|
922
971
|
singleUse: true,
|
|
923
972
|
note: "Served by this server, not by Microsoft Graph. Valid for one fetch until it expires."
|
|
@@ -2318,7 +2367,8 @@ async function executeGraphTool(tool, config, graphClient, params, authManager,
|
|
|
2318
2367
|
options.body = typeof body === "string" ? body : JSON.stringify(body);
|
|
2319
2368
|
}
|
|
2320
2369
|
}
|
|
2321
|
-
const isProbablyMediaContent = tool.errors?.some((error) => error.description === "Retrieved media content") ||
|
|
2370
|
+
const isProbablyMediaContent = tool.errors?.some((error) => error.description === "Retrieved media content") || // path already carries the query string, e.g. ?includeIDs=true on OneNote page content
|
|
2371
|
+
path2.split("?")[0].endsWith("/content");
|
|
2322
2372
|
if (config?.returnDownloadUrl && path2.endsWith("/content")) {
|
|
2323
2373
|
path2 = path2.replace(/\/content$/, "");
|
|
2324
2374
|
logger.info(
|
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.
|
|
4
|
+
"version": "0.184.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",
|
package/src/endpoints.json
CHANGED
|
@@ -1259,7 +1259,13 @@
|
|
|
1259
1259
|
"method": "get",
|
|
1260
1260
|
"toolName": "get-onenote-page-content",
|
|
1261
1261
|
"presets": ["onenote", "personal"],
|
|
1262
|
-
"scopes": ["Notes.Read"]
|
|
1262
|
+
"scopes": ["Notes.Read"],
|
|
1263
|
+
"extraQueryParams": {
|
|
1264
|
+
"includeIDs": {
|
|
1265
|
+
"type": "boolean",
|
|
1266
|
+
"description": "Add each element's generated id, for use as an update target."
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1263
1269
|
},
|
|
1264
1270
|
{
|
|
1265
1271
|
"pathPattern": "/me/onenote/pages/{onenotePage-id}/content",
|
|
@@ -1276,7 +1282,7 @@
|
|
|
1276
1282
|
"properties": {
|
|
1277
1283
|
"target": {
|
|
1278
1284
|
"type": "string",
|
|
1279
|
-
"description": "Element to change:
|
|
1285
|
+
"description": "Element to change: #<data-id>, a generated id (no #), or 'body' or 'title'. Most replace actions need the generated id: read the page content with includeIDs=true, and again after each update, as ids can change."
|
|
1280
1286
|
},
|
|
1281
1287
|
"action": {
|
|
1282
1288
|
"type": "string",
|
|
@@ -1343,7 +1349,13 @@
|
|
|
1343
1349
|
"method": "get",
|
|
1344
1350
|
"toolName": "get-sharepoint-site-onenote-page-content",
|
|
1345
1351
|
"presets": ["onenote", "work"],
|
|
1346
|
-
"workScopes": ["Notes.Read.All"]
|
|
1352
|
+
"workScopes": ["Notes.Read.All"],
|
|
1353
|
+
"extraQueryParams": {
|
|
1354
|
+
"includeIDs": {
|
|
1355
|
+
"type": "boolean",
|
|
1356
|
+
"description": "Add each element's generated id, for use as an update target."
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1347
1359
|
},
|
|
1348
1360
|
{
|
|
1349
1361
|
"pathPattern": "/sites/{site-id}/onenote/notebooks",
|
|
@@ -1390,7 +1402,7 @@
|
|
|
1390
1402
|
"properties": {
|
|
1391
1403
|
"target": {
|
|
1392
1404
|
"type": "string",
|
|
1393
|
-
"description": "Element to change:
|
|
1405
|
+
"description": "Element to change: #<data-id>, a generated id (no #), or 'body' or 'title'. Most replace actions need the generated id: read the page content with includeIDs=true, and again after each update, as ids can change."
|
|
1394
1406
|
},
|
|
1395
1407
|
"action": {
|
|
1396
1408
|
"type": "string",
|