@softeria/ms-365-mcp-server 0.19.2 → 0.20.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/dist/graph-client.js +55 -5
- package/dist/graph-tools.js +7 -0
- package/package.json +1 -1
package/dist/graph-client.js
CHANGED
|
@@ -43,14 +43,26 @@ class GraphClient {
|
|
|
43
43
|
);
|
|
44
44
|
}
|
|
45
45
|
const text = await response.text();
|
|
46
|
+
let result;
|
|
46
47
|
if (text === "") {
|
|
47
|
-
|
|
48
|
+
result = { message: "OK!" };
|
|
49
|
+
} else {
|
|
50
|
+
try {
|
|
51
|
+
result = JSON.parse(text);
|
|
52
|
+
} catch {
|
|
53
|
+
result = { message: "OK!", rawResponse: text };
|
|
54
|
+
}
|
|
48
55
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
56
|
+
if (options.includeHeaders) {
|
|
57
|
+
const etag = response.headers.get("ETag") || response.headers.get("etag");
|
|
58
|
+
if (result && typeof result === "object" && !Array.isArray(result)) {
|
|
59
|
+
return {
|
|
60
|
+
...result,
|
|
61
|
+
_etag: etag || "no-etag-found"
|
|
62
|
+
};
|
|
63
|
+
}
|
|
53
64
|
}
|
|
65
|
+
return result;
|
|
54
66
|
} catch (error) {
|
|
55
67
|
logger.error("Microsoft Graph API request failed:", error);
|
|
56
68
|
throw error;
|
|
@@ -96,6 +108,44 @@ class GraphClient {
|
|
|
96
108
|
}
|
|
97
109
|
}
|
|
98
110
|
formatJsonResponse(data, rawResponse = false) {
|
|
111
|
+
if (data && typeof data === "object" && "_headers" in data) {
|
|
112
|
+
const responseData = data;
|
|
113
|
+
const meta = {};
|
|
114
|
+
if (responseData._etag) {
|
|
115
|
+
meta.etag = responseData._etag;
|
|
116
|
+
}
|
|
117
|
+
if (responseData._headers) {
|
|
118
|
+
meta.headers = responseData._headers;
|
|
119
|
+
}
|
|
120
|
+
if (rawResponse) {
|
|
121
|
+
return {
|
|
122
|
+
content: [{ type: "text", text: JSON.stringify(responseData.data) }],
|
|
123
|
+
_meta: meta
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
if (responseData.data === null || responseData.data === void 0) {
|
|
127
|
+
return {
|
|
128
|
+
content: [{ type: "text", text: JSON.stringify({ success: true }) }],
|
|
129
|
+
_meta: meta
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
const removeODataProps2 = (obj) => {
|
|
133
|
+
if (typeof obj === "object" && obj !== null) {
|
|
134
|
+
Object.keys(obj).forEach((key) => {
|
|
135
|
+
if (key.startsWith("@odata.")) {
|
|
136
|
+
delete obj[key];
|
|
137
|
+
} else if (typeof obj[key] === "object") {
|
|
138
|
+
removeODataProps2(obj[key]);
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
removeODataProps2(responseData.data);
|
|
144
|
+
return {
|
|
145
|
+
content: [{ type: "text", text: JSON.stringify(responseData.data, null, 2) }],
|
|
146
|
+
_meta: meta
|
|
147
|
+
};
|
|
148
|
+
}
|
|
99
149
|
if (rawResponse) {
|
|
100
150
|
return {
|
|
101
151
|
content: [{ type: "text", text: JSON.stringify(data) }]
|
package/dist/graph-tools.js
CHANGED
|
@@ -42,6 +42,7 @@ function registerGraphTools(server, graphClient, readOnly = false, enabledToolsP
|
|
|
42
42
|
if (tool.method.toUpperCase() === "GET" && tool.path.includes("/")) {
|
|
43
43
|
paramSchema["fetchAllPages"] = z.boolean().describe("Automatically fetch all pages of results").optional();
|
|
44
44
|
}
|
|
45
|
+
paramSchema["includeHeaders"] = z.boolean().describe("Include response headers (including ETag) in the response metadata").optional();
|
|
45
46
|
server.tool(
|
|
46
47
|
tool.alias,
|
|
47
48
|
tool.description || `Execute ${tool.method.toUpperCase()} request to ${tool.path}`,
|
|
@@ -63,6 +64,9 @@ function registerGraphTools(server, graphClient, readOnly = false, enabledToolsP
|
|
|
63
64
|
if (paramName === "fetchAllPages") {
|
|
64
65
|
continue;
|
|
65
66
|
}
|
|
67
|
+
if (paramName === "includeHeaders") {
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
66
70
|
const odataParams = [
|
|
67
71
|
"filter",
|
|
68
72
|
"select",
|
|
@@ -111,6 +115,9 @@ function registerGraphTools(server, graphClient, readOnly = false, enabledToolsP
|
|
|
111
115
|
if (isProbablyMediaContent) {
|
|
112
116
|
options.rawResponse = true;
|
|
113
117
|
}
|
|
118
|
+
if (params.includeHeaders === true) {
|
|
119
|
+
options.includeHeaders = true;
|
|
120
|
+
}
|
|
114
121
|
logger.info(`Making graph request to ${path2} with options: ${JSON.stringify(options)}`);
|
|
115
122
|
let response = await graphClient.graphRequest(path2, options);
|
|
116
123
|
const fetchAllPages = params.fetchAllPages === true;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softeria/ms-365-mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.20.0",
|
|
4
4
|
"description": " A Model Context Protocol (MCP) server for interacting with Microsoft 365 and Office services through the Graph API",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|