Skip to content

feat(webmcp-polyfill): serialize image tool results - #260

Draft
MiguelsPizza wants to merge 2 commits into
mainfrom
alex/webmcp-image-tool-results
Draft

feat(webmcp-polyfill): serialize image tool results#260
MiguelsPizza wants to merge 2 commits into
mainfrom
alex/webmcp-image-tool-results

Conversation

@MiguelsPizza

Copy link
Copy Markdown
Contributor

Summary

Splits the WebMCP image-value feature work out of local main onto its own branch. Tools registered on document.modelContext can return direct image values, either as serialized { type: "image", data, mimeType } payloads or browser-source { type: "image", value, mimeType? } payloads backed by Blob, HTMLCanvasElement, or HTMLImageElement.

This also adds the matching @mcp-b/webmcp-types image value types and a focused Playwright runtime contract for the polyfill/native image-value behavior.

Why

This is unrelated feature work and should not be mixed into the release-prep commits currently sitting on local main. The implementation follows the image/tool-result direction discussed in WebMCP: webmachinelearning/webmcp#41 and webmachinelearning/webmcp#86.

Validation

  • pnpm --filter @mcp-b/webmcp-types typecheck
  • pnpm --filter @mcp-b/webmcp-polyfill typecheck
  • pnpm --filter mcp-e2e-tests exec playwright test tests/runtime-contract-image-values.spec.ts

Note: the focused e2e run requires local workspace package builds first in a fresh worktree because the test app imports built package entry points.

MiguelsPizza and others added 2 commits July 1, 2026 13:49
Tools registered on document.modelContext can now return image values:
the serialized MCP-style {type: 'image', data, mimeType} form, or a
browser-source {type: 'image', value, mimeType?} form carrying a Blob,
HTMLCanvasElement, or HTMLImageElement. The source shape mirrors the
Prompt API's LanguageModelToolResultContent {type, value}; sources are
encoded with Web APIs (Blob.arrayBuffer, canvas.toBlob) and serialized
to the base64 data form before executeTool() returns (see
webmachinelearning/webmcp#41 and webmachinelearning/webmcp#86).

Adds @mcp-b/webmcp-types image value types and a Playwright runtime
contract suite that runs against the polyfill, stock Chrome, and native
WebMCP Chromium builds. Browser-source serialization is optional for
native runtimes until spec text exists; those tests skip via runtime
capability detection.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Cover a canvas-backed image value with a requested JPEG MIME type and
an array-wrapped image value (image detection applies to the top-level
result only), mirroring the new wpt_internal subtests in the Chromium
CL. Verified green against both the polyfill and the native build.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@github-actions github-actions Bot added documentation Improvements or additions to documentation testing Test-related changes config Configuration file changes dependencies Dependency updates labels Jul 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes dependencies Dependency updates documentation Improvements or additions to documentation testing Test-related changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant