{"record":{"id":"24d614f76137433e","repo":"vercel/ai","slug":"unsupported-mcp-app-resource-content-format-uri","errorCode":null,"errorMessage":"Unsupported MCP App resource content format: ${uri}","messagePattern":"Unsupported MCP App resource content format: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/mcp/src/tool/mcp-apps.ts","lineNumber":257,"sourceCode":"  if (content == null) {\n    throw new Error(`MCP App resource not found in read result: ${uri}`);\n  }\n\n  if (content.mimeType !== MCP_APP_MIME_TYPE) {\n    throw new Error(\n      `Unsupported MCP App resource MIME type: ${content.mimeType}`,\n    );\n  }\n\n  const html =\n    'text' in content && typeof content.text === 'string'\n      ? content.text\n      : 'blob' in content && typeof content.blob === 'string'\n        ? new TextDecoder().decode(convertBase64ToUint8Array(content.blob))\n        : undefined;\n\n  if (html == null) {\n    throw new Error(`Unsupported MCP App resource content format: ${uri}`);\n  }\n\n  const meta = getResourceUiMeta(content._meta);\n\n  return { uri, mimeType: MCP_APP_MIME_TYPE, html, meta };\n}\n\n/**\n * Reads a `ui://` resource from an MCP server and normalizes it for rendering.\n */\nexport async function readMCPAppResource({\n  client,\n  uri,\n  options,\n}: {\n  client: Pick<MCPClient, 'readResource'>;\n  uri: string;\n  options?: RequestOptions;","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/vercel/ai/blob/69428b1f8b037e4d118fb4853428d5c4e620493c/packages/mcp/src/tool/mcp-apps.ts#L239-L275","documentation":"Thrown by getMCPAppResourceFromReadResult when the content entry has the correct MCP App MIME type but contains neither a 'text' string nor a 'blob' base64 string, so no HTML can be extracted. The library requires renderable HTML payload from the resource.","triggerScenarios":"A read result content matches the requested uri and has mimeType MCP_APP_MIME_TYPE, but is missing both the text and blob fields (or they are of the wrong type), leaving html === undefined.","commonSituations":"A buggy or partially-implemented MCP server returns an empty resource entry; a proxy strips the text field; the server sends binary content with malformed base64 encoding fields omitted; serialization drops the body.","solutions":["Fix the MCP server to include the HTML in content.text (or base64 in content.blob) for the ui:// resource.","Log the full read result to inspect what the server actually returned.","Update the MCP server implementation/SDK version so the resource body is serialized correctly.","If the payload is large, ensure the transport (e.g. SSE/HTTP) is not truncating or dropping the content."],"exampleFix":"// before (server response missing body)\n{ uri: 'ui://widget/gauge', mimeType: 'text/html;profile=mcp-app' }\n// after\n{ uri: 'ui://widget/gauge', mimeType: 'text/html;profile=mcp-app', text: '<html>...</html>' }","handlingStrategy":"validation","validationCode":"function hasRenderableBody(c: { text?: unknown; blob?: unknown }) {\n  return typeof c.text === 'string' || typeof c.blob === 'string';\n}","typeGuard":"function hasHtmlPayload(c: unknown): c is { text: string } | { blob: string } {\n  return !!c && typeof c === 'object' && (('text' in c && typeof (c as any).text === 'string') || ('blob' in c && typeof (c as any).blob === 'string'));\n}","tryCatchPattern":"try {\n  const app = await readMCPAppResource({ client, uri });\n} catch (e) {\n  if (e instanceof Error && e.message.startsWith('Unsupported MCP App resource content format')) {\n    // treat as empty/missing app, use placeholder UI\n  } else throw e;\n}","preventionTips":["Log the raw readResource result when integrating a new server","Add a server-side test asserting the ui:// resource includes text or blob","Keep server SDK versions current so bodies serialize correctly"],"tags":["mcp","mcp-apps","resource","payload"],"backgroundTag":"empty-resource-payload","analyzedSha":"69428b1f8b037e4d118fb4853428d5c4e620493c","analyzedAt":"2026-08-30T12:32:21.016Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}