fix: include required result members in 2026-07-28 mock responses#341
Merged
Conversation
At the 2026-07-28 revision every server result must include resultType, and cacheable results (server/discover, tools/list, prompts/list, resources/list, resources/templates/list, resources/read) must also include ttlMs and cacheScope. The client-direction mock servers omitted these, so a strictly-validating client was failed by the suite's own non-conformant mock. The shared stateless mock now stamps the missing members onto handler results and its server/discover response (withRequiredDraftResultFields), and the hand-rolled per-scenario servers set them explicitly or route their fallbacks through the helper. The deliberately resultType-less probe in sep-2322-client-request-state is unchanged. New tests pin the response shapes.
commit: |
felixweinberger
commented
Jun 16, 2026
| jsonrpc: '2.0', | ||
| id, | ||
| result: { | ||
| result: withRequiredDraftResultFields(method, { |
Collaborator
Author
There was a problem hiding this comment.
this is only happening in the stateless branch of the auth helper
pcarleton
approved these changes
Jun 16, 2026
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.
The mock servers used for client-direction scenarios return results that are not valid for the 2026-07-28 revision: they omit
resultType, and the cacheable results also omitttlMs/cacheScope. This makes those results spec-valid so the suite can no longer fail a strictly-conforming client because of its own mock.Motivation and Context
At 2026-07-28, results from servers must include
resultType("TheresultMUST include aresultTypefield", basic/index §Result responses;Result.resultTypeinschema/draft/schema.ts: "Servers implementing this protocol version MUST include this field"), and the six cacheable operations (server/discover,tools/list,prompts/list,resources/list,resources/templates/list,resources/read) must also includettlMsandcacheScope(CacheableResult, server/utilities/caching). The suite's own server-direction checksep-2322-result-type-includedalready enforces theresultTypeMUST against servers under test.The client-direction mocks don't follow it themselves: the stateless mock wraps scenario handler results verbatim and its built-in
server/discoverresult has none of these members, and the hand-rolled per-scenario servers (SEP-2243/2575/2322 scenarios, the auth helper) build results without them. The absent⇒complete bridge in the spec is explicitly scoped to earlier-revision servers, so a client that validates 2026-07-28 results strictly is correct to reject these — and then can't passtools_call(or other carry-forward scenarios) at--spec-version 2026-07-28even though the non-conformant party is the mock.What changed
src/mock-server/stateless.ts: newwithRequiredDraftResultFields(method, result)helper (exported viasrc/mock-server/index.ts) fillsresultType: "complete"on every result andttlMs: 0/cacheScope: "private"on cacheable-method results, preserving anything the handler set itself. Applied to the handler wrap point and the built-inserver/discoverresult, so everyctx.createServer-based scenario is covered.http-standard-headers,http-custom-headers,http-invalid-tool-headers),request-metadata,sep-2322-client-request-state, the auth helper's stateless path, andjson-schema-ref-no-deref's tools/list now return the required members. Method-dispatched fallbacks (sendGenericResult, the request-metadata generic reply, the auth helper) route through the shared helper so cacheable methods that fall through still get the caching hints; fixed per-method literals carry the members explicitly so the wire shape stays visible at the emission site.sep-2322-default-result-type-completeprobe insep-2322-client-request-statestill omitsresultType— that omission is the check's stimulus.mock-server.test.tspins the helper and the stateless wrap point;tools_call.test.tsgains a draft-mode case asserting the scenario serves spec-valid 2026-07-28 results; newdraft-result-fields.test.tspins the hand-rolled scenario servers (including the fallback path and the preserved deliberate omission).How Has This Been Tested?
npm run check,npm run build,npm test: all green (285 tests, including the new response-shape pins).node dist/index.js client --command "npx tsx examples/clients/typescript/everything-client.ts" --suite draftbefore and after the change: identical results (115 passed / 9 failed — the 9 are pre-existing gaps in the bundled example client, unrelated to result shapes), so existing clients see no behavior change beyond the added members.Breaking Changes
None for clients: the added members are required by the 2026-07-28 schema and ignored by earlier-revision clients. Note for SDK consumers: SDKs pin published releases, so a strict 2026 client can only pass the affected client-direction scenarios once a release containing this change is published (next alpha).
Types of changes
Checklist
Additional context
sep-2322-default-result-type-completecheck exercises the absent⇒complete bridge against a mock that claims 2026-07-28; per the spec the bridge is scoped to earlier-revision servers, so that check may want re-scoping or rewording — left out of this PR as a follow-up question.json-schema-ref-no-derefserves everything except tools/list through the bundled 1.x SDK transport (initialize handshake, noserver/discover), so the scenario as a whole is still not a conformant 2026-07-28 server; making it one needs a separate rework coordinated with the example client.http-custom-header-server-validationagainst a server with nox-mcp-headertool); deliberately not touched here, will be raised separately.