Repository navigation
fix(mcp): make execute results the same in every client - #235
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The same
executecall looked different depending on the MCP client:executedeclared anoutputSchema, but image results carry nostructuredContent. The MCP SDK client (protocol 2026-07-28) rejects that withTool execute has an output schema but did not return structured content, so every screenshot came back as an error. AddingstructuredContentto image results doesn't help: clients that send onlystructuredContentto the model then drop the image.structuredContent. Clients that show only the text lost the hints. Clients that show onlystructuredContentlost the error message. In our browse evals, 11 of 78 failed executes had a hint the model never saw.Change
executeno longer declares anoutputSchema. Every other tool keeps its schema. Successful non-image results still sendstructuredContent.Warnings:,Diagnostic:, aPage:line (only when the page moved, navigated, logged errors or handed off) and the latest logs. The error is capped at 3,000 characters (head and tail, so theat execute.js:L:Cframe survives), logs at 20 entries and 2,500 characters, and the whole thing stays under ~8k, so it's under the 10,000-character point where some clients cut error text. A bare error is still just the message. Image results that fail use the same text.structuredContentFailed execute (
await page.goto('about:blank'); await page.locator('#nope').click({ timeout: 2000 })), text the model gets:locator.click: Timeout 2000ms exceeded. Call log: - waiting for locator('#nope') at execute.js:5:61 + +Warnings: +- Locator failed on page about:blank. Navigate with page.goto(...) or adopt an attached tab before querying controls. + +Page: moved from https://example.com/ to about:blank; 1 navigationThe trade-off: clients lose the declared shape of
execute's structured result. Its value is whatever the script returns, so the schema only described the wrapper, and it was the reason screenshots broke.Out of scope
page.setContent(...), because the URL staysabout:blank. Fixing it properly needs a DOM check when the error happens, so I left it for another PR.Verification
bun run typecheck,bun test test/: 692 pass, 1 fail. The failure (download behavior > default behavior, missing paths and non-string paths are refusedinexecute-cdp-file-roots.test.ts) also fails ondevon this machine.cli/test/mcp-output-schema.test.ts: the full error text with nostructuredContent, a bare error stays the message, a huge call log plus 500 logs stays under 10,000 characters and keeps the warnings and latest logs, andexecutehas nooutputSchema(other tools keep theirs) so an image result passes the client's structured-content check.@modelcontextprotocol/client2.4.0 pinned to protocol 2026-07-28: ondevthe screenshot threw the validation error and the click error had no hints; on this branch the screenshot returned an image and the click error showed the message, warning and page line above. A headless CLI client that validates output schemas showed the same before/after.