Repository navigation
Add outputSchema to ModelContextTool and RegisteredTool - #254
Conversation
Codify WebMCP JSON Schema subset (Draft 2020-12) per 2026-03-05 CG resolution.
Meta-validation in registerTool() (TypeError on invalid schema) and input
validation in executeTool() parallel block before tool execute steps
(DataError with {path,reason,schemaPath} for agent self-correction).
Spec-only per review; WPT split to web-platform-tests/wpt (tentative).
Coordinates with webmachinelearning#254 (outputSchema, same dictionaries).
|
Is this still planned on being added? |
a7e008f to
a988ee0
Compare
I hope so :) 🤞 @domfarolino I've started experimenting with |
a988ee0 to
ec56f58
Compare
markafoltz
left a comment
There was a problem hiding this comment.
A few questions/comments about how the serialization result is passed around (might be missing some key idea)
markafoltz
left a comment
There was a problem hiding this comment.
Looks good % a few optional suggested edits
|
Thanks for working on this. One thing I'd like to see said explicitly is that leaving out Related, and a question more than a request: since results are serialized as JSON, a tool that returns a string comes back as a JSON string with quotes and escaped newlines. Is that the intended shape for text results, or is a plain text result something to look at separately (maybe together with the typed results work in #41 and #282)? On sjdallst2's question about validation, I'd say a result that doesn't match should reach the host as a tool error, so the host can tell it from a normal result and decide what to do. Also, a schema is written by the page, so the description fields inside it are model-visible text from the page and should get the same treatment as tool descriptions. |
|
@domfarolino I think we're good now. |
SHA: 6cd745a Reason: push, by domfarolino Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This adds an optional outputSchema dictionary member to ModelContextTool and RegisteredTool to define the expected structure of tool execution return values. Upon registration, outputSchema is serialized with the tool schema serialization algorithm, throwing a TypeError on serialization failure before checking abort signals. getTools() exposes outputSchema as a parsed JSON Schema object, or undefined when omitted. Spec PR: webmachinelearning/webmcp#254 Bug: 489045948 Bug: 565876481 Change-Id: I5e333c74c834cd6bc29253609e4e3d74edb09d08
This adds an optional outputSchema dictionary member to ModelContextTool and RegisteredTool to define the expected structure of tool execution return values. Upon registration, outputSchema is serialized with the tool schema serialization algorithm, throwing a TypeError on serialization failure before checking abort signals. getTools() exposes outputSchema as a parsed JSON Schema object, or undefined when omitted. Spec PR: webmachinelearning/webmcp#254 Bug: 489045948 Bug: 565876481 Change-Id: I5e333c74c834cd6bc29253609e4e3d74edb09d08 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8398367 Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> Reviewed-by: Dominic Farolino <dom@chromium.org> Commit-Queue: Fr <beaufort.francois@gmail.com> Cr-Commit-Position: refs/heads/main@{#1732837}
This adds an optional outputSchema dictionary member to ModelContextTool and RegisteredTool to define the expected structure of tool execution return values. Upon registration, outputSchema is serialized with the tool schema serialization algorithm, throwing a TypeError on serialization failure before checking abort signals. getTools() exposes outputSchema as a parsed JSON Schema object, or undefined when omitted. Spec PR: webmachinelearning/webmcp#254 Bug: 489045948 Bug: 565876481 Change-Id: I5e333c74c834cd6bc29253609e4e3d74edb09d08 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8398367 Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> Reviewed-by: Dominic Farolino <dom@chromium.org> Commit-Queue: Fr <beaufort.francois@gmail.com> Cr-Commit-Position: refs/heads/main@{#1732837}
This adds an optional outputSchema dictionary member to ModelContextTool and RegisteredTool to define the expected structure of tool execution return values. Upon registration, outputSchema is serialized with the tool schema serialization algorithm, throwing a TypeError on serialization failure before checking abort signals. getTools() exposes outputSchema as a parsed JSON Schema object, or undefined when omitted. Spec PR: webmachinelearning/webmcp#254 Bug: 489045948 Bug: 565876481 Change-Id: I5e333c74c834cd6bc29253609e4e3d74edb09d08 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/8398367 Reviewed-by: Khushal Sagar <khushalsagar@chromium.org> Reviewed-by: Dominic Farolino <dom@chromium.org> Commit-Queue: Fr <beaufort.francois@gmail.com> Cr-Commit-Position: refs/heads/main@{#1732837}
This PR adds an optional
outputSchemamember to theModelContextToolandRegisteredTooldictionaries to enable browser agents and in-page agents to help LLMs reliably reason about the return values of tools.While
responseConstraintwas previously discussed, that name is too specific to the Built-in AI / Prompt API. TheoutputSchemaname aligns directly with the MCP Tools specificationoutputSchemaused to define expected structured outputs with JSON Schema.FIX #9
Preview | Diff