{"record":{"id":"35ae344c307a2d6e","repo":"CherryHQ/cherry-studio","slug":"invalid-manifest-server-mcp-config-args-must-be-a","errorCode":null,"errorMessage":"Invalid manifest: server.mcp_config.args must be an array","messagePattern":"Invalid manifest: server\\.mcp_config\\.args must be an array","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/main/ai/mcp/McpPackageService.ts","lineNumber":565,"sourceCode":"        manifest = { ...parsedManifest, dxt_version: parsedManifest.dxt_version }\n      }\n      if (!manifest.name) {\n        throw new Error('Invalid manifest: missing name')\n      }\n      if (!manifest.version) {\n        throw new Error('Invalid manifest: missing version')\n      }\n      if (!manifest.server) {\n        throw new Error('Invalid manifest: missing server configuration')\n      }\n      if (!manifest.server.mcp_config) {\n        throw new Error('Invalid manifest: missing server.mcp_config')\n      }\n      if (!manifest.server.mcp_config.command) {\n        throw new Error('Invalid manifest: missing server.mcp_config.command')\n      }\n      if (!Array.isArray(manifest.server.mcp_config.args)) {\n        throw new Error('Invalid manifest: server.mcp_config.args must be an array')\n      }\n\n      // Use server name as the final extract directory for automatic version management\n      const serverDirName = `server-${manifest.name}`\n      const finalExtractDir = ensurePathWithin(this.mcpDir, path.join(this.mcpDir, serverDirName))\n\n      // Stage the new package first, then swap directories so a failed install\n      // does not destroy the last working version.\n      await this.replacePackageDirectory(tempExtractDir, finalExtractDir, serverDirName)\n      logger.debug(`${packageLabel} server extracted to: ${finalExtractDir}`)\n\n      // Clean up the uploaded package file if it's in temp directory\n      if (filePath.startsWith(this.tempDir)) {\n        fs.unlinkSync(filePath)\n      }\n\n      // Return success with manifest and extraction path\n      return {","sourceCodeStart":547,"sourceCodeEnd":583,"githubUrl":"https://github.com/CherryHQ/cherry-studio/blob/726446b54cd69ffe51a276638672f6d95ca0768c/src/main/ai/mcp/McpPackageService.ts#L547-L583","documentation":"Thrown during MCP package installation when `server.mcp_config.args` exists but is not an array. The runtime expects args to be an array of strings passed to the command. Since the check is `!Array.isArray(...)`, a missing args field (undefined) also triggers this — args is required, not optional.","triggerScenarios":"The manifest.json contains `server.mcp_config.command` but `args` is a string (e.g. \"-y foo\"), an object, null, or omitted entirely. The validator runs `Array.isArray(manifest.server.mcp_config.args)` which returns false for all non-array values.","commonSituations":"Author writes args as a single space-delimited string instead of an array; args key is accidentally omitted; args is set to null; a JSON serialization bug converts the array to an object with numeric keys.","solutions":["Ensure manifest.json has `server.mcp_config.args` as a JSON array of strings","If args was omitted, add an empty array: \"args\": []","Convert any space-delimited string to an array: \"-y foo\" → [\"-y\", \"foo\"]","Re-package and retry the installation"],"exampleFix":"// before (manifest.json)\n{\n  \"server\": {\n    \"mcp_config\": {\n      \"command\": \"npx\",\n      \"args\": \"-y @my/mcp-server\"\n    }\n  }\n}\n\n// after\n{\n  \"server\": {\n    \"mcp_config\": {\n      \"command\": \"npx\",\n      \"args\": [\"-y\", \"@my/mcp-server\"]\n    }\n  }\n}","handlingStrategy":"validation","validationCode":"function validateManifestArgs(manifest: unknown): asserts manifest is McpPackageManifest {\n  const args = (manifest as any)?.server?.mcp_config?.args\n  if (!Array.isArray(args) || !args.every(a => typeof a === 'string')) {\n    throw new Error('Manifest server.mcp_config.args must be a string array')\n  }\n}","typeGuard":"function hasValidArgs(manifest: unknown): manifest is McpPackageManifest {\n  const args = (manifest as any)?.server?.mcp_config?.args\n  return Array.isArray(args) && args.every(a => typeof a === 'string')\n}","tryCatchPattern":"try {\n  await mcpPackageService.processUploadedPackage(filePath)\n} catch (e) {\n  if (e instanceof Error && e.message.includes('args must be an array')) {\n    // Prompt user to fix args in manifest\n  }\n  throw e\n}","preventionTips":["Validate manifest structure with a schema before packaging","If args can be empty, always set \"args\": [] explicitly","Use a linter or pre-submit validator for MCP package manifests"],"tags":["mcp","manifest-validation","package-install","configuration"],"backgroundTag":null,"analyzedSha":"726446b54cd69ffe51a276638672f6d95ca0768c","analyzedAt":"2026-08-12T17:30:37.448Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}