Skip to main content
AI agents and MCP · Lesson 5 of 5 · 12 min

MCP Stateless Compatibility Lab with Two Replicas

Run a local MCP stateless compatibility lab with two Node.js replicas, then inspect HTTP routing headers, a tool discovery response and a stock lookup.

By Matthews WongReviewed on Checked against MCP specification 2026-07-28

Key takeaway

This MCP stateless compatibility lab sends tool discovery to one local replica and a stock lookup to another. The requests carry the July 2026 revision and method information. You will read the test, run both cases and describe what a separate legacy-client check would still need to prove.

You will be able to

  • Trace the HTTP requests and identify the selected replica.
  • Record a passing result and a header mismatch in a compatibility matrix.
Watch it work

Step through the diagram

Press Play, or step with the arrows. Every step is written out below the diagram.

MCP Stateless Compatibility Lab with Two Replicas

This MCP stateless compatibility lab sends tool discovery to one local replica and a stock lookup to another. The requests carry the July 2026 revision and method information. You will read the test, run both cases and describe what a separate legacy-client check would still need to prove.

Reviewed on 3 December 2026 · MCP specification 2026-07-28

Step 1 of 5. Two loopback servers run with identical sample stock and individual replica labels.

Keys: ← → step · Home / End · K play or pause

  1. Two loopback servers run with identical sample stock and individual replica labels.

  2. The client reads get_stock from the tools/list response reported by A.

  3. The request reaches a different HTTP endpoint with the tool name and method already on the request.

    Predict the next step Which result confirms the tool ran on B? (The stock count by itself · The HTTP success and B’s replica marker · The file name of the test)
  4. The test checks B’s marker and the stock object in structuredContent.

  5. The fixture returns HTTP 400 when the method header disagrees with the request body.

Separate application state from request routing

MCP 2026-07-28 carries protocol and client information with requests. The fixture focuses on tools/list and tools/call, with an unchanged stock record available to both replicas. There is no previous discovery stored on B.

Read what the test proves

Read the x-lab-replica assertions alongside the returned stock. The label belongs to this fixture. In a real deployment you can use upstream logs to establish which server answered.

Read more (1)

The fixture implements two local request cases. To claim support for a real SDK or an older client, run and record that pairing separately, including its discovery path and required extensions.

How this site does it

The real config behind this lesson

Excerpts from the repository that builds and deploys this website, quoted as they are.

examples/learn/mcp-stateless.test.mjs
  const lookup = await call(b, 2, "tools/call", listing.result.tools[0].name);
  assert.equal(lookup.status, 200);
  assert.equal(lookup.headers.get("x-lab-replica"), "b");

The client takes the tool name from A’s response and makes a new HTTP request to B. Both the operation and upstream are independently asserted.

What breaks

Mistakes that cost real time

  • Both calls accidentally go to A

    The stock can still look correct. Keep the replica assertions to catch routing mistakes.

  • The method head and body differ

    Compare the sent HTTP header and JSON-RPC method. The fixture expects a 400 for the mismatch case.

Try it yourself

Do it on your own machine

Run the fixture from the portfolio checkout with Node.js. It listens only on loopback and reads synthetic stock.

  1. Run both cases and make a note about which one intentionally gets HTTP 400.

    node --test examples/learn/mcp-stateless.test.mjs
  2. In a practice copy, change the successful lookup’s endpoint from b to a. Rerun and confirm which assertion fails, then undo the one-line experiment.

    node --test --test-name-pattern=discovery examples/learn/mcp-stateless.test.mjs
  3. Record the tested revision, methods, replica labels and outputs. Add a row marked untested for an older client.

Quick quiz

Three questions before you move on

Pick an answer to see why it is right or wrong. Nothing is graded, so guess freely; a miss is kept in this browser so the course can ask it again later.

  1. 1.Which result confirms the tool ran on B?
  2. 2.What does the test use as shared business data?
  3. 3.What should the old client row say today?
From earlier lessons

Two questions from earlier lessons

Recalling an older lesson after a gap is what makes it stick. Answer from memory before you look anything up.

  1. 1.Which of these runs outside Claude Code's sandbox?
  2. 2.What does disable_destructive actually hide?

From: 4. How to Sandbox an AI Agent: Files, Network and Secrets · 2. MCP Server Least Privilege: Read-Only Mode and Toolsets

Think it through

Answer in your head, then check

  1. 1.What does the test use as shared business data?Show the answer

    Answer:Both servers read the same immutable sample stock, so no previous discovery on B is required.

  2. 2.What should the old client row say today?Show the answer

    Answer:Only the modern fixture calls ran here. A legacy client needs a separate observed run.

Go deeper

Related deep dives on this site

Sources

Primary sources checked on the research date. Follow them for the current version.