Skip to content

examples: MRTR backwards-compatibility exploration demos#1597

Draft
pcarleton wants to merge 2 commits intomainfrom
paulc/mrtr-backcompat-demos
Draft

examples: MRTR backwards-compatibility exploration demos#1597
pcarleton wants to merge 2 commits intomainfrom
paulc/mrtr-backcompat-demos

Conversation

@pcarleton
Copy link
Member

What

Three side-by-side demo servers exploring the backwards-compatibility story for existing await elicitInput()-style tool handlers under the MRTR SEP (transports-wg#12).

This is a direct response to the review discussion at line ~1160 ("this 'ideally' is doing a lot of heavy lifting … we need to figure out what's happening here").

Classification

# Scenario Hazard of naive retry Migration cost requestState? Tasks?
1 Simple retry — idempotent lookup Wasted compute only Trivial (mechanical inversion) No No
2 Continuation state — multi-step dialogue User re-prompted for answers already given Moderate (handler → state machine) Yes No
3 Persistent — mutation before elicitation Duplicate side-effects (e.g. two VMs) High (migrate to Tasks) N/A Yes

Each demo registers <name>_before (today's pattern) and <name>_after (MRTR pattern) on the same server, so you can diff the handler bodies directly.

Files

  • shims.ts — stand-in types for IncompleteResult, InputRequests/InputResponses; MRTR params ride on arguments._mrtr until the SDK threads them through natively.
  • 01SimpleRetry.ts — weather lookup; migration is essentially mechanical.
  • 02ContinuationState.ts — ADO-style cascading required fields (mirrors the SEP's real-world example).
  • 03TasksMigration.ts — VM provisioning with a mutation before elicitation; sketches the Tasks shape, defers full plumbing to simpleTaskInteractive.ts.
  • README.md — decision tree + rationale.

Not in scope

  • No transport changes (IncompleteResult is smuggled as a JSON text block)
  • No SDK-level auto-shim (the interesting follow-up question)
  • No paired demo client (drive manually via Inspector)

This is exploratory / not intended to merge as-is. Goal is to make the three migration buckets concrete enough to discuss which (if any) an SDK-level backcompat layer can automate.

Three side-by-side demo servers exploring the migration story for
existing `await elicitInput()`-style handlers under the MRTR SEP
(transports-wg#12), bucketed by migration cost:

  1. Simple retry — idempotent; mechanical inversion to
     'check inputResponses, else return IncompleteResult'
  2. Continuation state — multi-step dialogue; handler becomes a
     re-entrant state machine threading requestState through the client
  3. Persistent — mutation before elicitation; MRTR alone cannot
     rescue this, must migrate to Tasks workflow

Each demo registers <name>_before (today's pattern) and <name>_after
(MRTR pattern) so the diff is visible in one file.

The SDK doesn't have the real types yet so shims.ts stubs
IncompleteResult/InputRequests and carries the MRTR params via a
reserved `arguments._mrtr` key as a transport stand-in.

Relates to the backwards-compatibility discussion at
modelcontextprotocol/transports-wg#12
@changeset-bot
Copy link

changeset-bot bot commented Feb 27, 2026

⚠️ No Changeset found

Latest commit: 0ad4163

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@pkg-pr-new
Copy link

pkg-pr-new bot commented Feb 27, 2026

Open in StackBlitz

@modelcontextprotocol/client

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/client@1597

@modelcontextprotocol/server

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/server@1597

@modelcontextprotocol/express

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/express@1597

@modelcontextprotocol/hono

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/hono@1597

@modelcontextprotocol/node

npm i https://pkg.pr.new/modelcontextprotocol/typescript-sdk/@modelcontextprotocol/node@1597

commit: db161d9

… growth

Companion to 02ContinuationState.ts. Where 02 shows conditional
branching (second question depends on first answer), 04 shows
linear accumulation: a fixed three-step wizard where requestState
grows monotonically each round (route → route+dates → full itinerary).

This is the more common shape of multi-elicitation tool in practice
(booking flows, setup wizards, onboarding), and the migration is
correspondingly simpler — a flat chain of 'have X yet? ask for X'
checks with no branching logic.

Also highlights that prompts referencing prior answers (e.g. 'dates
for LHR → SFO?') work identically under MRTR: the data just comes
from decoded requestState instead of closure variables.
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.

1 participant