Skip to content

Clarify resultType is required; reframe absent-field handling as backward compat - #2726

Merged
1 commit merged into
mainfrom
pja/draft-result-type-clarifications
May 15, 2026
Merged

1 commit merged into
mainfrom
pja/draft-result-type-clarifications

Conversation

@pja-ant

@pja-ant pja-ant commented May 15, 2026

Copy link
Copy Markdown
Contributor

Motivation and Context

A review of the draft spec found three issues with how Result.resultType (introduced in SEP-2322) is specified:

  1. schema.ts marks resultType required (no ?) while annotating it @default "complete". A required field cannot have a default; the @default JSDoc generates a misleading "default" keyword in schema.json and schema.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).
  2. basic/index.mdx says "MUST be included" and "if not specified, assume complete" in the same bullet, which reads as a contradiction. The intent is that resultType is 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.
  3. The TypeScript snippet in basic/index.mdx places resultType as a sibling of result in the JSON-RPC envelope. Per the schema it is a field of Result and lives inside result.

This PR resolves them by stating the model explicitly: servers implementing the draft protocol MUST include resultType; clients MUST treat an absent resultType from older servers as "complete". Also adds the missing "indicates" verb in the two ResultType bullets and fixes "poly-morphic" → "polymorphic".

schema.json and schema.mdx are regenerated.

Note

19 example JSON files that omit resultType are unchanged here; #2725 adds resultType to those examples and is the right place for that fix.

How Has This Been Tested?

Breaking Changes

None. This is a documentation/annotation clarification; the wire format is unchanged.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

@pja-ant
pja-ant force-pushed the pja/draft-result-type-clarifications branch from a782424 to 5ebd3d7 Compare May 15, 2026 15:13
@pja-ant
pja-ant marked this pull request as ready for review May 15, 2026 15:23
@pja-ant
pja-ant requested a review from a team as a code owner May 15, 2026 15:23
@mintlify

mintlify Bot commented May 15, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
mcp-staging 🟢 Ready View Preview May 15, 2026, 3:25 PM

💡 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
pja-ant force-pushed the pja/draft-result-type-clarifications branch from fc7f5ab to 2031da6 Compare May 15, 2026 15:31
@pja-ant
pja-ant requested a review from CaitieM20 May 15, 2026 15:35
@CaitieM20 CaitieM20 mentioned this pull request May 15, 2026
7 of 9 tasks
@CaitieM20 CaitieM20 closed this pull request by merging all changes into main in c410707 May 15, 2026
@CaitieM20
CaitieM20 deleted the pja/draft-result-type-clarifications branch May 15, 2026 18:55
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

1 active deployment
staging - docs — 2031da67 Deployed May 15, 2026 by mintlify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants