{"record":{"id":"8a5296975e60712d","repo":"CherryHQ/cherry-studio","slug":"invalid-mcp-package-upload-file-exceeds-the-100-m","errorCode":null,"errorMessage":"Invalid MCP package upload: file exceeds the 100 MiB size limit","messagePattern":"Invalid MCP package upload: file exceeds the 100 MiB size limit","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ai/mcp/McpPackageService.ts","lineNumber":316,"sourceCode":"  }\n  if (path.extname(trimmedFileName).toLowerCase() !== `.${packageFormat}`) {\n    throw new Error(`Invalid MCP package upload: expected a .${packageFormat} file`)\n  }\n\n  let buffer: Buffer\n  if (fileBuffer instanceof ArrayBuffer) {\n    buffer = Buffer.from(fileBuffer)\n  } else if (ArrayBuffer.isView(fileBuffer)) {\n    buffer = Buffer.from(fileBuffer.buffer, fileBuffer.byteOffset, fileBuffer.byteLength)\n  } else {\n    throw new Error('Invalid MCP package upload: file buffer must be an ArrayBuffer')\n  }\n\n  if (buffer.byteLength === 0) {\n    throw new Error('Invalid MCP package upload: file buffer cannot be empty')\n  }\n  if (buffer.byteLength > MCP_PACKAGE_UPLOAD_MAX_BYTES) {\n    throw new Error('Invalid MCP package upload: file exceeds the 100 MiB size limit')\n  }\n\n  return buffer\n}\n\nexport function applyPlatformOverrides(mcpConfig: any, extractDir: string, userConfig?: Record<string, any>): any {\n  const platform = process.platform\n  // Deep-copy the nested env so substitution never mutates the caller's manifest object.\n  const resolvedConfig = { ...mcpConfig, env: mcpConfig.env ? { ...mcpConfig.env } : mcpConfig.env }\n\n  // Apply platform-specific overrides\n  if (mcpConfig.platform_overrides && mcpConfig.platform_overrides[platform]) {\n    const override = mcpConfig.platform_overrides[platform]\n\n    // Override command if specified\n    if (override.command) {\n      resolvedConfig.command = override.command\n    }","sourceCodeStart":298,"sourceCodeEnd":334,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/mcp/McpPackageService.ts#L298-L334","documentation":"Thrown by validatePackageUploadPayload when the buffer exceeds MCP_PACKAGE_UPLOAD_MAX_BYTES (100 * 1024 * 1024 = 104857600 bytes, ~100 MiB). The cap protects the main process from memory exhaustion: the buffer is received whole over IPC and converted to a Node Buffer, so an oversized upload holds the full payload in memory. The limit is a hard constant, not configurable.","triggerScenarios":"Renderer sent an ArrayBuffer larger than 100 MiB. The IPC layer may itself impose additional limits, but if the payload reaches validatePackageUploadPayload and exceeds 104857600 bytes, this guard fires.","commonSituations":"User selected a very large package (e.g. one bundling a runtime or large model weights); a developer packaged far more than intended into the .dxt/.mcpb; a build step included node_modules or other bulky artifacts.","solutions":["Reduce the package size below 100 MiB: exclude unnecessary node_modules (use a production install), strip source maps, remove large assets.","If the package legitimately needs more, split it into multiple packages or fetch large assets at runtime rather than bundling them.","Surface the limit in the renderer UI (check file.size before upload) so the user gets immediate feedback rather than waiting for the IPC round-trip."],"exampleFix":"// renderer - before\nconst buf = await file.arrayBuffer()\nawait upload(buf, file.name)\n// after\nconst MAX = 100 * 1024 * 1024\nif (file.size > MAX) { setError(`File exceeds ${MAX} bytes`); return }\nawait upload(await file.arrayBuffer(), file.name)","handlingStrategy":"validation","validationCode":"const MCP_PACKAGE_UPLOAD_MAX_BYTES = 100 * 1024 * 1024\nfunction isWithinUploadLimit(byteLength: number): boolean {\n  return byteLength > 0 && byteLength <= MCP_PACKAGE_UPLOAD_MAX_BYTES\n}","typeGuard":"function fitsUploadLimit(byteLength: number): boolean {\n  return byteLength <= 100 * 1024 * 1024\n}","tryCatchPattern":null,"preventionTips":["Surface the 100 MiB limit in the renderer and check file.size before upload so the user gets immediate feedback.","When authoring packages, run a production install (omit devDependencies) and strip large assets to stay well under the cap.","Fetch large model weights or assets at runtime rather than bundling them in the package."],"tags":["mcp","upload","validation","ipc","size-limit"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}