Repository navigation
Clarify resultType is required; reframe absent-field handling as backward compat - #2726
Merged
1 commit merged intoMay 15, 2026
Merged
1 commit merged into
1 commit merged into
Conversation
pja-ant
force-pushed
the
pja/draft-result-type-clarifications
branch
from
May 15, 2026 15:13
a782424 to
5ebd3d7
Compare
pja-ant
marked this pull request as ready for review
May 15, 2026 15:23
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
…ward compat
- Remove `@default "complete"` from `Result.resultType` in schema.ts. A
required field has no default; the JSDoc and generated JSON Schema
annotation gave the false impression that omitting it is conformant.
- Add JSDoc explaining the actual model: servers implementing this
protocol version MUST include `resultType`; clients MUST treat an
absent `resultType` from older servers as "complete".
- Fix the TypeScript snippet in basic/index.mdx, which placed
`resultType` as a sibling of `result` in the JSON-RPC envelope. Per
the schema it is a field of `Result` and lives inside `result`.
- Split the contradictory sentence "MUST be included … if not specified
assume complete" into a server requirement and a separate client-side
backward-compatibility rule for results from earlier protocol versions.
- Add the missing verb ("indicates") in the two ResultType definition
bullets, and fix "poly-morphic" -> "polymorphic".
- Regenerate schema.json and schema.mdx.
Note: 19 example JSON files that omit resultType are unchanged by this
PR; #2725 adds resultType to those examples.
pja-ant
force-pushed
the
pja/draft-result-type-clarifications
branch
from
May 15, 2026 15:31
fc7f5ab to
2031da6
Compare
7 of 9 tasks
jakemac53
pushed a commit
to dart-lang/ai
that referenced
this pull request
Jul 24, 2026
First slice of the 2026-07-28 core-protocol support tracked in #162, split out from the HTTP transport work to keep it small and reviewable on its own. Adds the `resultType` result field as an additive, non-breaking API: - `Result.resultType` reads the field. A null value means the server did not send it; callers treat null as `complete`, the backward-compatible convention the 2026-07-28 schema requires for results from servers on earlier protocol versions. See modelcontextprotocol/modelcontextprotocol#2726, which reframes an absent `resultType` as backward compatibility. - The getter is a nullable `String`, exactly matching `CreateMessageResult.stopReason` (both `String?`), the open union this package already has. The schema types `resultType` as `"complete" | "input_required" | string`, so a server may send a value this package does not know. A closed `enum` cannot represent that set; it would have to throw on an unknown value or fold it into a fallback constant, and both lose the string the server actually sent. See modelcontextprotocol/modelcontextprotocol#2773, the SEP-2322 fix that made `ResultType` an open union so servers can extend it. - No `latestSupported` bump and no server-side emission; those are later slices. This is the read side, so a client parses `resultType` from a 2026-07-28 server correctly without waiting for the rest. ## Tests - `resultType` is null when the field is absent, and passes both a known value and an unknown string through unchanged. - `dart test -p chrome,vm -c dart2wasm,dart2js,kernel,exe` passes (219 tests in each of the four configurations). - `dart analyze --fatal-infos` is clean here and in `mcp_examples` resolved against this branch. The diff only adds lines, so existing formatting is untouched. Part of #162.
This branch was successfully deployed
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.
Motivation and Context
A review of the draft spec found three issues with how
Result.resultType(introduced in SEP-2322) is specified:schema.tsmarksresultTyperequired (no?) while annotating it@default "complete". A required field cannot have a default; the@defaultJSDoc generates a misleading"default"keyword inschema.jsonandschema.mdx, and contributed to 19 example files being authored without the field (those are fixed separately in Bug & Doc Fixes for SEP-2322: MRTR Docs #2725).basic/index.mdxsays "MUST be included" and "if not specified, assume complete" in the same bullet, which reads as a contradiction. The intent is thatresultTypeis required for servers implementing this protocol version, and the "assume complete" fallback is a client-side backward-compatibility rule for results received from servers implementing earlier protocol versions.basic/index.mdxplacesresultTypeas a sibling ofresultin the JSON-RPC envelope. Per the schema it is a field ofResultand lives insideresult.This PR resolves them by stating the model explicitly: servers implementing the draft protocol MUST include
resultType; clients MUST treat an absentresultTypefrom older servers as"complete". Also adds the missing "indicates" verb in the two ResultType bullets and fixes "poly-morphic" → "polymorphic".schema.jsonandschema.mdxare regenerated.Note
19 example JSON files that omit
resultTypeare unchanged here; #2725 addsresultTypeto those examples and is the right place for that fix.How Has This Been Tested?
npm run generate:schema(clean),npm run check:schema(110 passed, 19 failed — all 19 are the pre-existing missing-resultTypeexamples addressed in Bug & Doc Fixes for SEP-2322: MRTR Docs #2725, no new failures).Breaking Changes
None. This is a documentation/annotation clarification; the wire format is unchanged.
Types of changes
Checklist