different-ai/openwork · error · RemoteMcpAppError
app_too_large
app_too_large
Error message
Remote MCP Apps must be ${REMOTE_MCP_APP_MAX_BYTES / 1024} KiB or smaller. What it means
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.
Source
Thrown at ee/apps/den-api/src/remote-mcp-apps.ts:245
const mimeType = rawMimeType?.trim().toLowerCase()
if (mimeType !== "text/html" && mimeType !== "application/xhtml+xml") {
throw new RemoteMcpAppError(422, "invalid_content_type", "Remote MCP Apps must be served as text/html or application/xhtml+xml.")
}
for (const parameter of parameters) {
const match = parameter.trim().match(/^charset\s*=\s*(?:"([^"]+)"|'([^']+)'|([^\s]+))$/i)
const charset = (match?.[1] ?? match?.[2] ?? match?.[3])?.toLowerCase()
if (charset && charset !== "utf-8" && charset !== "utf8") {
throw new RemoteMcpAppError(422, "invalid_encoding", "Remote MCP Apps must be UTF-8 HTML.")
}
}
return mimeType
}
async function boundedResponseText(response: Response) {
const declaredLength = Number(response.headers.get("content-length"))
if (Number.isFinite(declaredLength) && declaredLength > REMOTE_MCP_APP_MAX_BYTES) {
await response.body?.cancel()
throw new RemoteMcpAppError(413, "app_too_large", `Remote MCP Apps must be ${REMOTE_MCP_APP_MAX_BYTES / 1024} KiB or smaller.`)
}
if (!response.body) return ""
const reader = response.body.getReader()
const chunks: Uint8Array[] = []
let total = 0
try {
while (true) {
const { done, value } = await reader.read()
if (done) break
total += value.byteLength
if (total > REMOTE_MCP_APP_MAX_BYTES) {
await reader.cancel()
throw new RemoteMcpAppError(413, "app_too_large", `Remote MCP Apps must be ${REMOTE_MCP_APP_MAX_BYTES / 1024} KiB or smaller.`)
}
chunks.push(value)
}
} finally {
reader.releaseLock()View on GitHub (pinned to 2b7df46e8a)
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.
Defensive patterns
Strategy: validation
Validate before calling
const head = await fetch(sourceUrl, { method: "HEAD" });
const len = Number(head.headers.get("content-length"));
const MAX = REMOTE_MCP_APP_MAX_BYTES;
if (Number.isFinite(len) && len > MAX) throw new Error(`App HTML is ${len} bytes; limit is ${MAX}.`); Try / catch
try {
await importRemoteMcpApp({ sourceUrl, ... });
} catch (e) {
if (e instanceof RemoteMcpAppError && e.code === "app_too_large") {
// shrink the HTML bundle or externalize assets, then retry
} else throw e;
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- request_failed
- Failed to fetch latest-mac.yml (${response.status} ${respons
- response_too_large
- plugin_ref_not_found
- invalid_payload
AI-assisted analysis of different-ai/openwork@2b7df46e8a (2026-09-01).
Data as JSON: /api/errors/bcfb06c6a11cb980.
Report an issue: GitHub.