Repository navigation
Description
Summary
The HTTP MCP loopback gateway still strips data/mimeType from non-text tool-call content blocks on 2026.6.10. normalizeToolCallContent rewrites every block to {type, text}, so image/audio/resource/resource_link results fail the MCP content-block union at the client.
This was previously reported in #68037 (now locked & closed as stale) with fix PR #68046 (closed as needs-real-behavior-proof). This issue supplies that missing real-behavior proof on current stable so the fix can land.
Environment
- OpenClaw
2026.6.10 - Bundled file (current hash):
dist/mcp-http-B3wjS3va.js:172, functionnormalizeToolCallContent(source:src/gateway/mcp-http.handlers.ts) - Transport: HTTP MCP loopback gateway. Client: an agent runtime (Claude Code) driving OpenClaw tools over the loopback.
Current code
function normalizeToolCallContent(result) {
const content = result?.content;
if (Array.isArray(content)) return content.map((block) => ({
type: block.type ?? "text",
text: block.text ?? (typeof block === "string" ? block : JSON.stringify(block))
}));
return [{ type: "text", text: typeof result === "string" ? result : JSON.stringify(result) }];
}For { type: "image", data, mimeType } this returns { type: "image", text: "<json>" } — it keeps type: "image" but drops data/mimeType, so the union rejects it.
Repro (real behavior, 2026.6.10)
- From a loopback MCP client (e.g. an OpenClaw sub-agent or the agent tool), call
browserwithaction: "screenshot". - Client-side Zod validation fails:
[{"code":"invalid_union","path":["content",0],"message":"Invalid input",
"expected":"string","path":["data"],"message":"expected string, received undefined"},
{"expected":"string","path":["mimeType"],"message":"expected string, received undefined"}]
navigate/act/evaluate(text-only) work — confirming the non-text block path is the culprit.
Isolating the layer
openclaw browser screenshot via the CLI (no loopback normalizer) works and writes a valid PNG. The browser core is fine; the loss is purely in normalizeToolCallContent on the loopback path.
User impact
Every loopback MCP client — OpenClaw sub-agents and the agent tool — cannot use browser screenshot, snapshot with labels:true, or any tool returning image/audio/resource/resource_link. The native main-agent path uses a different function and is unaffected (why this stays hidden in normal use). Matches the original impact:data-loss rating.
Fix (same intent as #68046)
Pass non-text blocks through untouched; only coerce text/string/unknown blocks:
function normalizeToolCallContent(result) {
const content = result?.content;
if (Array.isArray(content)) return content.map((block) => {
if (block && typeof block === "object" && typeof block.type === "string" && block.type !== "text") return block;
return { type: "text", text: block?.text ?? (typeof block === "string" ? block : JSON.stringify(block)) };
});
return [{ type: "text", text: typeof result === "string" ? result : JSON.stringify(result) }];
}Verified locally on 2026.6.10 (applied this patch → browser action=screenshot returns a valid image block over the loopback). Please consider reopening #68037 / merging #68046 or an equivalent. Happy to help validate.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jul 5, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed July 5, 2026, 9:23 AM ET / 13:23 UTC.
Summary
Keep open. Current main and latest release still normalize HTTP MCP loopback tool-result content down to
typeandtext, so non-text MCP blocks lose required fields; the earlier issue is stale-closed and the attempted PR is closed unmerged, so this issue is now the canonical live report.Reproducibility: yes. by source inspection: current
tools/callresponses still pass throughnormalizeToolCallContent, and that helper drops every field excepttypeandtextfrom array content blocks. I did not run a live HTTP MCP screenshot client in this read-only review.Root-cause cluster
Relationship:
canonicalCanonical: #100329
Summary: This issue is the live canonical report for the HTTP MCP loopback normalizer bug because the earlier issue is stale-closed, the attempted PR is closed unmerged, and no open PR currently owns the fix.
Members:
superseded: HTTP MCP gateway strips image/audio/resource fields from tool results (normalizeToolCallContent) #68037 - It reports the samenormalizeToolCallContentfield loss but was closed stale without a merged fix.superseded: fix: pass through image/audio/resource content blocks in MCP HTTP gateway #68046 - It attempted the same surface but is closed unmerged and had unresolved proof and validation concerns.adjacent_distinct: Browser screenshot fails MCP content validation after 2026.6.1 upgrade #90743 - It covered screenshot MCP content validation on the plugin-tools MCP bridge, which was fixed by a different merged PR and does not touch this HTTP loopback normalizer.partial_overlap: [Feature]: First-class relay of MCP ImageContent (and other binary Content) to channel extensions (iMessage/BlueBubbles, Telegram, Signal, …) #87023 - It tracks broader first-class binary MCP relay work, while this issue is a concrete HTTP loopback data-preservation bug.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
The bug is source-reproducible, current in the latest release, and narrow enough for one focused gateway fix with regression coverage.
Review details
Best possible solution:
Land a narrow gateway fix that preserves valid MCP SDK content blocks in
normalizeToolCallContent, falls back safely for malformed/unknown blocks, and adds HTTPtools/callregression coverage for non-text results.Do we have a high-confidence way to reproduce the issue?
Yes by source inspection: current
tools/callresponses still pass throughnormalizeToolCallContent, and that helper drops every field excepttypeandtextfrom array content blocks. I did not run a live HTTP MCP screenshot client in this read-only review.Is this the best way to solve the issue?
Yes, the best fix is at the gateway normalizer boundary, not in browser screenshot generation or client configuration. The repair should validate/preserve known MCP block shapes and add route-level coverage rather than reopening the old PR unchanged.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against f9e194e4a122.
Label changes
Label changes:
P2: This breaks non-text results on the HTTP MCP loopback transport without making the whole gateway runtime unusable.impact:data-loss: The reported bug silently drops structured MCP content fields such as image data, MIME type, resource URI, and embedded resource payloads.maturity:stable: The affected HTTP MCP loopback path belongs togateway-runtime, which the maturity shortlist reports as M4 Stable.issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.clawsweeper:source-repro: Current issue advisory state selects this label.clawsweeper:queueable-fix: Current issue advisory state selects this label.clawsweeper:fix-shape-clear: Current issue advisory state selects this label.Label justifications:
P2: This breaks non-text results on the HTTP MCP loopback transport without making the whole gateway runtime unusable.impact:data-loss: The reported bug silently drops structured MCP content fields such as image data, MIME type, resource URI, and embedded resource payloads.maturity:stable: The affected HTTP MCP loopback path belongs togateway-runtime, which the maturity shortlist reports as M4 Stable.Evidence reviewed
Acceptance criteria:
What I checked:
normalizeToolCallContentreturnsMcpTextContent[]and maps each array block to a fresh object containing onlytypeandtext, sodata,mimeType,resource,uri, andnameare dropped. (src/gateway/mcp-http.handlers.ts:27, f9e194e4a122)tools/callbranch executes the scoped tool and returnscontent: normalizeToolCallContent(result)in the JSON-RPC result. (src/gateway/mcp-http.handlers.ts:142, f9e194e4a122)v2026.6.11contains the same text-only normalizer, so this is not fixed in the latest shipped release. (src/gateway/mcp-http.handlers.ts:27, e085fa1a3ffd)@modelcontextprotocol/sdk1.29.0, whoseCallToolResultSchema.contentis an array ofContentBlockSchemaincluding image/audio/resource/resource_link schemas with required non-text fields. (upstream:modelcontextprotocol/typescript-sdk/src/types.ts:1272, e12cbd7078db)imageResultFromFile, andimageResultemits{ type: "image", data, mimeType }, matching the fields dropped by the loopback normalizer. (extensions/browser/src/browser-tool.ts:899, f9e194e4a122)Array<{ type: string; text: string }>and existing tool-call tests assert text responses, leaving no regression coverage for preserving image/audio/resource blocks through HTTP. (src/gateway/mcp-http.test.ts:8, f9e194e4a122)Likely related people:
src/gateway/mcp-http.handlers.ts,src/gateway/mcp-http.ts,src/gateway/mcp-http.test.ts)src/gateway/mcp-http.handlers.ts,src/gateway/mcp-http.runtime.ts,src/gateway/mcp-http.ts)src/gateway/mcp-http.handlers.ts)src/mcp/plugin-tools-handlers.ts,src/mcp/plugin-tools-serve.test.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.