Skip to content

Commit ec57a39

Browse files
authored
fix: use blob field for binary resources to prevent context overflow (cloudflare#252)
Binary content (images, etc.) was incorrectly using 'text' field, causing MCP hosts like Claude Desktop to display base64 strings as text messages, flooding the context window. Changed to use 'blob' field for binary data per MCP 2025-06-18 spec.
1 parent c0d176f commit ec57a39

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

apps/sandbox-container/server/containerMcp.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,10 @@ export class ContainerMcpAgent extends McpAgent<Env, never, Props> {
165165
{
166166
type: 'resource',
167167
resource: {
168-
text: readFile.type === 'text' ? readFile.textOutput : readFile.base64Output,
168+
...(readFile.type === 'text'
169+
? { text: readFile.textOutput }
170+
: { blob: readFile.base64Output }
171+
),
169172
uri: `file://${path}`,
170173
mimeType: readFile.mimeType,
171174
},

0 commit comments

Comments
 (0)