# 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.

URL: https://www.matthewswong.com/en/learn/ai-agents-mcp/mcp-stateless-compatibility-lab/

AI agents and MCP · Lesson 5 of 5 · Reviewed on 3 December 2026 · Checked against MCP specification 2026-07-28 · By Matthews Wong (https://www.matthewswong.com/en/about/)

> 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.

## 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.

1. **Start the fixture.** Two loopback servers run with identical sample stock and individual replica labels.
2. **List tools on A.** The client reads get_stock from the tools/list response reported by A.
3. **Call the tool on B.** The request reaches a different HTTP endpoint with the tool name and method already on the request.

   *Predict:* 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. **Validate stock and replica.** The test checks B’s marker and the stock object in structuredContent.
5. **Check a mismatch.** 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.

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.

## The real config behind this lesson

`examples/learn/mcp-stateless.test.mjs`

```js
  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

- **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

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.

   ```bash
   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.

   ```bash
   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

1. **Which result confirms the tool ran on B?**
   A. The stock count by itself
   B. The HTTP success and B’s replica marker
   C. The file name of the test
   Answer: B. The marker identifies the upstream. The server’s returned stock verifies the operation separately.

2. **What does the test use as shared business data?**
   A. Fixed stock for one chain SKU
   B. A client session ID
   C. A global developer token
   Answer: A. Both servers read the same immutable sample stock, so no previous discovery on B is required.

3. **What should the old client row say today?**
   A. Supported in production
   B. Protocol conformance certified
   C. Untested in this lab
   Answer: C. Only the modern fixture calls ran here. A legacy client needs a separate observed run.

## Think it through

- **What does the test use as shared business data?** Both servers read the same immutable sample stock, so no previous discovery on B is required.
- **What should the old client row say today?** Only the modern fixture calls ran here. A legacy client needs a separate observed run.

## Go deeper

- [MCP 2.0 Explained and the Latest Stable Specification](https://www.matthewswong.com/en/blog/mcp-2-0-latest-spec-version/)
- [Test Stateless MCP Across Two Server Replicas](https://www.matthewswong.com/en/blog/mcp-stateless-multi-replica-test/)

## Sources

- [Streamable HTTP](https://modelcontextprotocol.io/specification/2026-07-28/basic/transports/streamable-http)
- [MCP tools specification](https://modelcontextprotocol.io/specification/2026-07-28/server/tools)

---

- HTML version: https://www.matthewswong.com/en/learn/ai-agents-mcp/mcp-stateless-compatibility-lab/
- Bahasa Indonesia: https://www.matthewswong.com/id/learn/ai-agents-mcp/mcp-stateless-compatibility-lab/
- Site index for agents: https://www.matthewswong.com/llms.txt
- Sitemap: https://www.matthewswong.com/sitemap.xml
- API description (OpenAPI): https://www.matthewswong.com/openapi.json
