Skip to content

HTTP MCP loopback still strips image/audio/resource fields on 2026.6.10 (normalizeToolCallContent) — real-behavior proof for #68037 / #68046 #100329

Closed

Description

@OpenClawKobian99

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, function normalizeToolCallContent (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)

  1. From a loopback MCP client (e.g. an OpenClaw sub-agent or the agent tool), call browser with action: "screenshot".
  2. 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"}]
  1. 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.

Activity

  1. clawsweeper commented on Jul 5, 2026

    @clawsweeper
    Contributor

    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 type and text, 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/call responses still pass through normalizeToolCallContent, and that helper drops every field except type and text from array content blocks. I did not run a live HTTP MCP screenshot client in this read-only review.

    Root-cause cluster
    Relationship: canonical
    Canonical: #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:

    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 HTTP tools/call regression coverage for non-text results.

    Do we have a high-confidence way to reproduce the issue?

    Yes by source inspection: current tools/call responses still pass through normalizeToolCallContent, and that helper drops every field except type and text from 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:

    • No live HTTP MCP client was run in this read-only review; the conclusion rests on source inspection, the reporter's stable-release proof, current tests, and the pinned MCP SDK contract.
    • A repair should not repeat the closed PR's overbroad pass-through guard; valid SDK content blocks should be preserved while malformed or unknown blocks fall back to text.

    Codex review notes: model internal, reasoning high; reviewed against f9e194e4a122.

    Label changes

    Label changes:

    • add P2: This breaks non-text results on the HTTP MCP loopback transport without making the whole gateway runtime unusable.
    • add impact:data-loss: The reported bug silently drops structured MCP content fields such as image data, MIME type, resource URI, and embedded resource payloads.
    • add maturity:stable: The affected HTTP MCP loopback path belongs to gateway-runtime, which the maturity shortlist reports as M4 Stable.
    • add issue-rating: 🦞 diamond lobster: Current issue advisory state selects this label.
    • add clawsweeper:source-repro: Current issue advisory state selects this label.
    • add clawsweeper:queueable-fix: Current issue advisory state selects this label.
    • add 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 to gateway-runtime, which the maturity shortlist reports as M4 Stable.
    Evidence reviewed

    Acceptance criteria:

    • pnpm test src/gateway/mcp-http.test.ts src/gateway/mcp-http.handlers.test.ts
    • pnpm check:changed -- src/gateway/mcp-http.handlers.ts src/gateway/mcp-http.test.ts src/gateway/mcp-http.handlers.test.ts

    What I checked:

    • Current main still strips non-text fields: normalizeToolCallContent returns McpTextContent[] and maps each array block to a fresh object containing only type and text, so data, mimeType, resource, uri, and name are dropped. (src/gateway/mcp-http.handlers.ts:27, f9e194e4a122)
    • Lossy helper is on the reported HTTP tools/call path: The tools/call branch executes the scoped tool and returns content: normalizeToolCallContent(result) in the JSON-RPC result. (src/gateway/mcp-http.handlers.ts:142, f9e194e4a122)
    • Latest release still has the same behavior: Release tag v2026.6.11 contains the same text-only normalizer, so this is not fixed in the latest shipped release. (src/gateway/mcp-http.handlers.ts:27, e085fa1a3ffd)
    • MCP SDK contract requires non-text block fields: OpenClaw pins @modelcontextprotocol/sdk 1.29.0, whose CallToolResultSchema.content is an array of ContentBlockSchema including image/audio/resource/resource_link schemas with required non-text fields. (upstream:modelcontextprotocol/typescript-sdk/src/types.ts:1272, e12cbd7078db)
    • Browser screenshot source emits the affected image shape: The browser screenshot action returns imageResultFromFile, and imageResult emits { type: "image", data, mimeType }, matching the fields dropped by the loopback normalizer. (extensions/browser/src/browser-tool.ts:899, f9e194e4a122)
    • Current tests are text-only at the loopback result boundary: The MCP HTTP test mock result type is 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:

    • steipete: Peter Steinberger split the MCP loopback transport helpers into the current handler files and current blame/history carries the lossy helper through this path. (role: introduced current handler and recent area contributor; confidence: high; commits: 25b069a6f3cd, 3d23103081f4, b6f4cf5ac432; files: src/gateway/mcp-http.handlers.ts, src/gateway/mcp-http.ts, src/gateway/mcp-http.test.ts)
    • Michael Appel: Michael Appel modified the same MCP loopback handler/runtime/test path while adding owner-only tool policy and before-tool-call hook behavior. (role: recent adjacent contributor; confidence: medium; commits: 8b76392e3e79; files: src/gateway/mcp-http.handlers.ts, src/gateway/mcp-http.runtime.ts, src/gateway/mcp-http.ts)
    • vincentkoc: Vincent Koc touched the shared runtime typing seam in this handler and tagged the latest release that still contains the lossy behavior. (role: recent adjacent contributor and release-path contributor; confidence: medium; commits: c109a7623b13, e085fa1a3ffd; files: src/gateway/mcp-http.handlers.ts)
    • mushuiyu886: mushuiyu886 authored the merged plugin-tools MCP content-shape fix for a nearby screenshot/content validation path, which is adjacent but distinct from this HTTP loopback normalizer bug. (role: adjacent MCP content-boundary contributor; confidence: medium; commits: a846b879ecd9; files: src/mcp/plugin-tools-handlers.ts, src/mcp/plugin-tools-serve.test.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P2Normal backlog priority with limited blast radius.
    impact:data-lossCan lose, corrupt, or silently drop user/session/config data.
    maturity:stableBroken existing behavior primarily owned by an M4/M5 scorecard surface.
    no-staleExclude from stale automation
    issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.
    clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.
    on Jul 5, 2026
  3. locked as resolved and limited conversation to collaborators on Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.maturity:stableBroken existing behavior primarily owned by an M4/M5 scorecard surface.no-staleExclude from stale automation

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions