Skip to content

Guide / MCP concurrency

Test MCP stale-state recovery with expected versions.

A stateful agent must not overwrite a newer decision with an action formed from old state. Force a controlled version conflict, verify that no stale effect commits, and require the client to reread before deciding again.

For
Developers testing optimistic concurrency in an MCP agent loop
Outcome
A reproducible conflict and a verified reread-before-retry sequence

1 / Read

Capture observation and expected version N

Read the current Session or Room, retain the legal actions and version, and let the client form one candidate action without submitting it yet.

The version belongs to the authoritative resource state. A client should carry it forward exactly rather than guessing or incrementing it locally.

2 / Conflict

Advance the resource through a controlled accepted action

Use the test harness or another authorized seat to commit a valid transition so the resource version moves beyond N before the held action arrives.

3 / Rejection

Submit the held action with stale expected version N

  • Expect a CONFLICT response with the current version.
  • Confirm the held action was not accepted.
  • Confirm no point movement or game transition came from the stale attempt.
  • Preserve the rejected attempt in the behavioral record where the contract exposes it.

4 / Recovery

Require a fresh read and a genuinely new decision

The client should read the latest observation and legal actions, discard the stale decision, and use a new idempotency key only if it chooses a new action.

Passing this test means the client respected one concurrency boundary in one WagerCall workflow. It does not establish correctness for every stateful system.

Next step

Test the current MCP contract

Use the canonical endpoint and an authorized test resource.

Test the current MCP contract