@danainnovations/cortex-mcp 1.0.39 → 1.0.41

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/cli.js CHANGED
@@ -41,7 +41,7 @@ var AVAILABLE_MCPS = [
41
41
  {
42
42
  name: "m365",
43
43
  displayName: "Microsoft 365",
44
- description: "Email, calendar, OneDrive, Teams, meetings, contacts, tasks, notes (32 tools)",
44
+ description: "Email, calendar, OneDrive, Teams, meetings, contacts, tasks, notes (33 tools)",
45
45
  serverName: "cortex-m365",
46
46
  authMode: "personal"
47
47
  },
@@ -1020,7 +1020,8 @@ var CortexHttpClient = class {
1020
1020
  const headers = {
1021
1021
  "Content-Type": "application/json",
1022
1022
  "x-api-key": this.apiKey,
1023
- "mcp-protocol-version": PROTOCOL_VERSION
1023
+ "mcp-protocol-version": PROTOCOL_VERSION,
1024
+ "x-cortex-client": "cortex-mcp-stdio"
1024
1025
  };
1025
1026
  if (this.sessionId) {
1026
1027
  headers["mcp-session-id"] = this.sessionId;
@@ -1030,7 +1031,7 @@ var CortexHttpClient = class {
1030
1031
  method: "POST",
1031
1032
  headers,
1032
1033
  body: JSON.stringify(body),
1033
- signal: AbortSignal.timeout(3e4)
1034
+ signal: AbortSignal.timeout(6e4)
1034
1035
  });
1035
1036
  const newSessionId = response.headers.get("mcp-session-id");
1036
1037
  if (newSessionId) {
@@ -1055,7 +1056,8 @@ var CortexHttpClient = class {
1055
1056
  const headers = {
1056
1057
  "Content-Type": "application/json",
1057
1058
  "x-api-key": this.apiKey,
1058
- "mcp-protocol-version": PROTOCOL_VERSION
1059
+ "mcp-protocol-version": PROTOCOL_VERSION,
1060
+ "x-cortex-client": "cortex-mcp-stdio"
1059
1061
  };
1060
1062
  if (this.sessionId) {
1061
1063
  headers["mcp-session-id"] = this.sessionId;
@@ -1090,7 +1092,7 @@ var CortexHttpClient = class {
1090
1092
 
1091
1093
  // src/proxy/stdio-server.ts
1092
1094
  var UPLOAD_TOOLS = /* @__PURE__ */ new Set(["upload_file", "upload_file_to_sharepoint"]);
1093
- var INLINE_UPLOAD_MAX = 3.5 * 1024 * 1024;
1095
+ var INLINE_UPLOAD_MAX = 3 * 1024 * 1024;
1094
1096
  function overrideUploadToolSchema(tool) {
1095
1097
  const name = tool.name;
1096
1098
  const baseName = name.includes("__") ? name.split("__").pop() : name;
@@ -1216,48 +1218,57 @@ async function handleLocalFileUpload(cortex, toolName, args) {
1216
1218
  };
1217
1219
  }
1218
1220
  const fileBuffer = readFileSync4(filePath);
1219
- const chunkSize = 10 * 1024 * 1024;
1221
+ const chunkSize = 2.5 * 1024 * 1024;
1220
1222
  const total = fileBuffer.length;
1221
- let lastResponse = null;
1223
+ let driveItem = {};
1222
1224
  for (let start = 0; start < total; start += chunkSize) {
1223
1225
  const end = Math.min(start + chunkSize, total);
1224
1226
  const chunk = fileBuffer.subarray(start, end);
1227
+ const chunkBase64 = Buffer.from(chunk).toString("base64");
1225
1228
  console.error(
1226
- `[cortex-mcp] Uploading chunk ${start}-${end - 1}/${total}`
1229
+ `[cortex-mcp] Uploading chunk ${start}-${end - 1}/${total} via backend relay`
1227
1230
  );
1228
- lastResponse = await fetch(uploadUrl, {
1229
- method: "PUT",
1230
- headers: {
1231
- "Content-Length": String(chunk.length),
1232
- "Content-Range": `bytes ${start}-${end - 1}/${total}`
1233
- },
1234
- body: chunk,
1235
- signal: AbortSignal.timeout(12e4)
1236
- // 2 min per chunk
1231
+ const chunkResponse = await cortex.callTool(`${prefix}upload_file_chunk`, {
1232
+ upload_url: uploadUrl,
1233
+ chunk: chunkBase64,
1234
+ range_start: start,
1235
+ range_end: end - 1,
1236
+ total_size: total
1237
1237
  });
1238
- if (!lastResponse.ok && lastResponse.status !== 202) {
1239
- const errText = await lastResponse.text();
1238
+ if (chunkResponse.error) {
1239
+ return {
1240
+ content: [{ type: "text", text: chunkResponse.error.message }],
1241
+ isError: true
1242
+ };
1243
+ }
1244
+ const chunkResult = chunkResponse.result;
1245
+ let chunkData;
1246
+ try {
1247
+ chunkData = JSON.parse(chunkResult.content[0].text);
1248
+ } catch {
1240
1249
  return {
1241
1250
  content: [{ type: "text", text: JSON.stringify({
1242
1251
  success: false,
1243
- error: `Upload chunk failed (${lastResponse.status}): ${errText.slice(0, 200)}`
1252
+ error: "Failed to parse chunk upload response from backend"
1244
1253
  }) }],
1245
1254
  isError: true
1246
1255
  };
1247
1256
  }
1248
- }
1249
- let driveItem = {};
1250
- if (lastResponse) {
1251
- try {
1252
- driveItem = await lastResponse.json();
1253
- } catch {
1257
+ if (!chunkData.success) {
1258
+ return {
1259
+ content: [{ type: "text", text: JSON.stringify(chunkData) }],
1260
+ isError: true
1261
+ };
1262
+ }
1263
+ if (chunkData.status === 200 || chunkData.status === 201) {
1264
+ driveItem = chunkData.data ?? {};
1254
1265
  }
1255
1266
  }
1256
1267
  return {
1257
1268
  content: [{ type: "text", text: JSON.stringify({
1258
1269
  success: true,
1259
1270
  file: driveItem,
1260
- message: `Uploaded '${args.path}' (${(fileSize / 1024).toFixed(1)}KB) via upload session`
1271
+ message: `Uploaded '${args.path}' (${(fileSize / 1024 / 1024).toFixed(1)}MB) via upload session`
1261
1272
  }) }],
1262
1273
  isError: false
1263
1274
  };
@@ -1319,8 +1330,13 @@ async function startStdioServer(options) {
1319
1330
  // src/cli/serve.ts
1320
1331
  async function runServe() {
1321
1332
  const config = readConfig();
1322
- let serverUrl = config?.server || DEFAULT_SERVER_URL;
1323
- let apiKey = getEffectiveApiKey();
1333
+ const serverUrl = config?.server || DEFAULT_SERVER_URL;
1334
+ const apiKey = getEffectiveApiKey();
1335
+ if (apiKey === DEFAULT_API_KEY) {
1336
+ process.stderr.write(
1337
+ "Warning: Using shared API key. Personal MCPs (M365, Slack, etc.) will not have access to your account.\nRun: npx @danainnovations/cortex-mcp@latest login\n\n"
1338
+ );
1339
+ }
1324
1340
  await startStdioServer({ serverUrl, apiKey });
1325
1341
  }
1326
1342