{"record":{"id":"bcfb06c6a11cb980","repo":"different-ai/openwork","slug":"app-too-large","errorCode":"app_too_large","errorMessage":"Remote MCP Apps must be ${REMOTE_MCP_APP_MAX_BYTES / 1024} KiB or smaller.","messagePattern":"Remote MCP Apps must be (.+?) KiB or smaller\\.","errorType":"http","errorClass":"RemoteMcpAppError","httpStatus":413,"severity":"error","filePath":"ee/apps/den-api/src/remote-mcp-apps.ts","lineNumber":245,"sourceCode":"  const mimeType = rawMimeType?.trim().toLowerCase()\n  if (mimeType !== \"text/html\" && mimeType !== \"application/xhtml+xml\") {\n    throw new RemoteMcpAppError(422, \"invalid_content_type\", \"Remote MCP Apps must be served as text/html or application/xhtml+xml.\")\n  }\n  for (const parameter of parameters) {\n    const match = parameter.trim().match(/^charset\\s*=\\s*(?:\"([^\"]+)\"|'([^']+)'|([^\\s]+))$/i)\n    const charset = (match?.[1] ?? match?.[2] ?? match?.[3])?.toLowerCase()\n    if (charset && charset !== \"utf-8\" && charset !== \"utf8\") {\n      throw new RemoteMcpAppError(422, \"invalid_encoding\", \"Remote MCP Apps must be UTF-8 HTML.\")\n    }\n  }\n  return mimeType\n}\n\nasync function boundedResponseText(response: Response) {\n  const declaredLength = Number(response.headers.get(\"content-length\"))\n  if (Number.isFinite(declaredLength) && declaredLength > REMOTE_MCP_APP_MAX_BYTES) {\n    await response.body?.cancel()\n    throw new RemoteMcpAppError(413, \"app_too_large\", `Remote MCP Apps must be ${REMOTE_MCP_APP_MAX_BYTES / 1024} KiB or smaller.`)\n  }\n  if (!response.body) return \"\"\n  const reader = response.body.getReader()\n  const chunks: Uint8Array[] = []\n  let total = 0\n  try {\n    while (true) {\n      const { done, value } = await reader.read()\n      if (done) break\n      total += value.byteLength\n      if (total > REMOTE_MCP_APP_MAX_BYTES) {\n        await reader.cancel()\n        throw new RemoteMcpAppError(413, \"app_too_large\", `Remote MCP Apps must be ${REMOTE_MCP_APP_MAX_BYTES / 1024} KiB or smaller.`)\n      }\n      chunks.push(value)\n    }\n  } finally {\n    reader.releaseLock()","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/different-ai/openwork/blob/2b7df46e8ae1517d64c896c7793d2d52ec845669/ee/apps/den-api/src/remote-mcp-apps.ts#L227-L263","documentation":"This error is thrown by boundedResponseText in ee/apps/den-api/src/remote-mcp-apps.ts when downloading a Remote MCP App whose HTML exceeds REMOTE_MCP_APP_MAX_BYTES. The library checks the declared content-length header before streaming; if it is present, finite, and larger than the cap, it cancels the body and throws a 413 app_too_large error to avoid buffering oversized payloads.","triggerScenarios":"Calling fetchRemoteMcpApp (via the html caller) with a sourceUrl whose response declares a content-length header greater than REMOTE_MCP_APP_MAX_BYTES. Any download of a remote MCP app HTML document larger than the configured KiB limit.","commonSituations":"Publishing a very large single-file HTML app (inlined JS/CSS/assets) to a static host and registering it as a Remote MCP App source URL; a host that inflates content-length; limit lowered in config while existing apps still exceed it.","solutions":["Reduce the app HTML size below REMOTE_MCP_APP_MAX_BYTES (minify, remove inlined assets, split resources).","Host large assets externally and reference them by URL instead of inlining.","Verify the content-length header is accurate; fix misconfigured proxies/CDNs that inflate it.","If the limit must change, adjust REMOTE_MCP_APP_MAX_BYTES and redeploy the den-api service."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const head = await fetch(sourceUrl, { method: \"HEAD\" });\nconst len = Number(head.headers.get(\"content-length\"));\nconst MAX = REMOTE_MCP_APP_MAX_BYTES;\nif (Number.isFinite(len) && len > MAX) throw new Error(`App HTML is ${len} bytes; limit is ${MAX}.`);","typeGuard":null,"tryCatchPattern":"try {\n  await importRemoteMcpApp({ sourceUrl, ... });\n} catch (e) {\n  if (e instanceof RemoteMcpAppError && e.code === \"app_too_large\") {\n    // shrink the HTML bundle or externalize assets, then retry\n  } else throw e;\n}","preventionTips":["Keep single-file HTML apps well under the size limit; minify JS/CSS.","Externalize large assets (images, fonts, libraries) to URLs.","Set correct content-length headers on the host so failures surface early.","CI-check the built app HTML size before registering it as a Remote MCP App."],"tags":["http","size-limit","remote-mcp-app"],"backgroundTag":"payload-too-large","analyzedSha":"2b7df46e8ae1517d64c896c7793d2d52ec845669","analyzedAt":"2026-09-01T07:59:23.713Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}