Skip to content
Agent Field Notes
← Return to research directory

TOOLS

Migrating MCP without losing business truth: 2025 sessions to 2026 stateless requests

A version-pinned tutorial with before/after wire examples, dual-era probes, MRTR/Tasks boundaries, issuer/resource checks, negative controls and rollback criteria.

01 · Start with the refund the network cannot explain

A migration fails when transport state quietly becomes business truth. Imagine a client submits refund-7, the payment service commits, and a gateway drops the reply. The operations team then switches the endpoint from an initialized MCP adapter to a stateless one. If the new client interprets “no old session” as “no old refund,” it issues a second refund. The protocol upgrade did not cause the duplicate by itself; the adapter discarded the business identity.

This tutorial compares exactly MCP 2025-11-25 and MCP 2026-07-28, reviewed 2026-10-30. The latter is the current stable specification linked by the official specification entry at review time. Deployed clients may still implement older revisions. Wire blocks below are original protocol illustrations for a hypothetical test service, not executed integration evidence. Hostnames use the reserved .invalid domain; refund_order, operation_id and its ledger are application choices, not built-in MCP features.

Use MCP reconnection for the preserved legacy function exercise and tool contracts for validation and execution authority. The practical goal here is to replace transport assumptions without losing pending operations.

02 · Compare the state models before comparing packets

Visual guide · Protocol state can change; business identity must survive

Protocol state can change; business identity must survive

Teaching comparison of both protocol versions. Authentication, durable operation identity and receipts remain application responsibilities; Tasks is optional. Select the figure to open it at full size.

Concern 2025-11-25 legacy adapter 2026-07-28 modern core
Establish protocol context initialize, then notifications/initialized No core initialize handshake; declare version/capabilities per request
HTTP connection state Optional Mcp-Session-Id and legacy session lifecycle No protocol session ID; explicit server-minted application handles where needed
Result delivery Optional originating-stream replay with Last-Event-ID Request-scoped POST JSON/SSE; no Last-Event-ID resumption
Server asks for input Server-initiated JSON-RPC request MRTR input_required result; client retries with inputResponses
Independent changes Legacy standalone GET SSE Opted-in subscriptions/listen POST stream
Long operation Revision-specific experimental task support Official opt-in Tasks extension, not a core capability every peer has

“Stateless” constrains the protocol's dependency on past connection calls. It does not ban a database, job queue or application ledger. A modern list can vary by the authorization on the current request; it cannot vary because this connection previously selected a tenant through another RPC. Treat authentication, protocol era and business operation status as distinct records.

Official changes and version compatibility define the migration boundary.

03 · Before: the legacy initialization path

The first block is the legacy initialize request. For the second block, assume a successful initialization response negotiated 2025-11-25 and assigned legacy-session-7, and the client then sent notifications/initialized. Those intervening response/notification packets are omitted; do not send a tools/call before finishing that legacy sequence. Authorization headers are omitted from both generations for readability; a protected real HTTP deployment must provide its validated token on each request.

POST /mcp HTTP/1.1
Host: mcp.example.invalid
Content-Type: application/json
Accept: application/json, text/event-stream

{
  "jsonrpc": "2.0",
  "id": "legacy-init-1",
  "method": "initialize",
  "params": {
    "protocolVersion": "2025-11-25",
    "capabilities": {},
    "clientInfo": {
      "name": "field-notes-client",
      "version": "1.0.0"
    }
  }
}
POST /mcp HTTP/1.1
Host: mcp.example.invalid
Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2025-11-25
Mcp-Session-Id: legacy-session-7

{
  "jsonrpc": "2.0",
  "id": "legacy-write-1",
  "method": "tools/call",
  "params": {
    "name": "refund_order",
    "arguments": {
      "order_id": "order-7",
      "operation_id": "refund-7"
    }
  }
}

04 · After: make each modern request self-describing

The modern probe is a normal server/discover request, not a mandatory new initialization handshake. A modern server must implement it; a modern-only client can instead call another RPC and handle an unsupported-version result. For mixed fleets use a safe probe to avoid era-ambiguous tools/call behavior. The next block shows a hypothetical refund request after compatibility and authorization have been established.

POST /mcp HTTP/1.1
Host: mcp.example.invalid
Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2026-07-28
Mcp-Method: server/discover

{
  "jsonrpc": "2.0",
  "id": "probe-1",
  "method": "server/discover",
  "params": {
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientInfo": {
        "name": "field-notes-client",
        "version": "2.0.0"
      },
      "io.modelcontextprotocol/clientCapabilities": {}
    }
  }
}
POST /mcp HTTP/1.1
Host: mcp.example.invalid
Content-Type: application/json
Accept: application/json, text/event-stream
MCP-Protocol-Version: 2026-07-28
Mcp-Method: tools/call
Mcp-Name: refund_order

{
  "jsonrpc": "2.0",
  "id": "write-1",
  "method": "tools/call",
  "params": {
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientInfo": {
        "name": "field-notes-client",
        "version": "2.0.0"
      },
      "io.modelcontextprotocol/clientCapabilities": {}
    },
    "name": "refund_order",
    "arguments": {
      "order_id": "order-7",
      "operation_id": "refund-7"
    }
  }
}

The required protocolVersion and clientCapabilities live in params._meta on every request. clientInfo is recommended self-description, not authentication. HTTP mirrors the protocol version, method and applicable name into headers; execution must reject mismatches. These examples use ASCII tool names and no x-mcp-header annotations. If a real tool schema uses those annotations, the client must also encode and mirror the selected arguments and the server must verify them.

A successful discovery response has resultType=complete, supportedVersions and server capabilities. Cache it only under a reviewed server configuration and appropriate authorization scope; serverInfo alone cannot verify the remote publisher. Never cache one tenant's private tools into another tenant's context.

Modern HTTP binding, metadata, discovery.

05 · Parse resultType before declaring success

Modern core results are complete or input_required; an opted-in extension can define additional result variants. Legacy responses may lack resultType and must be interpreted according to legacy compatibility rules rather than rejected as broken modern traffic. Do not force a modern-only parser onto legacy responses.

For MRTR, assume export_report was originally called as draft-1 with the same arguments and elicitation form capability shown in the retry below. The server can return this illustrative input_required result. The next block is the client retry after a trusted user interface obtained the answer. The example state string is intentionally not a real signed state token and must not be used in production.

{
  "jsonrpc": "2.0",
  "id": "draft-1",
  "result": {
    "resultType": "input_required",
    "inputRequests": {
      "export_confirmation": {
        "method": "elicitation/create",
        "params": {
          "mode": "form",
          "message": "Export the selected report?",
          "requestedSchema": {
            "type": "object",
            "properties": {
              "confirmed": {
                "type": "boolean"
              }
            },
            "required": [
              "confirmed"
            ]
          }
        }
      }
    },
    "requestState": "example-opaque-state-not-a-real-signature"
  }
}
{
  "jsonrpc": "2.0",
  "id": "draft-2",
  "method": "tools/call",
  "params": {
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientInfo": {
        "name": "field-notes-client",
        "version": "2.0.0"
      },
      "io.modelcontextprotocol/clientCapabilities": {
        "elicitation": {
          "form": {}
        }
      }
    },
    "name": "export_report",
    "arguments": {
      "report_id": "report-7",
      "operation_id": "export-7"
    },
    "inputResponses": {
      "export_confirmation": {
        "action": "accept",
        "content": {
          "confirmed": true
        }
      }
    },
    "requestState": "example-opaque-state-not-a-real-signature"
  }
}

Each MRTR round is a separate request and uses a new JSON-RPC id; retain the same business operation identity. Return only the matching inputResponses and echo any requestState exactly, without decoding or modifying it. The server must treat returned state as attacker-controlled: protect integrity when it influences business logic, bind principal/expiry/parameter digest, and enforce single consumption separately when required. A valid MAC alone cannot prevent the same authorized state from being reused twice.

Bound MRTR rounds, input sizes and allowed user interactions. A remote tool's request for confirmation does not automatically authorize a different operation. Core's stateless request model does not mean that all extensions lack initialization or lifecycle requirements: pin and follow each adopted extension's contract.

MRTR specification.

06 · Recover asynchronous work through Tasks, not old event replay

Tasks is an official opt-in extension identified by io.modelcontextprotocol/tasks. The client declares support in per-request capabilities and the server advertises it in discovery. After that shared opt-in, a server can return a task result without a separate per-call opt-in flag. Do not infer Tasks support merely from the core revision. The example below polls a previously obtained, authorized taskId; it does not show or test task creation.

{
  "jsonrpc": "2.0",
  "id": "poll-1",
  "method": "tasks/get",
  "params": {
    "_meta": {
      "io.modelcontextprotocol/protocolVersion": "2026-07-28",
      "io.modelcontextprotocol/clientInfo": {
        "name": "field-notes-client",
        "version": "2.0.0"
      },
      "io.modelcontextprotocol/clientCapabilities": {
        "extensions": {
          "io.modelcontextprotocol/tasks": {}
        }
      }
    },
    "taskId": "example-task-7"
  }
}

When work needs input, tasks/get reports input_required and the client supplies responses through tasks/update according to the extension. Preserve taskId, service identity, principal and TTL in durable client state. A lost polling response can be polled again within policy; a lost creation response is different because the client may not know the durable handle. Reconcile that case using the original business operation ledger, not a newly generated task or JSON-RPC id.

Tasks cancellation is cooperative. Closing a polling request's HTTP stream is not proof that the separate durable job was cancelled. Conversely, in modern core, closing the SSE response stream of the in-flight request signals cancellation of that request. Neither event rewinds an external commit. Design cancellation_requested, protocol_result and business_outcome as separate fields.

Tasks extension, request cancellation.

07 · Probe both eras without executing a business write

The following command is an unexecuted template, not a runnable public endpoint. Replace the reserved hostname with an authorized test deployment and add required authentication using its approved credential workflow. A discovery probe must have no business side effect. Do not paste production secrets into a learning report.

# An authorized TEST endpoint is required; this is an unexecuted protocol probe.
# Replace the reserved .invalid host. Never use a business write as the probe.
curl --include --request POST 'https://mcp.example.invalid/mcp' \
  --header 'Content-Type: application/json' \
  --header 'Accept: application/json, text/event-stream' \
  --header 'MCP-Protocol-Version: 2026-07-28' \
  --header 'Mcp-Method: server/discover' \
  --data '{"jsonrpc":"2.0","id":"probe-1","method":"server/discover","params":{"_meta":{"io.modelcontextprotocol/protocolVersion":"2026-07-28","io.modelcontextprotocol/clientInfo":{"name":"field-notes-client","version":"2.0.0"},"io.modelcontextprotocol/clientCapabilities":{}}}}'

Implement era detection as a dedicated adapter decision, separate from retries of pending operations:

# Design pseudocode, not an executable MCP client.
probe = safe_discovery_probe(transport, preferred_version="2026-07-28")
if probe.is_discover_result:
    era = "modern"
    version = choose_mutual(probe.supportedVersions)
elif probe.is_recognized_modern_error:
    era = "modern"  # HeaderMismatch and missing capabilities are not legacy evidence.
    version = correct_request_or_choose_mutual(probe)
elif transport == "stdio" and probe.is_legacy_error_or_bounded_timeout:
    era, version = legacy_initialize_on_same_process()
elif transport == "http" and probe.http_status == 400 and probe.body_is_not_modern_error:
    era, version = legacy_initialize_on_same_origin()
else:
    stop_and_diagnose()  # Auth failures and network ambiguity do not trigger a downgrade.
persist(era, version, server_configuration_revision)
# Probe with discovery, never a business write. Preserve pending operation_id.

A legacy-only client cannot fall forward when a modern-only server rejects initialize. During migration retain a dual-era server or route those clients to a pinned legacy adapter. For stdio, inspect discovery success, recognized modern errors, other errors and bounded silence as the binding specifies. For HTTP, inspect the body of the documented 400 response; a recognized modern error stays modern. A bare authentication denial or lost response is not a valid reason to weaken permissions. Cache era against process/origin and configuration revision, then re-probe when that assumption fails.

stdio detection and compatibility matrix.

08 · Negative controls are the acceptance criteria

Use all nine combinations of legacy-only, modern-only and dual-era clients/servers. Record supported, deliberately rejected and compatibility-routed combinations; do not label all nine as expected successes. Then run these controls against a disposable authorized test deployment. The outcomes below are requirements to verify, not results measured by this article.

Probe/change Required observation What it does not prove
Omit required _meta Modern request rejected before tool execution Business receipt storage is durable
Change Mcp-Name while body keeps another tool HeaderMismatch rejection; no tool effect A gateway can trust older unvalidated header versions
Request an unsupported protocol version Recognized modern error with supported versions; no initialize downgrade The next business write is idempotent
Send modern GET + Last-Event-ID No modern replay; modern-only GET is rejected as specified An old write did not commit
Omit Tasks capability Core behavior or controlled extension error All tools support synchronous fallback
Return input_required without declared input capability Controlled capability failure User confirmation authorizes unrelated parameters
Reuse a taskId from another principal Resource authorization denies access Task IDs alone are bearer authority
Commit refund then drop reply Same operation_id reconciles to one effect or remains unknown Cancellation automatically rolls back
Repeat business key with changed arguments Executor reports conflict, never a second effect JSON-RPC itself implements the ledger

Keep request/response captures redacted. Count business rows or authoritative effects; an HTTP 2xx and a fluent final answer are insufficient. Preserve first failures and repaired reruns with protocol/SDK/server versions. No concrete SDK version is claimed here because no SDK was executed.

09 · Preserve authorization while changing transport

For protected HTTP, follow a validated authorization-server discovery chain and bind both authorization/token requests to the target MCP resource. The service validates audience and scope, then applies tenant/resource/action authorization. OAuth scope is not a substitute for checking that order-7 belongs to the current tenant. Never pass an incoming token to an unrelated downstream API; use separately issued restricted credentials or an approved delegation mechanism.

Issuer binding is a different check from resource audience. Save the issuer selected from validated metadata alongside PKCE/state. When the authorization response contains iss, compare it exactly to that issuer before code exchange, even if support was not advertised. If metadata advertises issuer-response support and iss is missing, reject. Without that advertisement and without iss, the current revision permits proceeding; do not invent a universal requirement that every missing iss fails. Do not normalize trailing slashes or case for this comparison. Mismatch errors must not become permission to display or act on attacker-supplied authorization errors.

Protect MRTR state and task handles at the execution service. Check principal and TTL, limit result size, redact credentials, and constrain outbound destinations. Tool annotations and self-reported serverInfo cannot grant authority. Validate OAuth redirects and metadata fetch destinations to reduce SSRF/mix-up risks. These controls must remain equivalent in both adapters.

Authorization and security practices.

10 · Roll back traffic without rolling back facts

Visual guide · Migrating adapters must preserve an unresolved refund

Migrating adapters must preserve an unresolved refund

Illustrative migration, not an endpoint run. Reload refund-7 and its parameters, refresh authorization, then query the original authority before any new write. Select the figure to open it at full size.

Version the client adapter, server artifact, adopted extensions, routing policy and tool contracts together. Canary a small authorized traffic slice after the matrix and security controls pass. Log protocol era, server configuration hash, principal pseudonym, operation key digest, request id, task handle reference and verified outcome. Persist the business ledger outside a transport session or a disposable client process.

A rollback changes routing for eligible new requests. It must not discard unknown writes, change a pending operation's business key, or send an existing taskId to an unrelated service. Reconcile pending writes before enabling resubmission; keep the authorized task service available until its jobs settle or are explicitly handed over. If an older adapter cannot express a required extension, reject or pause those operations with an actionable state instead of pretending the capability exists.

The learner deliverable is a version inventory, both-era wire transcript, nine-cell compatibility table, negative-control evidence, operation-ledger reconciliation and an exercised rollback record. The existing Python function exercise verifies only 13 fixed legacy decisions. This article verified source interpretation and illustrative structure; it did not contact an MCP endpoint, execute these curl templates, exercise OAuth, test hostile traffic, measure production load or prove exactly-once effects. Keep each of those claims pending until its actual evidence exists.