Skip to content

fix: serve server/discover from the hand-rolled client-scenario mocks#347

Merged
pcarleton merged 1 commit into
mainfrom
fweinberger/hand-rolled-mocks-discover
Jun 18, 2026
Merged

fix: serve server/discover from the hand-rolled client-scenario mocks#347
pcarleton merged 1 commit into
mainfrom
fweinberger/hand-rolled-mocks-discover

Conversation

@felixweinberger

Copy link
Copy Markdown
Collaborator

The hand-rolled mock servers for the SEP-2243/2322/2106 client-direction scenarios now answer server/discover, so a 2026-07-28 client that negotiates via discover before its scenario calls can proceed without intercepting the response at the transport layer.

Motivation and Context

server/discover is the recommended negotiation entry point at 2026-07-28 ("Clients MAY call server/discover", server/discover); a client that does so against the suite's mocks should get a valid DiscoverResult. The shared stateless mock (createServerStateless / validateStatelessRequest) and the request-metadata and auth scenarios already serve it, but the hand-rolled servers used by http-standard-headers, http-custom-headers, http-invalid-tool-headers, sep-2322-client-request-state, and json-schema-ref-no-deref did not — discover hit their fallbacks (-32601 for the MRTR mock, the generic empty result for the SEP-2243 scenarios, the bundled 1.x SDK's method-not-found for the SEP-2106 scenario). A client whose fixture negotiates via discover currently has to synthesize the response itself; the typescript-sdk's everythingClient carries exactly that workaround.

Same family as #341: the mocks need to speak enough of the 2026-07-28 surface that a strictly-conforming client can connect and proceed.

What changed

  • BaseHttpScenario answers server/discover itself (before delegating to handlePost) with a valid DiscoverResult: supportedVersions: [DRAFT_PROTOCOL_VERSION], capabilities from a new overridable discoverCapabilities() (default { tools: {} }), serverInfo, and the required resultType/ttlMs/cacheScope. sendInitialize defaults its capabilities to the same hook so the legacy and modern paths advertise the same set.
  • http-standard-headers overrides discoverCapabilities() to { tools: {}, resources: {}, prompts: {} } (the methods it actually serves).
  • mrtr-client adds a server/discover case to its method switch.
  • json-schema-ref-no-deref answers server/discover directly before handing the request to the bundled SDK transport (which predates the 2026-07-28 lifecycle).
  • draft-result-fields.test.ts gains a parameterised test asserting each of the five scenarios returns a valid DiscoverResult carrying supportedVersions: [draft], the expected capabilities, and the cacheable-result members.

How Has This Been Tested?

  • npm run check, npm run build, npm test — all green (293 tests, including the 5 new discover assertions).
  • node dist/index.js client --command "npx tsx examples/clients/typescript/everything-client.ts" --suite draft before and after the change: identical results (the bundled example client doesn't call discover on these scenarios, so this confirms no regression for clients that don't).

Breaking Changes

None. The added server/discover handling is purely additive; clients that don't call discover see no change.

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

Additional context

  • Once this ships in a release, the typescript-sdk's everythingClient can drop its discover-interception shim and exercise the negotiation step against the mocks for real.
  • json-schema-ref-no-deref still routes everything except discover through the bundled 1.x SDK transport (initialize handshake, no _meta validation); fully reworking that scenario to a hand-rolled stateless server is a larger follow-up flagged in fix: include required result members in 2026-07-28 mock responses #341.
  • These mocks deliberately do not enforce per-request _meta validation (unlike the shared stateless mock), so clients on either lifecycle can drive them; only the discover response was missing.
  • Because BaseHttpScenario now answers discover before delegating to handlePost, http-standard-headers no longer emits its opportunistic Mcp-Method check for server/discover (it was never in the scenario's expectedMethods list, so no backfill or test changes). If we want SEP-2243 header coverage on server/discover, the right place is the scenario's expected-methods list — separate question from this PR.

The SEP-2243, SEP-2322, and SEP-2106 client-direction scenarios build
their own mock servers and did not answer server/discover, so a
2026-07-28 client that negotiates via discover before its scenario calls
hit a -32601 or generic fallback and had to synthesize the response
itself. The shared stateless mock and the request-metadata and auth
scenarios already served it.

BaseHttpScenario now answers server/discover with a valid DiscoverResult
(supportedVersions, capabilities from an overridable
discoverCapabilities(), serverInfo, plus the cacheable-result members)
before delegating to handlePost; http-standard-headers overrides the
capabilities to match the methods it serves. mrtr-client and
json-schema-ref-no-deref answer it directly. New tests pin the response
shape for all five scenarios.
@pkg-pr-new

pkg-pr-new Bot commented Jun 18, 2026

Copy link
Copy Markdown

Open in StackBlitz

npx https://pkg.pr.new/@modelcontextprotocol/conformance@347

commit: 17e53b3

@pcarleton pcarleton merged commit 206709f into main Jun 18, 2026
8 checks passed
@pcarleton pcarleton deleted the fweinberger/hand-rolled-mocks-discover branch June 18, 2026 14:30
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